GMA und TALAS Meldestation aktualisiert sich
This commit is contained in:
@@ -446,30 +446,42 @@ await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStat
|
||||
}, [map, zoomTrigger]);
|
||||
|
||||
useEffect(() => {
|
||||
if (map) {
|
||||
const allMarkers = [
|
||||
...talasMarkers,
|
||||
...eciMarkers,
|
||||
...gsmModemMarkers,
|
||||
...ciscoRouterMarkers,
|
||||
...wagoMarkers,
|
||||
...siemensMarkers,
|
||||
...otdrMarkers,
|
||||
...wdmMarkers,
|
||||
...gmaMarkers,
|
||||
...messstellenMarkers,
|
||||
...talasiclMarkers,
|
||||
...dauzMarkers,
|
||||
...smsfunkmodemMarkers,
|
||||
...sonstigeMarkers,
|
||||
...ulafMarkers,
|
||||
//...lteModemMarkers,
|
||||
];
|
||||
if (!map) return;
|
||||
|
||||
checkOverlappingMarkers(map, allMarkers, plusRoundIcon);
|
||||
// Entferne alle vorhandenen Marker
|
||||
if (poiLayerRef.current) {
|
||||
poiLayerRef.current.clearLayers();
|
||||
} else {
|
||||
poiLayerRef.current = new L.LayerGroup().addTo(map);
|
||||
}
|
||||
}, [map, talasMarkers, eciMarkers, ciscoRouterMarkers, wagoMarkers, siemensMarkers, otdrMarkers, wdmMarkers, gmaMarkers, messstellenMarkers, talasiclMarkers, dauzMarkers, smsfunkmodemMarkers, sonstigeMarkers, ulafMarkers]);
|
||||
//--------------------------------------------
|
||||
// Füge Marker zu OMS hinzu
|
||||
const allMarkers = [
|
||||
...talasMarkers,
|
||||
...eciMarkers,
|
||||
...gsmModemMarkers,
|
||||
...ciscoRouterMarkers,
|
||||
...wagoMarkers,
|
||||
...siemensMarkers,
|
||||
...otdrMarkers,
|
||||
...wdmMarkers,
|
||||
...gmaMarkers,
|
||||
...messstellenMarkers,
|
||||
...talasiclMarkers,
|
||||
...dauzMarkers,
|
||||
...smsfunkmodemMarkers,
|
||||
...sonstigeMarkers,
|
||||
...ulafMarkers,
|
||||
];
|
||||
|
||||
allMarkers.forEach((marker) => {
|
||||
if (!poiLayerRef.current.hasLayer(marker)) {
|
||||
poiLayerRef.current.addLayer(marker); // Füge Marker zur LayerGroup hinzu
|
||||
}
|
||||
oms.addMarker(marker); // Füge Marker zu OMS hinzu
|
||||
});
|
||||
}, [map, talasMarkers, eciMarkers, ciscoRouterMarkers, wagoMarkers, siemensMarkers, otdrMarkers, wdmMarkers, gmaMarkers, messstellenMarkers, talasiclMarkers, dauzMarkers, smsfunkmodemMarkers, sonstigeMarkers, ulafMarkers]);
|
||||
//--------------------------------------------
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
@@ -675,7 +687,7 @@ await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStat
|
||||
initializeContextMenu();
|
||||
}, [map]);
|
||||
//--------------------------------------------
|
||||
|
||||
/*
|
||||
useEffect(() => {
|
||||
if (!map) return; // Stelle sicher, dass die Karte initialisiert ist
|
||||
|
||||
@@ -710,7 +722,7 @@ await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStat
|
||||
// Cleanup-Funktion, um das Intervall zu entfernen, wenn die Komponente entladen wird
|
||||
return () => clearInterval(intervalId);
|
||||
}, [map, gmaMarkers, layers.MAP_LAYERS.GMA, oms, mapGisStationsMeasurementsUrl, mapGisStationsStatusDistrictUrl]);
|
||||
|
||||
*/
|
||||
//---------------------------------
|
||||
|
||||
const markerLayerRef = useRef(null);
|
||||
@@ -753,9 +765,56 @@ await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStat
|
||||
};
|
||||
}, [gisSystemStaticLoaded, map, GisSystemStatic, priorityConfig]);
|
||||
|
||||
//---------------------------------------
|
||||
const talasLayerRef = useRef(null); // LayerGroup für TALAS
|
||||
|
||||
useEffect(() => {
|
||||
if (!gisSystemStaticLoaded || !map) return; // Sicherstellen, dass alle Abhängigkeiten geladen sind
|
||||
|
||||
// Initialisiere die LayerGroup für TALAS, falls noch nicht vorhanden
|
||||
if (!talasLayerRef.current) {
|
||||
talasLayerRef.current = new L.LayerGroup().addTo(map);
|
||||
}
|
||||
|
||||
const updateTalasMarkers = () => {
|
||||
// Alte Marker aus der LayerGroup entfernen
|
||||
talasLayerRef.current.eachLayer((layer) => {
|
||||
talasLayerRef.current.removeLayer(layer);
|
||||
});
|
||||
|
||||
// Neue Marker hinzufügen
|
||||
createAndSetDevices(
|
||||
1,
|
||||
(newMarkers) => {
|
||||
setTalasMarkers(newMarkers); // Update State
|
||||
newMarkers.forEach((marker) => talasLayerRef.current.addLayer(marker)); // Füge Marker zur LayerGroup hinzu
|
||||
},
|
||||
GisSystemStatic,
|
||||
priorityConfig
|
||||
);
|
||||
};
|
||||
|
||||
// Initiales Update
|
||||
updateTalasMarkers();
|
||||
|
||||
// Setze ein Intervall, um die TALAS-Marker alle 10 Sekunden zu aktualisieren
|
||||
const intervalId = setInterval(() => {
|
||||
updateTalasMarkers();
|
||||
}, 10000); // 10 Sekunden
|
||||
|
||||
// Aufräumen bei Komponentenentladung
|
||||
return () => {
|
||||
clearInterval(intervalId);
|
||||
if (talasLayerRef.current) {
|
||||
talasLayerRef.current.clearLayers();
|
||||
}
|
||||
};
|
||||
}, [gisSystemStaticLoaded, map, GisSystemStatic, priorityConfig]);
|
||||
|
||||
//----------------------------------
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
//-----------------
|
||||
return (
|
||||
<>
|
||||
<ToastContainer />
|
||||
|
||||
Reference in New Issue
Block a user