@vinctus/react-maplibre 0.2.9 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Layer.js +15 -3
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
package/dist/Layer.js
CHANGED
|
@@ -14,9 +14,21 @@ export const Layer = ({ layer, source }) => {
|
|
|
14
14
|
map.addLayer(parsedLayer);
|
|
15
15
|
}
|
|
16
16
|
return () => {
|
|
17
|
-
if (added) {
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
if (added && map && !map._removed) {
|
|
18
|
+
try {
|
|
19
|
+
// Check if layer exists before removing
|
|
20
|
+
if (map.getLayer(parsedLayer.id)) {
|
|
21
|
+
map.removeLayer(parsedLayer.id); // when removing, the layer must be removed first, and then the source
|
|
22
|
+
}
|
|
23
|
+
// Check if source exists before removing
|
|
24
|
+
if (map.getSource(parsedLayer.id)) {
|
|
25
|
+
map.removeSource(parsedLayer.id);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
// Silently handle cleanup errors during navigation
|
|
30
|
+
console.warn('Layer cleanup error:', error);
|
|
31
|
+
}
|
|
20
32
|
}
|
|
21
33
|
};
|
|
22
34
|
}, [layerString, sourceString, map, mapLoaded]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../src/ErrorBoundary.tsx","../src/GeolocateControl.tsx","../src/Layer.tsx","../src/Map.tsx","../src/Marker.tsx","../src/NavigationControl.tsx","../src/Popup.tsx","../src/ScaleControl.tsx","../src/index.tsx","../src/types.tsx"],"version":"5.8.2"}
|