Marker aktualisieren alle 60 Sekunden, später in Redux lösen
This commit is contained in:
@@ -253,9 +253,18 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
mapLayersVisibility.SMSFunkmodem // Sichtbarkeitsstatus aus dem State
|
||||
); */
|
||||
|
||||
const useMock = process.env.NEXT_PUBLIC_USE_MOCK_API === "true";
|
||||
useEffect(() => {
|
||||
const fetchWebServiceMap = async () => {
|
||||
try {
|
||||
let stationsStaticUrl = useMock ? "/mockData/gisStationsStaticDistrictMock.json" : mapGisStationsStaticDistrictUrl;
|
||||
|
||||
let stationsStatusUrl = useMock ? "/mockData/gisStationsStatusDistrictMock.json" : mapGisStationsStatusDistrictUrl;
|
||||
|
||||
let stationsMeasurementsUrl = useMock ? "/mockData/gisStationsMeasurementsMock.json" : mapGisStationsMeasurementsUrl;
|
||||
|
||||
let systemStaticUrl = useMock ? "/mockData/gisSystemStaticMock.json" : mapGisSystemStaticUrl;
|
||||
|
||||
// Zähler für externe API-Aufrufe in localStorage speichern
|
||||
let requestCount = localStorage.getItem("fetchWebServiceMap") || 0;
|
||||
requestCount = parseInt(requestCount, 10);
|
||||
@@ -823,9 +832,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
updateAllMarkers();
|
||||
|
||||
// Setze ein Intervall für regelmäßige Updates
|
||||
/* const intervalId = setInterval(() => {
|
||||
const intervalId = setInterval(() => {
|
||||
updateAllMarkers();
|
||||
}, 60000); // 20 Sekunden
|
||||
}, 60000); // 60 Sekunden dann werden die Marker aktualisiert, später mit Redux Store lösen, damit nicht flackert
|
||||
|
||||
// Aufräumen bei Komponentenentladung
|
||||
return () => {
|
||||
@@ -837,7 +846,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
ref.current.clearLayers();
|
||||
}
|
||||
});
|
||||
}; */
|
||||
};
|
||||
}, [gisSystemStaticLoaded, map, GisSystemStatic, priorityConfig]);
|
||||
|
||||
//---------------------------------------
|
||||
@@ -914,6 +923,13 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
//--------------------------------------------
|
||||
const fetchGisStationsStaticDistrict = async (idMap, idUser, dispatch) => {
|
||||
try {
|
||||
let stationsStaticUrl = useMock ? "/mockData/gisStationsStaticDistrictMock.json" : mapGisStationsStaticDistrictUrl;
|
||||
|
||||
let stationsStatusUrl = useMock ? "/mockData/gisStationsStatusDistrictMock.json" : mapGisStationsStatusDistrictUrl;
|
||||
|
||||
let stationsMeasurementsUrl = useMock ? "/mockData/gisStationsMeasurementsMock.json" : mapGisStationsMeasurementsUrl;
|
||||
|
||||
let systemStaticUrl = useMock ? "/mockData/gisSystemStaticMock.json" : mapGisSystemStaticUrl;
|
||||
// API-Endpunkt mit Query-Parametern aufrufen
|
||||
const response = await fetch(`/api/gisStationsStaticDistrict?idMap=${idMap}&idUser=${idUser}`);
|
||||
|
||||
@@ -977,6 +993,8 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
}, [map, menuItemAdded]);
|
||||
//--------------------------------------------
|
||||
|
||||
//----------------------------------------------
|
||||
|
||||
return (
|
||||
<>
|
||||
<ToastContainer />
|
||||
|
||||
Reference in New Issue
Block a user