diff --git a/components/MapComponent.js b/components/MapComponent.js index 2cd31ecb6..1a013a4e2 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -1211,6 +1211,8 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { }, []); //-------------------------------------------- useEffect(() => { + if (poiData.length === 0) return; + try { if (map && poiLayerRef.current && isPoiTypLoaded) { map.removeLayer(poiLayerRef.current); @@ -1306,6 +1308,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { isPoiTypLoaded, userRights, poiLayerVisible, + poiData, // Add poiData as a dependency ]); //---------------------------------------------