add geojson options
This commit is contained in:
parent
6aca93ebe9
commit
502614b9d4
2 changed files with 46 additions and 5 deletions
36
src/layer.ml
36
src/layer.ml
|
|
@ -78,9 +78,39 @@ let on : type kind. kind Event.sub -> (kind Event.t -> 'b) -> 'c t -> unit =
|
|||
|
||||
(** Geojson layers *)
|
||||
|
||||
let create_geojson : ?options:Jv.t -> Jv.t -> [ `Geojson ] t =
|
||||
fun ?(options = Jv.null) geojson ->
|
||||
let jv_t = Jv.call Global.leaflet "geoJSON" [| geojson; options |] in
|
||||
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
|
||||
|
||||
let geojson_opt_to_string = function
|
||||
| Point_to_layer _ -> "pointToLayer"
|
||||
| Style _ -> "style"
|
||||
| On_each_feature _ -> "onEachFeature"
|
||||
| Filter _ -> "filter"
|
||||
| Coords_to_latlng _ -> "coordsToLatLng"
|
||||
| Markers_inherit_options _ -> "markersInheritOptions"
|
||||
|
||||
let geojson_opt_to_jv = function
|
||||
| Markers_inherit_options b -> Jv.of_bool b
|
||||
| Point_to_layer f -> Jv.repr f
|
||||
| Style f -> Jv.repr f
|
||||
| On_each_feature f -> Jv.repr f
|
||||
| Filter f -> Jv.repr f
|
||||
| Coords_to_latlng f -> Jv.repr f
|
||||
|
||||
let create_geojson : Jv.t -> geojson_opt list -> [ `Geojson ] t =
|
||||
fun geojson options ->
|
||||
let l =
|
||||
Array.of_list
|
||||
@@ List.map
|
||||
(fun o -> (geojson_opt_to_string o, geojson_opt_to_jv o))
|
||||
options
|
||||
in
|
||||
let jv_t = Jv.call Global.leaflet "geoJSON" [| geojson; Jv.obj l |] in
|
||||
Geojson jv_t
|
||||
|
||||
(** Marker layers *)
|
||||
|
|
|
|||
|
|
@ -50,11 +50,21 @@ 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 : ?options:Jv.t -> Jv.t -> [ `Geojson ] t
|
||||
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
|
||||
|
|
@ -69,7 +79,8 @@ type marker_opt =
|
|||
| Bubbling_mouse_events of bool
|
||||
| Auto_pan_on_focus of bool
|
||||
|
||||
(** [create_marker latlng] is a new marker with the same position as latlng *)
|
||||
(** [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 *)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue