diff --git a/.env.development b/.env.development index 46dd9d567..65971fa6e 100644 --- a/.env.development +++ b/.env.development @@ -24,4 +24,4 @@ NEXT_PUBLIC_USE_MOCKS=true # z.B. http://10.10.0.13/xyz/index.aspx -> basePath in config.json auf /xyz setzen # basePath wird jetzt in public/config.json gepflegt # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.1.319 +NEXT_PUBLIC_APP_VERSION=1.1.320 diff --git a/.env.production b/.env.production index 642018afa..4f0d3c7d7 100644 --- a/.env.production +++ b/.env.production @@ -25,4 +25,4 @@ NEXT_PUBLIC_USE_MOCKS=false # basePath wird jetzt in public/config.json gepflegt # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.1.319 +NEXT_PUBLIC_APP_VERSION=1.1.320 diff --git a/components/devices/hooks/useDynamicDeviceLayers.js b/components/devices/hooks/useDynamicDeviceLayers.js index 32f452ee3..b644dc634 100644 --- a/components/devices/hooks/useDynamicDeviceLayers.js +++ b/components/devices/hooks/useDynamicDeviceLayers.js @@ -30,30 +30,44 @@ const useDynamicDeviceLayers = (map, GisSystemStatic, mapLayersVisibility, prior if (!map || GisSystemStatic.length === 0) return; GisSystemStatic.forEach(({ Name, IdSystem }) => { - const key = `system-${IdSystem}`; // Einheitlicher Key - - if (!layerRefs.current[key]) { - layerRefs.current[key] = new L.LayerGroup().addTo(map); + const key = `system-${IdSystem}`; + // LayerGroup-Instanzierung und Bereinigung + if (layerRefs.current[key]) { + // Entferne alte LayerGroup von der Map, falls vorhanden + if (map.hasLayer(layerRefs.current[key])) { + map.removeLayer(layerRefs.current[key]); + } + layerRefs.current[key].clearLayers(); } + // Neue oder wiederverwendete LayerGroup anlegen und zur Map hinzufügen + if (!layerRefs.current[key]) { + layerRefs.current[key] = new L.LayerGroup(); + } + layerRefs.current[key].addTo(map); + // Debug-Ausgabe + /* console.log( + `[DeviceLayers] LayerGroup für ${key} auf Map hinzugefügt. Aktuelle LayerGroups:`, + Object.keys(layerRefs.current) + ); */ createAndSetDevices( IdSystem, newMarkers => { - const oldMarkers = markerStates[key]; - - // Entferne alte Marker aus Karte und OMS - if (oldMarkers && Array.isArray(oldMarkers)) { - oldMarkers.forEach(marker => { - if (map.hasLayer(marker)) { - map.removeLayer(marker); - } - if (oms) { - oms.removeMarker(marker); - } + // Füge neue Marker der LayerGroup hinzu (nur Geräte-Marker) + if (layerRefs.current[key]) { + // Entferne alle Marker aus der LayerGroup, bevor neue hinzugefügt werden + layerRefs.current[key].clearLayers(); + newMarkers.forEach(marker => { + // Nur LayerGroup verwenden, nicht direkt auf map + marker.addTo(layerRefs.current[key]); }); + // Debug: Anzahl Marker in LayerGroup + console.log( + `[DeviceLayers] ${ + layerRefs.current[key].getLayers().length + } Marker in LayerGroup für ${key}` + ); } - - // Neue Marker setzen setMarkerStates(prev => ({ ...prev, [key]: newMarkers })); }, GisSystemStatic, diff --git a/package-lock.json b/package-lock.json index 8c6b2eba6..5f10c77db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "nodemap", - "version": "1.1.319", + "version": "1.1.320", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "nodemap", - "version": "1.1.319", + "version": "1.1.320", "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", diff --git a/package.json b/package.json index 9cad488c8..3158041ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodemap", - "version": "1.1.319", + "version": "1.1.320", "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0",