fix: Kabelstrecken werden ausgeblendet

This commit is contained in:
ISA
2025-08-22 09:46:31 +02:00
parent bf7b62d110
commit f2a322a91b
8 changed files with 82 additions and 36 deletions

View File

@@ -367,6 +367,14 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
//Tooltip an mouse position anzeigen für die Linien
useEffect(() => {
if (!map) return;
console.log(
"[MapComponent/useEffect] polylineVisible:",
polylineVisible,
"isTalasAllowed:",
isTalasAllowed,
"poiLayerVisible:",
poiLayerVisible
);
// Wenn TALAS nicht erlaubt ist, Polyline-Checkbox und Anzeige deaktivieren
if (!isTalasAllowed) {
@@ -381,6 +389,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
marker.remove();
});
cleanupPolylinesForMemory(polylines, map);
console.log("[MapComponent/useEffect] Nach cleanupPolylinesForMemory, polylines:", polylines);
// Setze neue Marker und Polylinien mit den aktuellen Daten (asynchron!)
const updatePolylines = async () => {
@@ -442,9 +451,19 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
cleanupMarkers(markers, oms);
setMarkers(newMarkers);
setPolylines(newPolylines);
console.log("[MapComponent/useEffect] setPolylines (sichtbar):", newPolylines);
} else {
// Entferne wirklich alle Polylinien-Layer von der Karte
if (map) {
map.eachLayer(layer => {
if (layer instanceof L.Polyline) {
map.removeLayer(layer);
}
});
}
cleanupPolylinesForMemory(polylines, map);
setPolylines([]);
console.log("[MapComponent/useEffect] setPolylines ([]), alle Polylinien entfernt");
}
};
updatePolylines();