fix: LTEModam nicht klickbar
This commit is contained in:
@@ -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]);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user