fix: LTEModam nicht klickbar

This commit is contained in:
ISA
2025-05-14 08:03:34 +02:00
parent 154d310117
commit c5d4ed3a59
4 changed files with 20 additions and 9 deletions

View File

@@ -6,12 +6,23 @@ const useLayerVisibility = (map, markers, mapLayersVisibility, layerKey, oms) =>
useEffect(() => {
if (!map || !markers || !oms) return;
// Leerzeichen, Bindestriche entfernen & Kleinbuchstaben erzwingen
const normalizedLayerKey = layerKey.replace(/\s|-/g, "").toLowerCase();
// Alle mapLayersVisibility-Keys auch normalisieren
const visibilityKeys = Object.keys(mapLayersVisibility).reduce((acc, key) => {
acc[key.replace(/\s|-/g, "").toLowerCase()] = mapLayersVisibility[key];
return acc;
}, {});
const isVisible = visibilityKeys[normalizedLayerKey] ?? false;
const toggleLayer = (isVisible) => {
markers.forEach((marker) => {
if (isVisible) {
marker.addTo(map);
oms.addMarker(marker);
addContextMenuToMarker(marker); // Kontextmenü hinzufügen
addContextMenuToMarker(marker);
} else {
map.removeLayer(marker);
oms.removeMarker(marker);
@@ -19,7 +30,7 @@ const useLayerVisibility = (map, markers, mapLayersVisibility, layerKey, oms) =>
});
};
toggleLayer(mapLayersVisibility[layerKey]);
toggleLayer(isVisible);
}, [map, markers, mapLayersVisibility, layerKey, oms]);
};