GMA Marker aktualisiert sich
This commit is contained in:
@@ -392,7 +392,6 @@ await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStat
|
||||
//console.log("priorityConfig in MapComponent2: ", priorityConfig);
|
||||
useEffect(() => {
|
||||
if (gisSystemStaticLoaded && map) {
|
||||
|
||||
createAndSetDevices(11, setGmaMarkers, GisSystemStatic, priorityConfig); // GMA-System
|
||||
createAndSetDevices(1, setTalasMarkers, GisSystemStatic, priorityConfig); // TALAS-System
|
||||
createAndSetDevices(2, setEciMarkers, GisSystemStatic, priorityConfig); // ECI-System
|
||||
@@ -679,7 +678,7 @@ await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStat
|
||||
|
||||
useEffect(() => {
|
||||
if (!map) return; // Stelle sicher, dass die Karte initialisiert ist
|
||||
|
||||
|
||||
const updateGmaData = async () => {
|
||||
try {
|
||||
const fetchOptions = {
|
||||
@@ -688,51 +687,47 @@ await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStat
|
||||
Connection: "close",
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
// Aktualisiere die Messdaten
|
||||
await fetchGisStationsMeasurements(mapGisStationsMeasurementsUrl, setGisStationsMeasurements, fetchOptions);
|
||||
await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStationsStatusDistrict, fetchOptions);
|
||||
|
||||
|
||||
|
||||
// Aktualisiere die Marker-Layer
|
||||
useGmaMarkersLayer(map, gmaMarkers, GisStationsMeasurements, layers.MAP_LAYERS.GMA, oms);
|
||||
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Aktualisieren der GMA-Daten:", error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Initialer Datenabruf
|
||||
updateGmaData();
|
||||
|
||||
|
||||
// Setze ein Intervall, um die Daten alle 5 Sekunden zu aktualisieren
|
||||
const intervalId = setInterval(() => {
|
||||
updateGmaData();
|
||||
}, 5000);
|
||||
|
||||
|
||||
// Cleanup-Funktion, um das Intervall zu entfernen, wenn die Komponente entladen wird
|
||||
return () => clearInterval(intervalId);
|
||||
}, [map, gmaMarkers, layers.MAP_LAYERS.GMA, oms, mapGisStationsMeasurementsUrl,mapGisStationsStatusDistrictUrl]);
|
||||
}, [map, gmaMarkers, layers.MAP_LAYERS.GMA, oms, mapGisStationsMeasurementsUrl, mapGisStationsStatusDistrictUrl]);
|
||||
|
||||
|
||||
//---------------------------------
|
||||
|
||||
|
||||
const markerLayerRef = useRef(null);
|
||||
useEffect(() => {
|
||||
if (!gisSystemStaticLoaded || !map) return; // Sicherstellen, dass alle Abhängigkeiten geladen sind
|
||||
|
||||
|
||||
// Initialisiere die LayerGroup, falls noch nicht vorhanden
|
||||
if (!markerLayerRef.current) {
|
||||
markerLayerRef.current = new L.LayerGroup().addTo(map);
|
||||
}
|
||||
|
||||
|
||||
const updateMarkers = () => {
|
||||
// Alte Marker entfernen
|
||||
markerLayerRef.current.clearLayers();
|
||||
|
||||
|
||||
// Neue Marker für jedes System erstellen
|
||||
/* createAndSetDevices(11, (markers) => {
|
||||
/* createAndSetDevices(11, (markers) => {
|
||||
setGmaMarkers(markers);
|
||||
markers.forEach((marker) => marker.addTo(markerLayerRef.current)); // Marker zur LayerGroup hinzufügen
|
||||
}, GisSystemStatic, priorityConfig);
|
||||
@@ -740,15 +735,15 @@ await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStat
|
||||
createAndSetDevices(11, setGmaMarkers, GisSystemStatic, priorityConfig);
|
||||
// Füge hier weitere `createAndSetDevices`-Aufrufe für andere Systeme ein
|
||||
};
|
||||
|
||||
|
||||
// Initiales Update der Marker
|
||||
updateMarkers();
|
||||
|
||||
|
||||
// Setze ein Intervall, um die Marker alle 10 Sekunden zu aktualisieren
|
||||
const intervalId = setInterval(() => {
|
||||
updateMarkers();
|
||||
}, 10000); // 10 Sekunden
|
||||
|
||||
|
||||
// Aufräumen bei Komponentenentladung
|
||||
return () => {
|
||||
clearInterval(intervalId);
|
||||
@@ -758,10 +753,9 @@ await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStat
|
||||
};
|
||||
}, [gisSystemStaticLoaded, map, GisSystemStatic, priorityConfig]);
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
//-----------------
|
||||
//-----------------
|
||||
return (
|
||||
<>
|
||||
<ToastContainer />
|
||||
|
||||
Reference in New Issue
Block a user