cleanup Marker

This commit is contained in:
Swrup 2024-01-29 23:05:24 +01:00
parent 65ee38b4ee
commit 25f51e0417
2 changed files with 9 additions and 10 deletions

View file

@ -3,7 +3,7 @@ include Layer
type t = [ `Marker ] Layer.t
type marker_opt =
type opt =
| Icon of Icon.t
| Keyboard of bool
| Title of string
@ -17,7 +17,7 @@ type marker_opt =
| Bubbling_mouse_events of bool
| Auto_pan_on_focus of bool
let marker_opt_to_string : marker_opt -> string = function
let opt_to_string : opt -> string = function
| Icon _ -> "icon"
| Keyboard _ -> "keyboard"
| Title _ -> "title"
@ -31,7 +31,7 @@ let marker_opt_to_string : marker_opt -> string = function
| Bubbling_mouse_events _ -> "bubblingMouseEvents"
| Auto_pan_on_focus _ -> "autoPanOnFocus"
let marker_opt_to_jv = function
let opt_to_jv = function
| Icon icon -> Icon.to_jv icon
| Keyboard b | Rise_on_hover b | Bubbling_mouse_events b | Auto_pan_on_focus b
->
@ -40,11 +40,10 @@ let marker_opt_to_jv = function
| Z_index_offset i | Rise_offset i -> Jv.of_int i
| Opacity f -> Jv.of_float f
let create_marker : Latlng.t -> marker_opt list -> t =
let create : Latlng.t -> opt list -> t =
fun latlng options ->
let l =
Array.of_list
@@ List.map (fun o -> (marker_opt_to_string o, marker_opt_to_jv o)) options
Array.of_list @@ List.map (fun o -> (opt_to_string o, opt_to_jv o)) options
in
let jv_t =
Jv.call Global.leaflet "marker" [| Latlng.to_jv latlng; Jv.obj l |]

View file

@ -1,7 +1,7 @@
type t = [ `Marker ] Layer.t
(** type for marker option, used to create marker *)
type marker_opt =
type opt =
| Icon of Icon.t
| Keyboard of bool
| Title of string
@ -15,9 +15,9 @@ type marker_opt =
| Bubbling_mouse_events of bool
| Auto_pan_on_focus of bool
(** [create_marker latlng options] is a new marker with the same position as
[latlng] and with options set to [options] *)
val create_marker : Latlng.t -> marker_opt list -> t
(** [create latlng options] is a new marker with the same position as [latlng]
and with options set to [options] *)
val create : Latlng.t -> opt list -> t
(** Returns the current geographical position of the marker. *)
val get_latlng : t -> Latlng.t