Mit Spider funktioniert etwas, es soll noch beim Klick wieder ausgeblendet werden

This commit is contained in:
ISA
2024-04-17 14:55:11 +02:00
parent 6f673829fd
commit b0a3d7dec9

View File

@@ -323,6 +323,10 @@ const MapComponent = ({ locations, onLocationUpdate }) => {
'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> 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