fix: leere Array
This commit is contained in:
@@ -375,7 +375,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
}
|
||||
|
||||
// vorherige Marker & Polylinien vollständig bereinigen
|
||||
markers.forEach(marker => {
|
||||
(Array.isArray(markers) ? markers : []).forEach(marker => {
|
||||
marker.remove();
|
||||
});
|
||||
cleanupPolylinesForMemory(polylines, map);
|
||||
@@ -394,7 +394,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
polylineVisible // kommt aus Redux
|
||||
);
|
||||
|
||||
newPolylines.forEach((polyline, index) => {
|
||||
(Array.isArray(newPolylines) ? newPolylines : []).forEach((polyline, index) => {
|
||||
const tooltipContent =
|
||||
tooltipContents[`${linePositions[index].idLD}-${linePositions[index].idModul}`] ||
|
||||
"Die Linie ist noch nicht in Webservice vorhanden oder bekommt keine Daten";
|
||||
@@ -616,14 +616,14 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
// Entferne alle Marker aus der Karte
|
||||
if (!map) return; // Sicherstellen, dass map existiert
|
||||
|
||||
areaMarkers.forEach(marker => {
|
||||
(Array.isArray(areaMarkers) ? areaMarkers : []).forEach(marker => {
|
||||
if (map.hasLayer(marker)) {
|
||||
map.removeLayer(marker);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Wenn editMode aktiviert ist, füge die Marker hinzu und aktiviere Dragging
|
||||
areaMarkers.forEach(marker => {
|
||||
(Array.isArray(areaMarkers) ? areaMarkers : []).forEach(marker => {
|
||||
if (!map.hasLayer(marker)) {
|
||||
marker.addTo(map); // Layer hinzufügen
|
||||
}
|
||||
@@ -836,7 +836,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
useEffect(() => {
|
||||
if (poiTypStatus === "succeeded" && Array.isArray(poiTypData)) {
|
||||
const map = new Map();
|
||||
poiTypData.forEach(item => map.set(item.idPoiTyp, item.name));
|
||||
(Array.isArray(poiTypData) ? poiTypData : []).forEach(item =>
|
||||
map.set(item.idPoiTyp, item.name)
|
||||
);
|
||||
setPoiTypMap(map);
|
||||
}
|
||||
}, [poiTypData, poiTypStatus]);
|
||||
@@ -928,7 +930,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
}, [GisSystemStatic]);
|
||||
useEffect(() => {
|
||||
if (Array.isArray(GisSystemStatic)) {
|
||||
GisSystemStatic.forEach(system => {
|
||||
(Array.isArray(GisSystemStatic) ? GisSystemStatic : []).forEach(system => {
|
||||
const key = `system-${system.IdSystem}`;
|
||||
if (!(key in mapLayersVisibility)) {
|
||||
dispatch(setLayerVisibility({ key, value: true })); // Sichtbarkeit aktivieren
|
||||
|
||||
Reference in New Issue
Block a user