fix: Marker-Duplikate & Spiderfy repariert | version 1.1.230

This commit is contained in:
ISA
2025-06-04 08:23:55 +02:00
parent 66afc1cee7
commit 569790d35f
6 changed files with 273 additions and 174 deletions

View File

@@ -3,7 +3,7 @@ import { useEffect, useRef, useState } from "react";
import L from "leaflet";
import { createAndSetDevices } from "../utils/devices/createAndSetDevices";
import { checkOverlappingMarkers } from "../utils/mapUtils";
import plusRoundIcon from "../components/icons/devices/overlapping/PlusRoundIcon";
import plusRoundIcon from "@/components/icons/devices/overlapping/PlusRoundIcon";
/**
* Dynamisch GIS-System-Marker erstellen & Sichtbarkeit steuern.
@@ -31,14 +31,27 @@ const useDynamicDeviceLayers = (map, GisSystemStatic, mapLayersVisibility, prior
createAndSetDevices(
IdSystem,
newMarkers => {
setMarkerStates(prev => ({ ...prev, [key]: newMarkers }));
const oldMarkers = markerStates[key];
// ❌ NICHT direkt zur Karte hinzufügen
// Sichtbarkeit folgt im 2. useEffect
checkOverlappingMarkers(map, newMarkers, plusRoundIcon, oms);
// 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);
}
});
}
// Neue Marker setzen
setMarkerStates(prev => ({ ...prev, [key]: newMarkers }));
},
GisSystemStatic,
priorityConfig
priorityConfig,
undefined,
oms
);
});
}, [map, GisSystemStatic, priorityConfig]);