fix: Geräte-Marker werden nur noch über LayerGroups verwaltet, doppelte Marker auf Karte verhindert
Geräte-Marker werden vor dem Hinzufügen aus LayerGroups entfernt und nur dort hinzugefügt Keine direkte .addTo(map) mehr für Geräte-Marker Debug-Ausgabe für Marker-Anzahl pro LayerGroup Problem mit mehrfachen Markern auf der Karte behoben
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user