leaflet/src/layer.mli
2022-06-20 10:05:35 +02:00

91 lines
2.6 KiB
OCaml

(* BSD-2-Clause License *)
type _ t =
| Basic : Jv.t -> [> `Basic ] t
| Geojson : Jv.t -> [> `Geojson ] t
| Marker : Jv.t -> [> `Marker ] t
| Tile : Jv.t -> [> `Tile ] t
type _ sub =
| Basic : [> `Basic ] sub
| Geojson : [> `Geojson ] sub
| Marker : [> `Marker ] sub
| Tile : [> `Tile ] sub
(** Basic layers *)
(** [add_to map layer] adds [layer] to [map] *)
val add_to : Map.t -> _ t -> unit
(** [remove layer] removes [layer] from the map it is currently active on *)
val remove : _ t -> unit
(** [remove_from map layer] removes [layer] from [map] *)
val remove_from : Map.t -> _ t -> unit
(** [bind_popup popup layer] binds [popup] to [layer] *)
val bind_popup : Brr.El.t -> Popup.opt list -> _ t -> unit
(** [unbind_popup layer] unbinds the popup bound to [layer] *)
val unbind_popup : _ t -> unit
(** [open_popup layer] opens the popup bound to [layer] *)
val open_popup : _ t -> unit
(** [close_popup layer] closes the popup bound to [layer] *)
val close_popup : _ t -> unit
(** [get_popup layer] is the popup bound to [layer] *)
val get_popup : _ t -> Popup.t
(** [to_jv o] is [o] as a {!Jv.t} *)
val to_jv : _ t -> Jv.t
(** [of_jv tag o] is [o] as a [tag t] *)
val of_jv : 'a sub -> Jv.t -> 'a t
(** [on event handler layer] add an event listener on [layer] for event [event]
with handler [handler] *)
val on : 'a Event.sub -> ('a Event.t -> 'b) -> 'c t -> unit
(** Geojson layers *)
(** type for geojson option, used to create geojson *)
type geojson_opt =
| Point_to_layer of (Jv.t -> Latlng.t -> unit)
| Style of (Jv.t -> unit)
| On_each_feature of (Jv.t -> [ `Geojson ] t -> unit)
| Filter of (Jv.t -> bool)
| Coords_to_latlng of (Jv.t -> Latlng.t)
| Markers_inherit_options of bool
(** [create_geojson geojson] is a new geojson layer *)
val create_geojson : Jv.t -> geojson_opt list -> [ `Geojson ] t
(** Marker layers *)
(** type for marker option, used to create marker *)
type marker_opt =
| Icon of Icon.t
| Keyboard of bool
| Title of string
| Alt of string
| Z_index_offset of int
| Opacity of float
| Rise_on_hover of bool
| Rise_offset of int
| Pane of string
| Shadow_pane of string
| 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 -> [ `Marker ] t
(** Tile layers *)
(** [create_tile_osm Some(url)] is a new tile layer with tile server specified
by [url]. Tile server default to [openstreetmap.org]. See
{:https://wiki.openstreetmap.org/wiki/Tile_servers} *)
val create_tile_osm : string option -> [ `Tile ] t