]> git.openstreetmap.org Git - nominatim-ui.git/commitdiff
Map: delete old viewbox rectangle before adding a new one
authormarc tobias <mtmail@gmx.net>
Tue, 29 Aug 2023 20:47:34 +0000 (22:47 +0200)
committermtmail <mtmail@gmx.net>
Tue, 29 Aug 2023 21:44:23 +0000 (23:44 +0200)
src/components/Map.svelte

index 37166f603ba9bda88ee93d79bfe84220898af293..7b1318713d7516946a5f438a896603464255eb24 100644 (file)
     if (viewbox) {
       let coords = viewbox.split(','); // <x1>,<y1>,<x2>,<y2>
       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;