@vinctus/react-maplibre 0.2.15 → 0.2.16

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.
@@ -9,7 +9,12 @@ export const GeolocateControl = ({ position = 'bottom-right', options = { showUs
9
9
  map.addControl(control, position);
10
10
  }
11
11
  return () => {
12
- map === null || map === void 0 ? void 0 : map.removeControl(control);
12
+ try {
13
+ map === null || map === void 0 ? void 0 : map.removeControl(control);
14
+ }
15
+ catch (_a) {
16
+ // Map might be destroyed already, ignore cleanup errors
17
+ }
13
18
  };
14
19
  }, [position, options, map]);
15
20
  return null;
package/dist/Layer.js CHANGED
@@ -16,18 +16,17 @@ export const Layer = ({ layer, source }) => {
16
16
  return () => {
17
17
  if (added && map) {
18
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
- }
19
+ // Try to remove layer and source, ignoring errors if map is destroyed
20
+ map.removeLayer(parsedLayer.id);
27
21
  }
28
- catch (error) {
29
- // Silently handle cleanup errors during navigation
30
- console.warn('Layer cleanup error:', error);
22
+ catch (_a) {
23
+ // Layer might not exist or map might be destroyed
24
+ }
25
+ try {
26
+ map.removeSource(parsedLayer.id);
27
+ }
28
+ catch (_b) {
29
+ // Source might not exist or map might be destroyed
31
30
  }
32
31
  }
33
32
  };
@@ -12,7 +12,12 @@ export const NavigationControl = ({ position = 'bottom-right', options = {
12
12
  map.addControl(control, position);
13
13
  }
14
14
  return () => {
15
- map === null || map === void 0 ? void 0 : map.removeControl(control);
15
+ try {
16
+ map === null || map === void 0 ? void 0 : map.removeControl(control);
17
+ }
18
+ catch (_a) {
19
+ // Map might be destroyed already, ignore cleanup errors
20
+ }
16
21
  };
17
22
  }, [position, options, map]);
18
23
  return null;
@@ -9,7 +9,12 @@ export const ScaleControl = ({ position = 'bottom-right', options, }) => {
9
9
  map.addControl(control, position);
10
10
  }
11
11
  return () => {
12
- map === null || map === void 0 ? void 0 : map.removeControl(control);
12
+ try {
13
+ map === null || map === void 0 ? void 0 : map.removeControl(control);
14
+ }
15
+ catch (_a) {
16
+ // Map might be destroyed already, ignore cleanup errors
17
+ }
13
18
  };
14
19
  }, [position, options, map]);
15
20
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vinctus/react-maplibre",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "description": "Minimalist MapLibre GL JS React wrapper library",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",