add polyline layer
This commit is contained in:
parent
076e3dd279
commit
3d19bc3f40
2 changed files with 25 additions and 9 deletions
29
src/layer.ml
29
src/layer.ml
|
|
@ -5,59 +5,61 @@ type _ t =
|
||||||
| Geojson : Jv.t -> [> `Geojson ] t
|
| Geojson : Jv.t -> [> `Geojson ] t
|
||||||
| Marker : Jv.t -> [> `Marker ] t
|
| Marker : Jv.t -> [> `Marker ] t
|
||||||
| Tile : Jv.t -> [> `Tile ] t
|
| Tile : Jv.t -> [> `Tile ] t
|
||||||
|
| Vector : Jv.t -> [> `Vector ] t
|
||||||
|
|
||||||
type _ sub =
|
type _ sub =
|
||||||
| Basic : [> `Basic ] sub
|
| Basic : [> `Basic ] sub
|
||||||
| Geojson : [> `Geojson ] sub
|
| Geojson : [> `Geojson ] sub
|
||||||
| Marker : [> `Marker ] sub
|
| Marker : [> `Marker ] sub
|
||||||
| Tile : [> `Tile ] sub
|
| Tile : [> `Tile ] sub
|
||||||
|
| Vector : [> `Vector ] sub
|
||||||
|
|
||||||
(** Basic layers *)
|
(** Basic layers *)
|
||||||
|
|
||||||
let add_to : type kind. Map.t -> kind t -> unit =
|
let add_to : type kind. Map.t -> kind t -> unit =
|
||||||
fun map -> function
|
fun map -> function
|
||||||
| Basic l | Geojson l | Marker l | Tile l ->
|
| Basic l | Geojson l | Marker l | Tile l | Vector l ->
|
||||||
let (_ : Jv.t) = Jv.call l "addTo" [| Map.to_jv map |] in
|
let (_ : Jv.t) = Jv.call l "addTo" [| Map.to_jv map |] in
|
||||||
()
|
()
|
||||||
|
|
||||||
let remove : type kind. kind t -> unit = function
|
let remove : type kind. kind t -> unit = function
|
||||||
| Basic l | Geojson l | Marker l | Tile l ->
|
| Basic l | Geojson l | Marker l | Tile l | Vector l ->
|
||||||
let (_ : Jv.t) = Jv.call l "remove" [||] in
|
let (_ : Jv.t) = Jv.call l "remove" [||] in
|
||||||
()
|
()
|
||||||
|
|
||||||
let remove_from : type kind. Map.t -> kind t -> unit =
|
let remove_from : type kind. Map.t -> kind t -> unit =
|
||||||
fun map -> function
|
fun map -> function
|
||||||
| Basic l | Geojson l | Marker l | Tile l ->
|
| Basic l | Geojson l | Marker l | Tile l | Vector l ->
|
||||||
let (_ : Jv.t) = Jv.call l "removeFrom" [| Map.to_jv map |] in
|
let (_ : Jv.t) = Jv.call l "removeFrom" [| Map.to_jv map |] in
|
||||||
()
|
()
|
||||||
|
|
||||||
let bind_popup : type kind. Popup.t -> kind t -> unit =
|
let bind_popup : type kind. Popup.t -> kind t -> unit =
|
||||||
fun popup -> function
|
fun popup -> function
|
||||||
| Basic layer | Geojson layer | Marker layer | Tile layer ->
|
| Basic layer | Geojson layer | Marker layer | Tile layer | Vector layer ->
|
||||||
let (_ : Jv.t) = Jv.call layer "bindPopup" [| Popup.to_jv popup |] in
|
let (_ : Jv.t) = Jv.call layer "bindPopup" [| Popup.to_jv popup |] in
|
||||||
()
|
()
|
||||||
|
|
||||||
let unbind_popup : type kind. kind t -> unit = function
|
let unbind_popup : type kind. kind t -> unit = function
|
||||||
| Basic l | Geojson l | Marker l | Tile l ->
|
| Basic l | Geojson l | Marker l | Tile l | Vector l ->
|
||||||
let (_ : Jv.t) = Jv.call l "unbindPopup" [||] in
|
let (_ : Jv.t) = Jv.call l "unbindPopup" [||] in
|
||||||
()
|
()
|
||||||
|
|
||||||
let open_popup : type kind. kind t -> unit = function
|
let open_popup : type kind. kind t -> unit = function
|
||||||
| Basic l | Geojson l | Marker l | Tile l ->
|
| Basic l | Geojson l | Marker l | Tile l | Vector l ->
|
||||||
let (_ : Jv.t) = Jv.call l "openPopup" [||] in
|
let (_ : Jv.t) = Jv.call l "openPopup" [||] in
|
||||||
()
|
()
|
||||||
|
|
||||||
let close_popup : type kind. kind t -> unit = function
|
let close_popup : type kind. kind t -> unit = function
|
||||||
| Basic l | Geojson l | Marker l | Tile l ->
|
| Basic l | Geojson l | Marker l | Tile l | Vector l ->
|
||||||
let (_ : Jv.t) = Jv.call l "closePopup" [||] in
|
let (_ : Jv.t) = Jv.call l "closePopup" [||] in
|
||||||
()
|
()
|
||||||
|
|
||||||
let get_popup : type kind. kind t -> Popup.t = function
|
let get_popup : type kind. kind t -> Popup.t = function
|
||||||
| Basic l | Geojson l | Marker l | Tile l ->
|
| Basic l | Geojson l | Marker l | Tile l | Vector l ->
|
||||||
Jv.call l "getPopup" [||] |> Popup.of_jv
|
Jv.call l "getPopup" [||] |> Popup.of_jv
|
||||||
|
|
||||||
let to_jv : type kind. kind t -> Jv.t = function
|
let to_jv : type kind. kind t -> Jv.t = function
|
||||||
| Basic l | Geojson l | Marker l | Tile l -> l
|
| Basic l | Geojson l | Marker l | Tile l | Vector l -> l
|
||||||
|
|
||||||
let of_jv : type kind. kind sub -> Jv.t -> kind t =
|
let of_jv : type kind. kind sub -> Jv.t -> kind t =
|
||||||
fun tag l ->
|
fun tag l ->
|
||||||
|
|
@ -66,6 +68,7 @@ let of_jv : type kind. kind sub -> Jv.t -> kind t =
|
||||||
| Geojson -> Geojson l
|
| Geojson -> Geojson l
|
||||||
| Marker -> Marker l
|
| Marker -> Marker l
|
||||||
| Tile -> Tile l
|
| Tile -> Tile l
|
||||||
|
| Vector -> Vector l
|
||||||
|
|
||||||
let on : type kind. kind Event.sub -> (kind Event.t -> 'b) -> 'c t -> unit =
|
let on : type kind. kind Event.sub -> (kind Event.t -> 'b) -> 'c t -> unit =
|
||||||
fun event handler layer ->
|
fun event handler layer ->
|
||||||
|
|
@ -225,3 +228,11 @@ let create_tile_osm : tile_layer_opt list -> [ `Tile ] t =
|
||||||
contributors"
|
contributors"
|
||||||
in
|
in
|
||||||
create_tile url ~attribution options
|
create_tile url ~attribution options
|
||||||
|
|
||||||
|
(* Vector Layers *)
|
||||||
|
|
||||||
|
let create_polyline : Latlng.t list -> [ `Vector ] t =
|
||||||
|
fun l ->
|
||||||
|
let l = Jv.of_list Latlng.to_jv l in
|
||||||
|
let jv_t = Jv.call Global.leaflet "polyline" [| l |] in
|
||||||
|
Vector jv_t
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,14 @@ type _ t =
|
||||||
| Geojson : Jv.t -> [> `Geojson ] t
|
| Geojson : Jv.t -> [> `Geojson ] t
|
||||||
| Marker : Jv.t -> [> `Marker ] t
|
| Marker : Jv.t -> [> `Marker ] t
|
||||||
| Tile : Jv.t -> [> `Tile ] t
|
| Tile : Jv.t -> [> `Tile ] t
|
||||||
|
| Vector : Jv.t -> [> `Vector ] t
|
||||||
|
|
||||||
type _ sub =
|
type _ sub =
|
||||||
| Basic : [> `Basic ] sub
|
| Basic : [> `Basic ] sub
|
||||||
| Geojson : [> `Geojson ] sub
|
| Geojson : [> `Geojson ] sub
|
||||||
| Marker : [> `Marker ] sub
|
| Marker : [> `Marker ] sub
|
||||||
| Tile : [> `Tile ] sub
|
| Tile : [> `Tile ] sub
|
||||||
|
| Vector : [> `Vector ] sub
|
||||||
|
|
||||||
(** Basic layers *)
|
(** Basic layers *)
|
||||||
|
|
||||||
|
|
@ -97,3 +99,6 @@ val create_tile :
|
||||||
attribution set to [openstreetmap.org]. See
|
attribution set to [openstreetmap.org]. See
|
||||||
{:https://wiki.openstreetmap.org/wiki/Tile_servers} *)
|
{:https://wiki.openstreetmap.org/wiki/Tile_servers} *)
|
||||||
val create_tile_osm : tile_layer_opt list -> [ `Tile ] t
|
val create_tile_osm : tile_layer_opt list -> [ `Tile ] t
|
||||||
|
|
||||||
|
(** [create_polyline l] create a polyline layer from [l] *)
|
||||||
|
val create_polyline : Latlng.t list -> [ `Vector ] t
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue