bindTooltip zu Marker hinzugefügt über Hover Effekt
This commit is contained in:
@@ -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(`<b>${station.LD_Name}</b><br>${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(
|
||||
`<b>${location.description || "Unbekannt"}</b><br>Type: ${location.idPoiTyp || "N/A"}<br>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;
|
||||
|
||||
Reference in New Issue
Block a user