fix: Geräte-Marker für Systeme ohne Statusdaten anzeigen (z. B. GMA)
- `createAndSetDevices.js` angepasst, sodass Marker auch ohne `statusDistrictData` erzeugt werden. - Problem behoben, dass Marker wie GMA trotz vorhandener Koordinaten und Sichtbarkeit nicht gezeichnet wurden. - Sicherheitsprüfung für Statusdaten optional gemacht, um Systems ohne Messdaten darzustellen.
This commit is contained in:
@@ -70,7 +70,8 @@ const useDynamicDeviceLayers = (map, GisSystemStatic, mapLayersVisibility, prior
|
||||
const editMode = localStorage.getItem("editMode") === "true";
|
||||
|
||||
Object.entries(markerStates).forEach(([key, markers]) => {
|
||||
const isVisible = mapLayersVisibility[key];
|
||||
const isVisible = mapLayersVisibility[key] ?? true; // undefined = true
|
||||
|
||||
markers.forEach(marker => {
|
||||
const hasLayer = map.hasLayer(marker);
|
||||
if (editMode || !isVisible) {
|
||||
|
||||
0
components/hooks/useStationCache.js
Normal file
0
components/hooks/useStationCache.js
Normal file
@@ -797,30 +797,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
}
|
||||
}, [poiIconsData, poiIconsStatus]);
|
||||
//-----------------------------------------------------------------
|
||||
useEffect(() => {
|
||||
if (!map) return;
|
||||
|
||||
const editMode = localStorage.getItem("editMode") === "true";
|
||||
|
||||
Object.entries(markerStates).forEach(([systemName, markers]) => {
|
||||
const isVisible = mapLayersVisibility[systemName];
|
||||
markers.forEach(marker => {
|
||||
const hasLayer = map.hasLayer(marker);
|
||||
if (editMode || !isVisible) {
|
||||
if (hasLayer) map.removeLayer(marker);
|
||||
} else {
|
||||
if (!hasLayer) marker.addTo(map);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// optional für alle zusammen
|
||||
const allMarkers = Object.values(markerStates)
|
||||
.filter(entry => Array.isArray(entry))
|
||||
.flat();
|
||||
|
||||
checkOverlappingMarkers(map, allMarkers, plusRoundIcon);
|
||||
}, [map, markerStates, mapLayersVisibility]);
|
||||
|
||||
//----------------------------------------------
|
||||
useEffect(() => {
|
||||
@@ -896,6 +872,21 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
}, [GisStationsStaticDistrict]);
|
||||
const { Points = [] } = useSelector(selectGisStationsStaticDistrict);
|
||||
useEffect(() => {}, [triggerUpdate]);
|
||||
//--------------------------------------------------------------------------------
|
||||
useEffect(() => {
|
||||
console.log("📊 GisSystemStatic:", GisSystemStatic);
|
||||
}, [GisSystemStatic]);
|
||||
useEffect(() => {
|
||||
if (Array.isArray(GisSystemStatic)) {
|
||||
GisSystemStatic.forEach(system => {
|
||||
const key = `system-${system.IdSystem}`;
|
||||
if (!(key in mapLayersVisibility)) {
|
||||
dispatch(setLayerVisibility({ key, value: true })); // Sichtbarkeit aktivieren
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [GisSystemStatic, mapLayersVisibility, dispatch]);
|
||||
|
||||
//---------------------------------------------
|
||||
//--------------------------------------------
|
||||
return (
|
||||
|
||||
@@ -9,7 +9,11 @@ import {
|
||||
} from "@/redux/slices/database/polylines/polylineLayerVisibleSlice";
|
||||
import { selectGisSystemStatic } from "@/redux/slices/webservice/gisSystemStaticSlice";
|
||||
import { selectGisStationsStaticDistrict } from "@/redux/slices/webservice/gisStationsStaticDistrictSlice";
|
||||
import { selectMapLayersState, setLayerVisibility } from "@/redux/slices/mapLayersSlice";
|
||||
import {
|
||||
selectMapLayersState,
|
||||
setLayerVisibility,
|
||||
setInitialLayers,
|
||||
} from "@/redux/slices/mapLayersSlice";
|
||||
import { setVisible } from "@/redux/slices/database/pois/poiLayerVisibleSlice";
|
||||
import { incrementZoomTrigger } from "@/redux/slices/zoomTriggerSlice";
|
||||
|
||||
@@ -122,13 +126,16 @@ function MapLayersControlPanel() {
|
||||
const initialVisibility = {};
|
||||
GisSystemStatic.forEach(system => {
|
||||
const visibility = system.Allow === 1;
|
||||
initialVisibility[system.SystemName] = visibility;
|
||||
dispatch(setLayerVisibility({ layer: system.SystemName, visibility }));
|
||||
const key = `system-${system.IdSystem}`;
|
||||
initialVisibility[key] = visibility;
|
||||
dispatch(setLayerVisibility({ layer: key, visibility }));
|
||||
console.log(
|
||||
`🎯 Setting ${system.SystemName} visibility to ${visibility} (Allow=${system.Allow})`
|
||||
);
|
||||
});
|
||||
|
||||
localStorage.setItem("mapLayersVisibility", JSON.stringify(initialVisibility));
|
||||
|
||||
console.log("💾 Saved initial mapLayersVisibility to localStorage:", initialVisibility);
|
||||
}
|
||||
}
|
||||
@@ -257,6 +264,16 @@ function MapLayersControlPanel() {
|
||||
console.log("📌 stationListing aktualisiert:", filteredAreas);
|
||||
}
|
||||
}, [GisStationsStaticDistrict, GisSystemStatic]);
|
||||
|
||||
//---------------------------
|
||||
// ✅ Redux mapLayers mit GisSystemStatic initialisieren
|
||||
useEffect(() => {
|
||||
if (Array.isArray(GisSystemStatic) && GisSystemStatic.length > 0) {
|
||||
console.log("🔧 Initializing mapLayers in Redux with GisSystemStatic:", GisSystemStatic);
|
||||
dispatch(setInitialLayers(GisSystemStatic));
|
||||
}
|
||||
}, [GisSystemStatic, dispatch]);
|
||||
|
||||
//---------------------------
|
||||
useEffect(() => {
|
||||
const next = (GisStationsStaticDistrict.Points || []).map(p => p.Area_Name).join("|");
|
||||
|
||||
Reference in New Issue
Block a user