add popup options

This commit is contained in:
Swrup 2022-06-20 10:05:35 +02:00
parent a438e54f42
commit ede9b2076d
6 changed files with 101 additions and 9 deletions

View file

@ -21,3 +21,59 @@ let close map =
()
let of_jv = Fun.id
type opt =
| Pane of string
| Offset of Point.t
| Max_width of int
| Min_width of int
| Max_height of int
| Auto_pan of bool
| Auto_pan_padding_top_left of Point.t
| Auto_pan_padding_bottom_right of Point.t
| Auto_pan_padding of Point.t
| Keep_in_view of bool
| Close_button of bool
| Auto_close of bool
| Close_on_escape_key of bool
| Close_on_click of bool
| Class_name of string
let opt_to_string = function
| Pane _ -> "pane"
| Offset _ -> "offset"
| Max_width _ -> "maxWidth"
| Min_width _ -> "minWidth"
| Max_height _ -> "maxHeight"
| Auto_pan _ -> "autoPan"
| Auto_pan_padding_top_left _ -> "autoPanPaddingTopLeft"
| Auto_pan_padding_bottom_right _ -> "autoPanPaddingBottomRight"
| Auto_pan_padding _ -> "autoPanPadding"
| Keep_in_view _ -> "keepInView"
| Close_button _ -> "closeButton"
| Auto_close _ -> "autoClose"
| Close_on_escape_key _ -> "closeOnEscapeKey"
| Close_on_click _ -> "closeOnClick"
| Class_name _ -> "className"
let opt_to_jv = function
| Offset p
| Auto_pan_padding_top_left p
| Auto_pan_padding_bottom_right p
| Auto_pan_padding p ->
Point.to_jv p
| Max_width i | Min_width i | Max_height i -> Jv.of_int i
| Auto_pan b
| Keep_in_view b
| Close_button b
| Auto_close b
| Close_on_escape_key b
| Close_on_click b ->
Jv.of_bool b
| Pane s | Class_name s -> Jv.of_string s
let create options =
let l =
Array.of_list @@ List.map (fun o -> (opt_to_string o, opt_to_jv o)) options
in
Jv.call Global.leaflet "popup" [| Jv.obj l |]