GMA und TALAS Meldestation aktualisiert sich

This commit is contained in:
ISA
2024-11-27 14:25:14 +01:00
parent 9c4c646d55
commit 0bca68153c
2 changed files with 84 additions and 25 deletions

View File

@@ -23,7 +23,7 @@ DB_PORT=3306
######################### #########################
#device nur Verlinkung wenn die gleiche DB ist #device nur Verlinkung wenn die gleiche DB ist
NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" NEXT_PUBLIC_BASE_URL="http://10.10.0.70/talas5/devices/"
NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" NEXT_PUBLIC_SERVER_URL="http://10.10.0.70"
NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70"
#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" #NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png"

View File

@@ -446,30 +446,42 @@ await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStat
}, [map, zoomTrigger]); }, [map, zoomTrigger]);
useEffect(() => { useEffect(() => {
if (map) { if (!map) return;
const allMarkers = [
...talasMarkers,
...eciMarkers,
...gsmModemMarkers,
...ciscoRouterMarkers,
...wagoMarkers,
...siemensMarkers,
...otdrMarkers,
...wdmMarkers,
...gmaMarkers,
...messstellenMarkers,
...talasiclMarkers,
...dauzMarkers,
...smsfunkmodemMarkers,
...sonstigeMarkers,
...ulafMarkers,
//...lteModemMarkers,
];
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(() => { useEffect(() => {
const fetchData = async () => { const fetchData = async () => {
try { try {
@@ -675,7 +687,7 @@ await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStat
initializeContextMenu(); initializeContextMenu();
}, [map]); }, [map]);
//-------------------------------------------- //--------------------------------------------
/*
useEffect(() => { useEffect(() => {
if (!map) return; // Stelle sicher, dass die Karte initialisiert ist 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 // Cleanup-Funktion, um das Intervall zu entfernen, wenn die Komponente entladen wird
return () => clearInterval(intervalId); 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); const markerLayerRef = useRef(null);
@@ -753,9 +765,56 @@ await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStat
}; };
}, [gisSystemStaticLoaded, map, GisSystemStatic, priorityConfig]); }, [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 ( return (
<> <>
<ToastContainer /> <ToastContainer />