bindTooltip zu Marker hinzugefügt über Hover Effekt
This commit is contained in:
@@ -68,11 +68,11 @@ const MapComponent = ({ locations, onLocationUpdate }) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (map && GisStationsStaticDistrict.length > 0) {
|
if (map && GisStationsStaticDistrict.length > 0) {
|
||||||
// Zuerst alte Marker entfernen
|
// Zuerst alte Marker entfernen
|
||||||
map.eachLayer((layer) => {
|
/* map.eachLayer((layer) => {
|
||||||
if (layer instanceof L.Marker) {
|
if (layer instanceof L.Marker) {
|
||||||
map.removeLayer(layer);
|
map.removeLayer(layer);
|
||||||
}
|
}
|
||||||
});
|
}); */
|
||||||
|
|
||||||
// Neue Marker für jede Station hinzufügen
|
// Neue Marker für jede Station hinzufügen
|
||||||
GisStationsStaticDistrict.forEach((station) => {
|
GisStationsStaticDistrict.forEach((station) => {
|
||||||
@@ -91,6 +91,10 @@ const MapComponent = ({ locations, onLocationUpdate }) => {
|
|||||||
marker
|
marker
|
||||||
.bindPopup(`<b>${station.LD_Name}</b><br>${station.Device}`)
|
.bindPopup(`<b>${station.LD_Name}</b><br>${station.Device}`)
|
||||||
.openPopup();
|
.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
|
}, [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(
|
marker.bindPopup(
|
||||||
`<b>${location.description || "Unbekannt"}</b><br>Type: ${location.idPoiTyp || "N/A"}<br>Lat: ${latitude.toFixed(5)}, Lng: ${longitude.toFixed(5)}`
|
`<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) {
|
marker.on("dragend", function (e) {
|
||||||
const newLat = e.target.getLatLng().lat;
|
const newLat = e.target.getLatLng().lat;
|
||||||
|
|||||||
Reference in New Issue
Block a user