feat(map): OMS (OverlappingMarkerSpiderfier) vollständig integriert
- Marker werden nun korrekt bei OMS registriert - Klick auf Plus-Icon spiderfied überlappende Marker - useDynamicDeviceLayers um oms erweitert - checkOverlappingMarkers optimiert für dynamische Marker-Gruppen - Fehlerbehandlung für ungültige Marker-Typen ergänzt
This commit is contained in:
@@ -149,6 +149,9 @@ export const createAndSetDevices = async (systemId, setMarkersFunction, GisSyste
|
||||
if (map.contextmenu && contextMenuItemIds.size > 0) {
|
||||
contextMenuItemIds.forEach((id) => map.contextmenu.removeItem(id));
|
||||
contextMenuItemIds.clear();
|
||||
if (window.oms && typeof window.oms.addMarker === "function") {
|
||||
window.oms.addMarker(marker);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ export const restoreMapSettings = (map) => {
|
||||
// Globales Array, um Plus-Icons zu speichern
|
||||
let plusMarkers = [];
|
||||
|
||||
export const checkOverlappingMarkers = (map, markers, plusIcon) => {
|
||||
export const checkOverlappingMarkers = (map, markers, plusIcon, oms) => {
|
||||
if (!Array.isArray(markers)) {
|
||||
console.warn("⚠️ checkOverlappingMarkers erwartet ein Array, aber erhielt:", markers);
|
||||
return;
|
||||
@@ -40,31 +40,24 @@ export const checkOverlappingMarkers = (map, markers, plusIcon) => {
|
||||
}
|
||||
});
|
||||
|
||||
// alte PlusIcons entfernen
|
||||
plusMarkers.forEach((plusMarker) => map.removeLayer(plusMarker));
|
||||
plusMarkers = [];
|
||||
|
||||
// neue PlusIcons hinzufügen
|
||||
for (const coords in overlappingGroups) {
|
||||
if (overlappingGroups[coords].length > 1) {
|
||||
const latLng = L.latLng(coords.match(/[-.\d]+/g).map(Number));
|
||||
const plusMarker = L.marker(latLng, { icon: plusIcon }).addTo(map);
|
||||
plusMarkers.push(plusMarker);
|
||||
|
||||
plusMarker.on("click", (e) => {
|
||||
const clickedLatLng = e.latlng;
|
||||
const nearbyMarkers = markers.filter((marker) => map.distance(marker.getLatLng(), clickedLatLng) < 50);
|
||||
if (nearbyMarkers.length > 0) {
|
||||
nearbyMarkers[0].fire("click");
|
||||
plusMarker.on("click", () => {
|
||||
const nearbyMarkers = overlappingGroups[coords];
|
||||
|
||||
if (oms && nearbyMarkers.length > 0) {
|
||||
oms.spiderfy(nearbyMarkers); // ✅ Zeige Marker als Spider
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(overlappingGroups).length === 0) {
|
||||
plusMarkers.forEach((plusMarker) => map.removeLayer(plusMarker));
|
||||
plusMarkers = [];
|
||||
}
|
||||
};
|
||||
|
||||
export const handlePlusIconClick = (map, markers, oms, clickedLatLng) => {
|
||||
|
||||
Reference in New Issue
Block a user