Systeme mit Map === 0 vollständig ausgeblenden
This commit is contained in:
@@ -31,7 +31,7 @@ function MapLayersControlPanel() {
|
||||
console.log("🎯 kabelstreckenVisible state changed to:", kabelstreckenVisible);
|
||||
}, [kabelstreckenVisible]);
|
||||
|
||||
// Prüfen, ob TALAS (IdSystem 1) erlaubt ist
|
||||
// Prüfen, ob TALAS (IdSystem 1) erlaubt & sichtbar auf Karte (Allow + Map)
|
||||
const isTalasAllowed = Array.isArray(GisSystemStatic)
|
||||
? GisSystemStatic.some(
|
||||
system => system.IdSystem === 1 && system.Allow === 1 && system.Map === 1
|
||||
@@ -134,18 +134,23 @@ function MapLayersControlPanel() {
|
||||
dispatch(setLayerVisibility({ layer: key, visibility: parsedVisibility[key] }));
|
||||
});
|
||||
} else {
|
||||
// Initialisiere mapLayersVisibility basierend auf GisSystemStatic Allow-Werten
|
||||
console.log("🚀 No stored mapLayersVisibility found, initializing based on Allow values...");
|
||||
// Initialisiere mapLayersVisibility basierend auf Allow & Map (nur Systeme mit Map===1 anzeigen)
|
||||
console.log(
|
||||
"🚀 No stored mapLayersVisibility found, initializing based on Allow && Map values..."
|
||||
);
|
||||
if (Array.isArray(GisSystemStatic)) {
|
||||
const initialVisibility = {};
|
||||
GisSystemStatic.forEach(system => {
|
||||
const systemKey = `system-${system.IdSystem}`;
|
||||
const visibility = system.Allow === 1;
|
||||
initialVisibility[systemKey] = visibility;
|
||||
dispatch(setLayerVisibility({ layer: systemKey, visibility }));
|
||||
console.log(
|
||||
`🎯 Setting ${systemKey} (${system.Name}) visibility to ${visibility} (Allow=${system.Allow})`
|
||||
);
|
||||
const visibility = system.Allow === 1 && system.Map === 1; // <— angepasst
|
||||
if (visibility) {
|
||||
// nur speichern wenn grundsätzlich sichtbar
|
||||
initialVisibility[systemKey] = visibility;
|
||||
dispatch(setLayerVisibility({ layer: systemKey, visibility }));
|
||||
console.log(
|
||||
`🎯 Setting ${systemKey} (${system.Name}) visibility to ${visibility} (Allow=${system.Allow}, Map=${system.Map})`
|
||||
);
|
||||
}
|
||||
});
|
||||
localStorage.setItem(mapStorageKey, JSON.stringify(initialVisibility));
|
||||
console.log(`💾 Saved initial mapLayersVisibility to ${mapStorageKey}:`, initialVisibility);
|
||||
@@ -159,9 +164,6 @@ function MapLayersControlPanel() {
|
||||
setLocalStorageLoaded(true);
|
||||
}, []); // Läuft nur beim Mount
|
||||
|
||||
// Entferne den komplexen Konsistenz-Check useEffect - nicht mehr nötig
|
||||
// da wir direkt mit localStorage arbeiten
|
||||
|
||||
const handleAreaChange = event => {
|
||||
const selectedIndex = event.target.options.selectedIndex;
|
||||
const areaName = event.target.options[selectedIndex].text;
|
||||
@@ -169,8 +171,13 @@ function MapLayersControlPanel() {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// Allowed systems jetzt nach Allow && Map filtern
|
||||
const allowedSystems = Array.isArray(GisSystemStatic)
|
||||
? new Set(GisSystemStatic.filter(system => system.Allow === 1).map(system => system.IdSystem))
|
||||
? new Set(
|
||||
GisSystemStatic.filter(system => system.Allow === 1 && system.Map === 1).map(
|
||||
system => system.IdSystem
|
||||
)
|
||||
)
|
||||
: new Set();
|
||||
|
||||
const seenNames = new Set();
|
||||
@@ -194,7 +201,7 @@ function MapLayersControlPanel() {
|
||||
const seenSystemNames = new Set();
|
||||
const filteredSystems = Array.isArray(GisSystemStatic)
|
||||
? GisSystemStatic.filter(item => {
|
||||
const isUnique = !seenSystemNames.has(item.Name) && item.Allow === 1;
|
||||
const isUnique = !seenSystemNames.has(item.Name) && item.Allow === 1 && item.Map === 1; // <— Map Bedingung hinzugefügt
|
||||
if (isUnique) {
|
||||
seenSystemNames.add(item.Name);
|
||||
}
|
||||
@@ -205,8 +212,8 @@ function MapLayersControlPanel() {
|
||||
setSystemListing(
|
||||
filteredSystems.map((system, index) => ({
|
||||
id: index + 1,
|
||||
name: system.Name, // Verwende den Originalnamen für die Anzeige
|
||||
key: `system-${system.IdSystem}`, // Internen Schlüssel für die MapLayersVisibility-Logik
|
||||
name: system.Name, // Anzeige
|
||||
key: `system-${system.IdSystem}`, // interner Schlüssel
|
||||
}))
|
||||
);
|
||||
}, [GisStationsStaticDistrict, GisSystemStatic]);
|
||||
@@ -328,13 +335,14 @@ function MapLayersControlPanel() {
|
||||
style={{ minWidth: "150px", maxWidth: "200px" }}
|
||||
>
|
||||
<option value="Station wählen">Station wählen</option>
|
||||
{[
|
||||
{/*
|
||||
...new Map(
|
||||
(GisStationsStaticDistrict.Points || [])
|
||||
.filter(p => !!p.Area_Name)
|
||||
.map(p => [p.Area_Name, p])
|
||||
).values(),
|
||||
].map((item, index) => (
|
||||
*/}
|
||||
{GisStationsStaticDistrict.Points.filter(p => !!p.Area_Name).map((item, index) => (
|
||||
<option key={item.Area_Name} value={item.IdLD}>
|
||||
{item.Area_Name}
|
||||
</option>
|
||||
@@ -399,25 +407,6 @@ function MapLayersControlPanel() {
|
||||
POIs
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{/* Areas
|
||||
<div className="flex items-center">
|
||||
<input type="checkbox" checked={areaVisible} onChange={handleAreaCheckboxChange} id="area-checkbox" />
|
||||
<label htmlFor="area-checkbox" className="text-sm ml-2">
|
||||
Bereiche
|
||||
</label>
|
||||
</div>
|
||||
*/}
|
||||
|
||||
{/* Standorte
|
||||
<div className="flex items-center">
|
||||
<input type="checkbox" checked={standordVisible} onChange={handleStandorteCheckboxChange} id="area-checkbox" />
|
||||
<label htmlFor="area-checkbox" className="text-sm ml-2">
|
||||
Standorte
|
||||
</label>
|
||||
</div>
|
||||
|
||||
*/}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user