From 62e52aea177da99ce119d9eaef86f5b153db86d6 Mon Sep 17 00:00:00 2001 From: marc tobias Date: Tue, 29 Aug 2023 22:47:34 +0200 Subject: [PATCH 1/1] Map: delete old viewbox rectangle before adding a new one --- src/components/Map.svelte | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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; -- 2.39.5