@vinctus/react-maplibre 0.2.18 → 0.2.19

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.
@@ -13,8 +13,9 @@ export class ErrorBoundary extends Component {
13
13
  console.error('Uncaught map error:', error, errorInfo);
14
14
  }
15
15
  render() {
16
- if (this.state.hasError)
16
+ if (this.state.hasError) {
17
17
  return this.props.fallback || _jsx("h1", { children: "Sorry.. there was a map error" });
18
+ }
18
19
  return this.props.children;
19
20
  }
20
21
  }
package/dist/Layer.js CHANGED
@@ -16,11 +16,11 @@ export const Layer = ({ layer, source }) => {
16
16
  return () => {
17
17
  if (map) {
18
18
  // Check if layer exists before removing
19
- if (map.getLayer && map.getLayer(parsedLayer.id)) {
19
+ if (map.getLayer(parsedLayer.id)) {
20
20
  map.removeLayer(parsedLayer.id); // when removing, the layer must be removed first, and then the source
21
21
  }
22
22
  // Check if source exists before removing
23
- if (map.getSource && map.getSource(parsedLayer.id)) {
23
+ if (map.getSource(parsedLayer.id)) {
24
24
  map.removeSource(parsedLayer.id);
25
25
  }
26
26
  }
package/dist/Map.js CHANGED
@@ -47,23 +47,28 @@ export const Map = React.forwardRef((_a, ref) => {
47
47
  const optionsString = JSON.stringify(options);
48
48
  useImperativeHandle(ref, () => map, [map]);
49
49
  useEffect(() => {
50
- if (map)
50
+ if (map) {
51
51
  return; // initialize map only once
52
+ }
52
53
  if (mapContainer.current) {
53
54
  const parsedOptions = JSON.parse(optionsString);
54
55
  const m = new maplibre.Map(Object.assign({ container: mapContainer.current, style: mapStyle, center: [longitude, latitude], zoom }, parsedOptions));
55
56
  mapInstanceRef.current = m;
56
- if (onDragEnd)
57
+ if (onDragEnd) {
57
58
  addEventHandler(m, 'dragend', onDragEnd);
58
- if (onLoad)
59
+ }
60
+ if (onLoad) {
59
61
  addEventHandler(m, 'load', (ev) => {
60
62
  onLoad(ev);
61
63
  setMapLoaded(true);
62
64
  });
63
- if (onMoveEnd)
65
+ }
66
+ if (onMoveEnd) {
64
67
  addEventHandler(m, 'moveend', onMoveEnd);
65
- if (onZoomEnd)
68
+ }
69
+ if (onZoomEnd) {
66
70
  addEventHandler(m, 'zoomend', onZoomEnd);
71
+ }
67
72
  setMap(m);
68
73
  // Cleanup when component unmounts
69
74
  return () => {
package/dist/Marker.js CHANGED
@@ -24,8 +24,9 @@ export const Marker = (_a) => {
24
24
  const optionsString = JSON.stringify(options);
25
25
  const popupString = JSON.stringify(popup);
26
26
  useEffect(() => {
27
- if (!map)
27
+ if (!map) {
28
28
  return;
29
+ }
29
30
  const element = document.createElement('div');
30
31
  const parsedOptions = JSON.parse(optionsString);
31
32
  setResult(ReactDOM.createPortal(children, element));
package/dist/Popup.js CHANGED
@@ -26,8 +26,9 @@ export const Popup = (_a) => {
26
26
  .addTo(map);
27
27
  }
28
28
  return () => {
29
- if (popup)
29
+ if (popup) {
30
30
  popup.remove();
31
+ }
31
32
  };
32
33
  }, [children, latitude, longitude, map, optionsString]);
33
34
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vinctus/react-maplibre",
3
- "version": "0.2.18",
3
+ "version": "0.2.19",
4
4
  "description": "Minimalist MapLibre GL JS React wrapper library",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",