From ddd8ae8a3cade71e79984bc0cb203e110740db8b Mon Sep 17 00:00:00 2001 From: ISA Date: Tue, 16 Apr 2024 09:26:49 +0200 Subject: [PATCH] =?UTF-8?q?bindTooltip=20zu=20Marker=20hinzugef=C3=BCgt=20?= =?UTF-8?q?=C3=BCber=20Hover=20Effekt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/MapComponent.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/components/MapComponent.js b/components/MapComponent.js index 1679180f9..c427186c3 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -68,11 +68,11 @@ const MapComponent = ({ locations, onLocationUpdate }) => { useEffect(() => { if (map && GisStationsStaticDistrict.length > 0) { // Zuerst alte Marker entfernen - map.eachLayer((layer) => { + /* map.eachLayer((layer) => { if (layer instanceof L.Marker) { map.removeLayer(layer); } - }); + }); */ // Neue Marker für jede Station hinzufügen GisStationsStaticDistrict.forEach((station) => { @@ -91,6 +91,10 @@ const MapComponent = ({ locations, onLocationUpdate }) => { marker .bindPopup(`${station.LD_Name}
${station.Device}`) .openPopup(); + marker.bindTooltip(station.LD_Name, { + permanent: false, + direction: "top", + }); }); } }, [map, GisStationsStaticDistrict]); // Abhängigkeiten hinzufügen, um sicherzustellen, dass Effekt bei Änderungen neu ausgeführt wird @@ -274,6 +278,10 @@ const MapComponent = ({ locations, onLocationUpdate }) => { marker.bindPopup( `${location.description || "Unbekannt"}
Type: ${location.idPoiTyp || "N/A"}
Lat: ${latitude.toFixed(5)}, Lng: ${longitude.toFixed(5)}` ); + marker.bindTooltip(location.description, { + permanent: false, + direction: "top", + }); marker.on("dragend", function (e) { const newLat = e.target.getLatLng().lat;