@mapcomponents/react-maplibre 0.1.18 → 0.1.22
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/CHANGELOG.md +13 -0
- package/coverage/clover.xml +222 -205
- package/coverage/coverage-final.json +6 -6
- package/coverage/lcov-report/index.html +30 -30
- package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.js.html +1 -1
- package/coverage/lcov-report/src/components/MapLibreMap/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.js.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.js.html +1 -1
- package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.js.html +1 -1
- package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +1 -1
- package/coverage/lcov-report/src/components/MlGPXViewer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js.html +20 -5
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayer/MlLayer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.js.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.js.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
- package/coverage/lcov-report/src/components/MlMarker/MlMarker.js.html +1 -1
- package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.js.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.js.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationTools/index.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
- package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +261 -111
- package/coverage/lcov-report/src/components/MlShareMapState/index.html +9 -9
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +1 -1
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
- package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
- package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
- package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.js.html +110 -17
- package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +15 -15
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.js.html +35 -89
- package/coverage/lcov-report/src/components/MlWmsLayer/index.html +17 -17
- package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.js.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
- package/coverage/lcov-report/src/hooks/index.html +1 -1
- package/coverage/lcov-report/src/hooks/useMap.js.html +23 -23
- package/coverage/lcov-report/src/hooks/useMapState.js.html +34 -34
- package/coverage/lcov-report/src/hooks/useWms.js.html +1 -1
- package/coverage/lcov-report/src/i18n.js.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/translations/english.js.html +1 -1
- package/coverage/lcov-report/src/translations/german.js.html +1 -1
- package/coverage/lcov-report/src/translations/index.html +1 -1
- package/coverage/lcov.info +390 -349
- package/dist/index.esm.js +90 -68
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/scripts/build-catalogue-markdown-docs.js +5 -3
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.js +26 -21
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.test.js +3 -3
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.doc.de.md +2 -2
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.doc.en.md +3 -0
- package/src/components/MlFeatureEditor/MlFeatureEditor.test.js +2 -2
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js +8 -3
- package/src/components/MlNavigationCompass/MlNavigationCompass.test.js +2 -2
- package/src/components/MlShareMapState/MlShareMapState.js +138 -88
- package/src/components/MlShareMapState/MlShareMapState.stories.js +79 -29
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.js +40 -9
- package/src/components/MlWmsLayer/MlWmsLayer.js +16 -34
- package/src/hooks/useMap.js +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -331,7 +331,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
331
331
|
/**
|
|
332
332
|
* Maps layerIds to layerState in JSON string form for quick deep comparisons
|
|
333
333
|
*/
|
|
334
|
-
|
|
334
|
+
layerStateString: "",
|
|
335
335
|
|
|
336
336
|
/**
|
|
337
337
|
* Previous Version of layerStateString
|
|
@@ -345,26 +345,30 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
345
345
|
* @returns object
|
|
346
346
|
*/
|
|
347
347
|
buildLayerObject: function buildLayerObject(layer) {
|
|
348
|
-
var _layer$paint, _layer$layout;
|
|
349
|
-
|
|
350
348
|
//if (self.baseLayers.indexOf(layer.id) === -1) {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
Object.keys(values || {}).
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
349
|
+
//let paint = {};
|
|
350
|
+
//let values = layer.paint?._values;
|
|
351
|
+
//Object.keys(values || {}).map((propName) => {
|
|
352
|
+
// paint[propName] =
|
|
353
|
+
// typeof values[propName].value !== "undefined"
|
|
354
|
+
// ? values[propName].value.value
|
|
355
|
+
// : values[propName];
|
|
356
|
+
//});
|
|
357
|
+
//let layout = {};
|
|
358
|
+
//values = layer.layout?._values;
|
|
359
|
+
//Object.keys(values || {}).map((propName) => {
|
|
360
|
+
// layout[propName] =
|
|
361
|
+
// typeof values[propName].value !== "undefined"
|
|
362
|
+
// ? values[propName].value.value
|
|
363
|
+
// : values[propName];
|
|
364
|
+
//});
|
|
361
365
|
return {
|
|
362
366
|
id: layer.id,
|
|
363
367
|
type: layer.type,
|
|
364
368
|
visible: layer.visibility === "none" ? false : true,
|
|
365
|
-
baseLayer: self.baseLayers.indexOf(layer.id) !== -1,
|
|
366
|
-
|
|
367
|
-
|
|
369
|
+
baseLayer: self.baseLayers.indexOf(layer.id) !== -1 //paint,
|
|
370
|
+
//layout,
|
|
371
|
+
//filter: layers[layerId].filter,
|
|
368
372
|
//layout: layers[layerId].layout,
|
|
369
373
|
//maxzoom: layers[layerId].maxzoom,
|
|
370
374
|
//metadata: layers[layerId].metadata,
|
|
@@ -394,9 +398,11 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
394
398
|
*/
|
|
395
399
|
refreshLayerState: function refreshLayerState() {
|
|
396
400
|
self.wrapper.layerState = self.wrapper.buildLayerObjects();
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
401
|
+
|
|
402
|
+
if (JSON.stringify(self.wrapper.layerState) !== self.wrapper.layerStateString) {
|
|
403
|
+
self.wrapper.fire("layerchange");
|
|
404
|
+
self.wrapper.layerStateString = JSON.stringify(self.wrapper.layerState);
|
|
405
|
+
}
|
|
400
406
|
},
|
|
401
407
|
|
|
402
408
|
/**
|
|
@@ -733,16 +739,18 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
733
739
|
self.wrapper.viewportState = self.wrapper.getViewport();
|
|
734
740
|
self.wrapper.fire("viewportchange");
|
|
735
741
|
});
|
|
742
|
+
self.map.on("idle", function () {
|
|
743
|
+
self.wrapper.refreshLayerState();
|
|
744
|
+
});
|
|
736
745
|
self.map.on("data", function () {
|
|
737
746
|
self.wrapper.refreshLayerState();
|
|
738
|
-
self.wrapper.fire("layerchange");
|
|
739
747
|
});
|
|
740
748
|
|
|
741
749
|
if (typeof props.onReady === "function") {
|
|
742
750
|
props.onReady(self.map, self);
|
|
743
751
|
}
|
|
744
752
|
|
|
745
|
-
case
|
|
753
|
+
case 11:
|
|
746
754
|
case "end":
|
|
747
755
|
return _context.stop();
|
|
748
756
|
}
|
|
@@ -1520,7 +1528,7 @@ var MlGeoJsonLayer = function MlGeoJsonLayer(props) {
|
|
|
1520
1528
|
}
|
|
1521
1529
|
|
|
1522
1530
|
layerTypeRef.current = props.type || getDefaulLayerTypeByGeometry(props.geojson);
|
|
1523
|
-
mapHook.map.addLayer({
|
|
1531
|
+
mapHook.map.addLayer(_objectSpread2({
|
|
1524
1532
|
id: layerId.current,
|
|
1525
1533
|
source: {
|
|
1526
1534
|
type: "geojson",
|
|
@@ -1529,18 +1537,18 @@ var MlGeoJsonLayer = function MlGeoJsonLayer(props) {
|
|
|
1529
1537
|
type: layerTypeRef.current,
|
|
1530
1538
|
paint: props.paint || getDefaultPaintPropsByType(layerTypeRef.current, props.defaultPaintOverrides),
|
|
1531
1539
|
layout: props.layout || {}
|
|
1532
|
-
}, props.insertBeforeLayer, mapHook.componentId);
|
|
1540
|
+
}, props.options), props.insertBeforeLayer, mapHook.componentId);
|
|
1533
1541
|
|
|
1534
1542
|
if (typeof props.onHover !== "undefined") {
|
|
1535
|
-
mapHook.map.on("mousemove",
|
|
1543
|
+
mapHook.map.on("mousemove", layerId.current, props.onHover, mapHook.componentId);
|
|
1536
1544
|
}
|
|
1537
1545
|
|
|
1538
1546
|
if (typeof props.onClick !== "undefined") {
|
|
1539
|
-
mapHook.map.on("click",
|
|
1547
|
+
mapHook.map.on("click", layerId.current, props.onClick, mapHook.componentId);
|
|
1540
1548
|
}
|
|
1541
1549
|
|
|
1542
1550
|
if (typeof props.onLeave !== "undefined") {
|
|
1543
|
-
mapHook.map.on("mouseleave",
|
|
1551
|
+
mapHook.map.on("mouseleave", layerId.current, props.onLeave, mapHook.componentId);
|
|
1544
1552
|
}
|
|
1545
1553
|
|
|
1546
1554
|
if (props.type === "line" && typeof props.transitionTime !== "undefined" && typeof props.geojson.geometry !== "undefined") {
|
|
@@ -1599,6 +1607,11 @@ MlGeoJsonLayer.propTypes = {
|
|
|
1599
1607
|
*/
|
|
1600
1608
|
defaultPaintOverrides: PropTypes.object,
|
|
1601
1609
|
|
|
1610
|
+
/**
|
|
1611
|
+
* Javascript object that is spread into the addLayer commands first parameter.
|
|
1612
|
+
*/
|
|
1613
|
+
options: PropTypes.object,
|
|
1614
|
+
|
|
1602
1615
|
/**
|
|
1603
1616
|
* GeoJSON data that is supposed to be rendered by this component.
|
|
1604
1617
|
*/
|
|
@@ -2676,6 +2689,7 @@ var MlVectorTileLayer = function MlVectorTileLayer(props) {
|
|
|
2676
2689
|
var idSuffixRef = useRef(new Date().getTime());
|
|
2677
2690
|
var layerIdsRef = useRef({});
|
|
2678
2691
|
var layerPaintConfsRef = useRef({});
|
|
2692
|
+
var layerLayoutConfsRef = useRef({});
|
|
2679
2693
|
var initializedRef = useRef(false);
|
|
2680
2694
|
var mapRef = useRef(null);
|
|
2681
2695
|
|
|
@@ -2701,13 +2715,12 @@ var MlVectorTileLayer = function MlVectorTileLayer(props) {
|
|
|
2701
2715
|
initializedRef.current = true;
|
|
2702
2716
|
mapRef.current = mapContext.getMap(props.mapId); // Add the new layer to the openlayers instance once it is available
|
|
2703
2717
|
|
|
2704
|
-
mapRef.current.addSource(sourceName + idSuffixRef.current, {
|
|
2718
|
+
mapRef.current.addSource(sourceName + idSuffixRef.current, _objectSpread2({
|
|
2705
2719
|
type: "vector",
|
|
2706
2720
|
tiles: [props.url],
|
|
2707
2721
|
tileSize: 512,
|
|
2708
|
-
attribution: ""
|
|
2709
|
-
|
|
2710
|
-
});
|
|
2722
|
+
attribution: ""
|
|
2723
|
+
}, props.sourceOptions));
|
|
2711
2724
|
|
|
2712
2725
|
for (var key in props.layers) {
|
|
2713
2726
|
var layerId = layerName + "_" + key + "_" + idSuffixRef.current;
|
|
@@ -2726,6 +2739,7 @@ var MlVectorTileLayer = function MlVectorTileLayer(props) {
|
|
|
2726
2739
|
}
|
|
2727
2740
|
}, props.layers[key]));
|
|
2728
2741
|
layerPaintConfsRef.current[key] = JSON.stringify(props.layers[key].paint);
|
|
2742
|
+
layerLayoutConfsRef.current[key] = JSON.stringify(props.layers[key].layout);
|
|
2729
2743
|
}
|
|
2730
2744
|
}, [mapContext.mapIds, props, mapContext]);
|
|
2731
2745
|
useEffect(function () {
|
|
@@ -2734,25 +2748,41 @@ var MlVectorTileLayer = function MlVectorTileLayer(props) {
|
|
|
2734
2748
|
|
|
2735
2749
|
for (var key in props.layers) {
|
|
2736
2750
|
if (mapRef.current.getLayer(layerIdsRef.current[key])) {
|
|
2737
|
-
|
|
2751
|
+
// update changed paint property
|
|
2752
|
+
var layerPaintConfString = JSON.stringify(props.layers[key].paint);
|
|
2738
2753
|
|
|
2739
|
-
if (
|
|
2754
|
+
if (layerPaintConfString !== layerPaintConfsRef.current[key]) {
|
|
2740
2755
|
for (var paintKey in props.layers[key].paint) {
|
|
2741
2756
|
mapContext.getMap(props.mapId).setPaintProperty(layerIdsRef.current[key], paintKey, props.layers[key].paint[paintKey]);
|
|
2742
2757
|
}
|
|
2743
2758
|
}
|
|
2744
2759
|
|
|
2745
|
-
layerPaintConfsRef.current[key] =
|
|
2760
|
+
layerPaintConfsRef.current[key] = layerPaintConfString; // update changed layout property
|
|
2761
|
+
|
|
2762
|
+
var layerLayoutConfString = JSON.stringify(props.layers[key].layout);
|
|
2763
|
+
|
|
2764
|
+
if (layerLayoutConfString !== layerLayoutConfsRef.current[key]) {
|
|
2765
|
+
for (var layoutKey in props.layers[key].layout) {
|
|
2766
|
+
mapContext.getMap(props.mapId).setLayoutProperty(layerIdsRef.current[key], layoutKey, props.layers[key].layout[layoutKey]);
|
|
2767
|
+
}
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2770
|
+
layerLayoutConfsRef.current[key] = layerLayoutConfString;
|
|
2746
2771
|
}
|
|
2747
2772
|
}
|
|
2748
2773
|
}, [props.layers, props, mapContext]);
|
|
2749
2774
|
useEffect(function () {
|
|
2750
|
-
if (!mapRef.current) return;
|
|
2775
|
+
if (!mapRef.current) return;
|
|
2751
2776
|
|
|
2752
|
-
|
|
2753
|
-
mapRef.current.
|
|
2754
|
-
|
|
2755
|
-
|
|
2777
|
+
for (var key in props.layers) {
|
|
2778
|
+
if (mapRef.current.getLayer(layerIdsRef.current[key])) {
|
|
2779
|
+
// toggle layer visibility by changing the layout object's visibility property
|
|
2780
|
+
if (props.visible) {
|
|
2781
|
+
mapContext.getMap(props.mapId).setLayoutProperty(layerIdsRef.current[key], "visibility", "visible");
|
|
2782
|
+
} else {
|
|
2783
|
+
mapContext.getMap(props.mapId).setLayoutProperty(layerIdsRef.current[key], "visibility", "none");
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2756
2786
|
}
|
|
2757
2787
|
}, [props.visible]);
|
|
2758
2788
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
|
|
@@ -2774,6 +2804,11 @@ MlVectorTileLayer.propTypes = {
|
|
|
2774
2804
|
*/
|
|
2775
2805
|
layers: PropTypes.object,
|
|
2776
2806
|
|
|
2807
|
+
/**
|
|
2808
|
+
* Boolean value to control the visibility of this layer
|
|
2809
|
+
*/
|
|
2810
|
+
visible: PropTypes.bool,
|
|
2811
|
+
|
|
2777
2812
|
/**
|
|
2778
2813
|
* String of the URL of a wms layer
|
|
2779
2814
|
*/
|
|
@@ -2821,29 +2856,16 @@ var defaultProps = {
|
|
|
2821
2856
|
*/
|
|
2822
2857
|
|
|
2823
2858
|
var MlWmsLayer = function MlWmsLayer(props) {
|
|
2824
|
-
var
|
|
2825
|
-
|
|
2826
|
-
|
|
2859
|
+
var mapHook = useMap({
|
|
2860
|
+
mapId: props.mapId,
|
|
2861
|
+
waitForLayer: props.insertBeforeLayer
|
|
2862
|
+
});
|
|
2827
2863
|
var initializedRef = useRef(false);
|
|
2828
|
-
var layerId = useRef(props.layerId || componentId
|
|
2829
|
-
useEffect(function () {
|
|
2830
|
-
var _componentId = componentId.current;
|
|
2831
|
-
return function () {
|
|
2832
|
-
// This is the cleanup function, it is called when this react component is removed from react-dom
|
|
2833
|
-
if (mapRef.current) {
|
|
2834
|
-
mapRef.current.cleanup(_componentId);
|
|
2835
|
-
mapRef.current = null;
|
|
2836
|
-
}
|
|
2837
|
-
|
|
2838
|
-
initializedRef.current = false;
|
|
2839
|
-
};
|
|
2840
|
-
}, []);
|
|
2864
|
+
var layerId = useRef(props.layerId || "MlWmsLayer-" + mapHook.componentId);
|
|
2841
2865
|
useEffect(function () {
|
|
2842
2866
|
var _propsUrlParams2;
|
|
2843
2867
|
|
|
2844
|
-
if (!
|
|
2845
|
-
mapRef.current = mapContext.getMap(props.mapId);
|
|
2846
|
-
if (!mapRef.current) return;
|
|
2868
|
+
if (!mapHook.map || initializedRef.current) return;
|
|
2847
2869
|
initializedRef.current = true;
|
|
2848
2870
|
|
|
2849
2871
|
var _propsUrlParams;
|
|
@@ -2862,31 +2884,31 @@ var MlWmsLayer = function MlWmsLayer(props) {
|
|
|
2862
2884
|
|
|
2863
2885
|
var urlParams = new URLSearchParams(urlParamsObj);
|
|
2864
2886
|
var urlParamsStr = decodeURIComponent(urlParams.toString()) + "".replace(/%2F/g, "/").replace(/%3A/g, ":");
|
|
2865
|
-
|
|
2887
|
+
mapHook.map.addSource(layerId.current, _objectSpread2({
|
|
2866
2888
|
type: "raster",
|
|
2867
2889
|
tiles: [_wmsUrl + "?" + urlParamsStr],
|
|
2868
2890
|
tileSize: urlParamsObj.width,
|
|
2869
2891
|
attribution: props.attribution
|
|
2870
|
-
}, props.sourceOptions), componentId
|
|
2871
|
-
|
|
2892
|
+
}, props.sourceOptions), mapHook.componentId);
|
|
2893
|
+
mapHook.map.addLayer(_objectSpread2({
|
|
2872
2894
|
id: layerId.current,
|
|
2873
2895
|
type: "raster",
|
|
2874
|
-
source:
|
|
2875
|
-
}, props.layerOptions), props.insertBeforeLayer, componentId
|
|
2896
|
+
source: layerId.current
|
|
2897
|
+
}, props.layerOptions), props.insertBeforeLayer, mapHook.componentId);
|
|
2876
2898
|
|
|
2877
2899
|
if (!props.visible) {
|
|
2878
|
-
|
|
2900
|
+
mapHook.map.setLayoutProperty(layerId.current, "visibility", "none");
|
|
2879
2901
|
}
|
|
2880
|
-
}, [
|
|
2902
|
+
}, [mapHook.map, props]);
|
|
2881
2903
|
useEffect(function () {
|
|
2882
|
-
if (!
|
|
2904
|
+
if (!mapHook.map || !initializedRef.current) return; // toggle layer visibility by changing the layout object's visibility property
|
|
2883
2905
|
|
|
2884
2906
|
if (props.visible) {
|
|
2885
|
-
|
|
2907
|
+
mapHook.map.setLayoutProperty(layerId.current, "visibility", "visible");
|
|
2886
2908
|
} else {
|
|
2887
|
-
|
|
2909
|
+
mapHook.map.setLayoutProperty(layerId.current, "visibility", "none");
|
|
2888
2910
|
}
|
|
2889
|
-
}, [props.visible]);
|
|
2911
|
+
}, [props.visible, mapHook.map]);
|
|
2890
2912
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
|
|
2891
2913
|
};
|
|
2892
2914
|
|