feat: Fix Redux-Datenstruktur für GisStationsStaticDistrict und Bereichs-Dropdown

- `GisStationsStaticDistrict` wird jetzt korrekt aus Redux gelesen und verwendet `Points` als Array.
- Fehler `find is not a function` behoben durch Zugriff auf `GisStationsStaticDistrict.Points`.
- Sicherstellung, dass `Points` existiert, bevor darauf zugegriffen wird.
- Konsole-Logs für Debugging hinzugefügt, um leere oder ungültige Daten zu erkennen.
- Bereichsauswahl im Dropdown funktioniert jetzt korrekt und fliegt zur gewählten Station auf der Karte.

 Tested: Dropdown zeigt jetzt die `Area_Name`-Werte und `map.flyTo()` funktioniert korrekt.
This commit is contained in:
Ismail Ali
2025-03-08 12:10:21 +01:00
parent 8399a957b5
commit 806347f0dd
12 changed files with 201 additions and 24 deletions

View File

@@ -647,16 +647,30 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
}
}, [map]);
//--------------------------------------------
// Bereich in DataSheet ->dropdownmenu
useEffect(() => {
console.log("🔍 GisStationsStaticDistrict Inhalt:", GisStationsStaticDistrict);
// Sicherstellen, dass `Points` existiert und ein Array ist
const points = GisStationsStaticDistrict?.Points;
if (!Array.isArray(points)) {
console.warn("⚠️ GisStationsStaticDistrict.Points ist nicht vorhanden oder kein Array.", points);
return;
}
if (selectedArea && map) {
const station = GisStationsStaticDistrict.find((s) => s.Area_Name === selectedArea);
const station = points.find((s) => s.Area_Name === selectedArea);
if (station) {
console.log("📌 Gefundene Station:", station);
map.flyTo([station.X, station.Y], 14);
} else {
console.warn("⚠️ Keine passende Station für die Area gefunden:", selectedArea);
}
}
}, [selectedArea, map, GisStationsStaticDistrict]);
//-------------------------------------
useEffect(() => {
if (zoomTrigger && map) {
map.flyTo([51.41321407879154, 7.739617925303934], 7);
@@ -945,7 +959,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
// Ergebnis im Dispatch speichern oder State aktualisieren
dispatch({ type: "SET_GIS_STATIONS", payload: data });
console.log("Daten erfolgreich geladen:", data);
//console.log("Daten erfolgreich geladen:", data);
return data; // Optional: Rückgabe der Daten
} catch (error) {
console.error("Fehler beim Laden der GIS-Daten:", error);