From bdb214b388f5d9dae7f06c8205780284b7b20a11 Mon Sep 17 00:00:00 2001 From: Jan Piskvor Martinec Date: Wed, 8 Mar 2023 15:59:32 +0100 Subject: [PATCH] add Nominatim_Config.Map_Default_Bounds config value - use fitBounds(Map_Default_Bounds) if this config value exists - center and zoom is not always provided from data - getting a bounding box might be easier in some use cases --- dist/config.defaults.js | 1 + src/components/Map.svelte | 3 +++ 2 files changed, 4 insertions(+) diff --git a/dist/config.defaults.js b/dist/config.defaults.js index fa0556c..27d98a8 100644 --- a/dist/config.defaults.js +++ b/dist/config.defaults.js @@ -33,6 +33,7 @@ let Nominatim_Config = { Map_Default_Lat: 20.0, Map_Default_Lon: 0.0, Map_Default_Zoom: 2, + Map_Default_Bounds: null, // For what {x}, {y} etc stand for see // https://leafletjs.com/reference-1.9.1.html#tilelayer diff --git a/src/components/Map.svelte b/src/components/Map.svelte index 5426864..1ef199c 100644 --- a/src/components/Map.svelte +++ b/src/components/Map.svelte @@ -28,6 +28,9 @@ ], zoom: Nominatim_Config.Map_Default_Zoom }); + if (typeof Nominatim_Config.Map_Default_Bounds !== 'undefined' && Nominatim_Config.Map_Default_Bounds) { + map.fitBounds(Nominatim_Config.Map_Default_Bounds); + } if (attribution && attribution.length) { L.control.attribution({ prefix: 'Leaflet' }).addTo(map); -- 2.45.1