From 076e3dd2799d046c2163429276fc72ff674a4520 Mon Sep 17 00:00:00 2001 From: Swrup Date: Tue, 30 Jan 2024 00:20:36 +0100 Subject: [PATCH] add more options to tile_layer --- src/layer.ml | 57 ++++++++++++++++++++++++++++++++++++++++++++------- src/layer.mli | 13 ++++++++++++ 2 files changed, 63 insertions(+), 7 deletions(-) diff --git a/src/layer.ml b/src/layer.ml index fa9dc0d..ec9bb68 100644 --- a/src/layer.ml +++ b/src/layer.ml @@ -129,11 +129,25 @@ type tile_layer_opt = | Tms of bool | Zoom_reverse of bool | Detect_retina of bool - (* TODO allow string for those two - "Whether the crossOrigin attribute will be added to the tiles. If a String is provided, all tiles will have their crossOrigin attribute set to the String provided. This is needed if you want to access tile pixel data. Refer to CORS Settings for valid String values." - *) - | Cross_origin of bool + | (* TODO allow string for those two + "Whether the crossOrigin attribute will be added to the tiles. If a String is provided, all tiles will have their crossOrigin attribute set to the String provided. This is needed if you want to access tile pixel data. Refer to CORS Settings for valid String values." + *) + Cross_origin of bool | Referrer_policy of bool + | (* GridLayer options *) + Tile_size of Point.t + | Opacity of float + | Update_when_idle of bool + | Update_when_zooming of bool + | Update_interval of int + | Z_index of int + | Bounds of (* LatLngBounds *) Latlng.t * Latlng.t + | Max_native_zoom of int + | Min_native_zoom of int + | No_wrap of bool + | Pane of string + | Class_name of string + | Keep_buffer of int let tile_layer_opt_to_string = function | Min_zoom _ -> "minZoom" @@ -146,17 +160,46 @@ let tile_layer_opt_to_string = function | Detect_retina _ -> "detectRetina" | Cross_origin _ -> "crossOrigin" | Referrer_policy _ -> "referrerPolicy" + | Tile_size _ -> "tileSize" + | Opacity _ -> "opacity" + | Update_when_idle _ -> "updateWhenIdle" + | Update_when_zooming _ -> "updateWhenZooming" + | Update_interval _ -> "updateInterval" + | Z_index _ -> "zIndex" + | Bounds _ -> "bounds" + | Max_native_zoom _ -> "maxNativeZoom" + | Min_native_zoom _ -> "minNativeZoom" + | No_wrap _ -> "noWrap" + | Pane _ -> "pane" + | Class_name _ -> "className" + | Keep_buffer _ -> "keepBuffer" let tile_layer_opt_to_jv = function - | Min_zoom o | Max_zoom o | Zoom_offset o -> Jv.of_int o + | Min_zoom o + | Max_zoom o + | Zoom_offset o + | Update_interval o + | Z_index o + | Keep_buffer o + | Min_native_zoom o + | Max_native_zoom o -> + Jv.of_int o | Tms o | Zoom_reverse o | Detect_retina o | Cross_origin o - | Referrer_policy o -> + | Referrer_policy o + | Update_when_idle o + | Update_when_zooming o + | No_wrap o -> Jv.of_bool o - | Error_tile_url o -> Jv.of_string o + | Error_tile_url o | Pane o | Class_name o -> Jv.of_string o | Subdomains o -> Jv.of_array Jv.of_string o + | Opacity o -> Jv.of_float o + | Tile_size o -> Point.to_jv o + | Bounds (a, b) -> + (* create the actual LatlngBounds from the pair *) + 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 = diff --git a/src/layer.mli b/src/layer.mli index bd5513d..5c28258 100644 --- a/src/layer.mli +++ b/src/layer.mli @@ -75,6 +75,19 @@ type tile_layer_opt = | Detect_retina of bool | Cross_origin of bool | Referrer_policy of bool + | Tile_size of Point.t + | Opacity of float + | Update_when_idle of bool + | Update_when_zooming of bool + | Update_interval of int + | Z_index of int + | Bounds of (* LatLngBounds *) Latlng.t * Latlng.t + | Max_native_zoom of int + | Min_native_zoom of int + | No_wrap of bool + | Pane of string + | Class_name of string + | Keep_buffer of int (** [create_tile url attribution opts] create a new tile layer *) val create_tile :