From b0a3d7dec958850f8a36a5a5209eb0eb9193d22d Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 17 Apr 2024 14:55:11 +0200 Subject: [PATCH] Mit Spider funktioniert etwas, es soll noch beim Klick wieder ausgeblendet werden --- components/MapComponent.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/components/MapComponent.js b/components/MapComponent.js index 1a8e2421d..e92fa5064 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -323,6 +323,10 @@ const MapComponent = ({ locations, onLocationUpdate }) => { '© OpenStreetMap contributors', }).addTo(initialMap); + const newOms = new OverlappingMarkerSpiderfier(initialMap, { + nearbyDistance: 50, + }); + setOms(newOms); setMap(initialMap); } }, [mapRef, map]); @@ -644,7 +648,7 @@ const MapComponent = ({ locations, onLocationUpdate }) => { //Informationen in Tooltips einfügen // Marker hinzufügen für GisStationsStaticDistrict useEffect(() => { - if (map && GisStationsStaticDistrict.length > 0) { + if (map && oms && GisStationsStaticDistrict.length > 0) { map.eachLayer((layer) => { if (layer instanceof L.Marker) { map.removeLayer(layer); @@ -686,9 +690,9 @@ const MapComponent = ({ locations, onLocationUpdate }) => { shadowSize: [41, 41], }), }); - //oms.addMarker(marker); // Marker zum OMS hinzufügen - marker.addTo(map); + marker.addTo(map); + oms.addMarker(marker); // Add marker to the OverlappingMarkerSpiderfier instance marker.on("mouseover", function (e) { this.openPopup(); }); @@ -704,7 +708,7 @@ const MapComponent = ({ locations, onLocationUpdate }) => { .openPopup(); }); } - }, [map, GisStationsStaticDistrict, GisStationsStatusDistrict]); // Include GisStationsStatusDistrict in dependencies + }, [map, GisStationsStaticDistrict, oms, GisStationsStatusDistrict]); // Include GisStationsStatusDistrict in dependencies //------------------------------------------ // Funktion, die den Pfad zum entsprechenden Icon basierend auf dem Status generiert