list -> array

This commit is contained in:
Swrup 2024-01-30 16:55:19 +01:00
parent d7de66c1be
commit 59e22333e7
9 changed files with 30 additions and 39 deletions

View file

@ -110,13 +110,10 @@ let geojson_opt_to_jv = function
| Filter f -> Jv.repr f
| Coords_to_latlng f -> Jv.repr f
let create_geojson : Jv.t -> geojson_opt list -> [ `Geojson ] t =
let create_geojson : Jv.t -> geojson_opt array -> [ `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
Array.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
@ -205,21 +202,21 @@ let tile_layer_opt_to_jv = function
Jv.call Global.leaflet "latLngBounds" [| Latlng.to_jv a; Latlng.to_jv b |]
let create_tile :
string -> attribution:string -> tile_layer_opt list -> [ `Tile ] t =
string -> attribution:string -> tile_layer_opt array -> [ `Tile ] t =
fun url ~attribution options ->
let arr =
Array.of_list
@@ ("attribution", Jv.of_string attribution)
:: List.map
(fun o -> (tile_layer_opt_to_string o, tile_layer_opt_to_jv o))
options
Array.append
[| ("attribution", Jv.of_string attribution) |]
(Array.map
(fun o -> (tile_layer_opt_to_string o, tile_layer_opt_to_jv o))
options )
in
let jv_t =
Jv.call Global.leaflet "tileLayer" [| Jv.of_string url; Jv.obj arr |]
in
Tile jv_t
let create_tile_osm : tile_layer_opt list -> [ `Tile ] t =
let create_tile_osm : tile_layer_opt array -> [ `Tile ] t =
fun options ->
let url = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" in
let attribution =
@ -231,8 +228,8 @@ let create_tile_osm : tile_layer_opt list -> [ `Tile ] t =
(* Vector Layers *)
let create_polyline : Latlng.t list -> [ `Vector ] t =
let create_polyline : Latlng.t array -> [ `Vector ] t =
fun l ->
let l = Jv.of_list Latlng.to_jv l in
let l = Jv.of_array Latlng.to_jv l in
let jv_t = Jv.call Global.leaflet "polyline" [| l |] in
Vector jv_t