From 35c62f297c9a10af2259a8e5773c401c87bc4f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Cant=C3=B9?= Date: Mon, 25 Mar 2024 10:46:16 +0100 Subject: [PATCH] fix --- src/pages/viewer/components/Layers.jsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pages/viewer/components/Layers.jsx b/src/pages/viewer/components/Layers.jsx index 8154bc1..96c78c2 100644 --- a/src/pages/viewer/components/Layers.jsx +++ b/src/pages/viewer/components/Layers.jsx @@ -5,22 +5,22 @@ import LegendSymbol from "./LegendSymbol"; import { Button } from "react-bulma-components"; function Layer({ node }) { - const { map, layers, lazy, config, visibleLayers, setVisibleLayers } = useContext(MapContext); + const { map, layers, lazy, config, visibleLayers } = useContext(MapContext); const layer = layers[node.data.id]; const icon = layer && layer.isVisible ? 'fas fa-eye' : 'fas fa-eye-slash'; const updateVisibility = () => { - if (layer) { - if (config && config.exclusive_layers) { - for (const lid of visibleLayers) { - map.setLayoutProperty(lid, 'visibility', 'none'); - } + if (config && config.exclusive_layers) { + for (const lid of visibleLayers) { + map.setLayoutProperty(lid, 'visibility', 'none'); } + } + + if (layer) { map.setLayoutProperty(node.data.id, 'visibility', layer.isVisible ? 'none' : 'visible'); } else { map.addLayer(lazy.layers[node.data.id]); - setVisibleLayers([...visibleLayers, node.data.id]); } }