From e8412f3dc330101c15d459195ccc68ef15162173 Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 17 Apr 2024 07:49:49 +0200 Subject: [PATCH] =?UTF-8?q?Station=20Status=20Meldungen=20in=20Popup=20hin?= =?UTF-8?q?zuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/MapComponent.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/components/MapComponent.js b/components/MapComponent.js index 25c36b41f..1fa4321c7 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -686,15 +686,24 @@ const MapComponent = ({ locations, onLocationUpdate }) => { // Marker hinzufügen für GisStationsStaticDistrict useEffect(() => { if (map && GisStationsStaticDistrict.length > 0) { - // Zuerst alte Marker entfernen map.eachLayer((layer) => { if (layer instanceof L.Marker) { map.removeLayer(layer); } }); - // Neue Marker für jede Station hinzufügen GisStationsStaticDistrict.forEach((station) => { + // Alle Status-Objekte mit gleicher IdLD finden + const matchingStatuses = GisStationsStatusDistrict.filter( + (status) => status.IdLD === station.IdLD + ); + let additionalInfo = ""; + + // Alle gefundenen Me-Werte zu einem String hinzufügen + matchingStatuses.forEach((status) => { + additionalInfo += `
${status.Me} (${status.Na}) `; + }); + const marker = L.marker([station.X, station.Y], { icon: L.icon({ iconUrl: getIconPath(station.Icon), @@ -705,27 +714,19 @@ const MapComponent = ({ locations, onLocationUpdate }) => { }), }).addTo(map); - // Popup beim Überfahren mit der Maus öffnen marker.on("mouseover", function (e) { this.openPopup(); }); - // Popup schließen, wenn die Maus den Marker verlässt marker.on("mouseout", function (e) { this.closePopup(); }); - // Ein Popup mit Informationen zur Station hinzufügen + marker .bindPopup( - `${station.LD_Name}
${station.Device}
${station.Area_Short} ${station.Area_Name}
${station.Location_Short} ${station.Location_Name}

` + `${station.LD_Name}
${station.Device}
${station.Area_Short} ${station.Area_Name}
${station.Location_Short} ${station.Location_Name}${additionalInfo}

` ) .openPopup(); - - // Diese Zeile entfernt das automatische Tooltip - // marker.bindTooltip(station.LD_Name, { - // permanent: false, - // direction: "top", - // }); }); } }, [map, GisStationsStaticDistrict, GisStationsStatusDistrict]); // Include GisStationsStatusDistrict in dependencies