From: marc tobias Date: Tue, 29 Aug 2023 20:47:34 +0000 (+0200) Subject: Map: delete old viewbox rectangle before adding a new one X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/commitdiff_plain/62e52aea177da99ce119d9eaef86f5b153db86d6?hp=426a3b71efeda0e140383cbf96b65309bab98bd1 Map: delete old viewbox rectangle before adding a new one --- diff --git a/src/components/Map.svelte b/src/components/Map.svelte index 37166f6..7b13187 100644 --- a/src/components/Map.svelte +++ b/src/components/Map.svelte @@ -127,13 +127,16 @@ if (viewbox) { let coords = viewbox.split(','); // ,,, let bounds = L.latLngBounds([coords[1], coords[0]], [coords[3], coords[2]]); - L.rectangle(bounds, { + let viewbox_on_map = L.rectangle(bounds, { color: '#69d53e', weight: 3, dashArray: '5 5', opacity: 0.8, - fill: false - }).addTo(map); + fill: false, + interactive: false + }); + map.addLayer(viewbox_on_map); + dataLayers.push(viewbox_on_map); } if (!aFeature) return;