diff --git a/src/layer.ml b/src/layer.ml index fd2042c..b18c108 100644 --- a/src/layer.ml +++ b/src/layer.ml @@ -85,7 +85,7 @@ let on : type kind. kind Event.sub -> (kind Event.t -> 'b) -> 'c t -> unit = (** Geojson layers *) type geojson_opt = - | Point_to_layer of (Jv.t -> Latlng.t -> unit) + | Point_to_layer of (Jv.t -> Latlng.t -> [ `Marker ] t) | Style of (Jv.t -> unit) | On_each_feature of (Jv.t -> [ `Geojson ] t -> unit) | Filter of (Jv.t -> bool) @@ -102,7 +102,9 @@ let geojson_opt_to_string = function let geojson_opt_to_jv = function | Markers_inherit_options b -> Jv.of_bool b - | Point_to_layer f -> Jv.repr f + | Point_to_layer f -> + (* the marker returned by `pointToLayer` is used internally by leaflet so we neet to unwrap it to a Jv.t *) + Jv.repr (fun geojsonpoint latlng -> to_jv @@ f geojsonpoint latlng) | Style f -> Jv.repr f | On_each_feature f -> (* we need to wrap the Jv.t *) diff --git a/src/layer.mli b/src/layer.mli index 7eaabd2..9c7a7cd 100644 --- a/src/layer.mli +++ b/src/layer.mli @@ -52,7 +52,7 @@ val on : 'a Event.sub -> ('a Event.t -> 'b) -> 'c t -> unit (** type for geojson option, used to create geojson *) type geojson_opt = - | Point_to_layer of (Jv.t -> Latlng.t -> unit) + | Point_to_layer of (Jv.t -> Latlng.t -> [ `Marker ] t) | Style of (Jv.t -> unit) | On_each_feature of (Jv.t -> [ `Geojson ] t -> unit) | Filter of (Jv.t -> bool)