From 825a966a71fbcc67f21e8ac762f4c1f8e95944ef Mon Sep 17 00:00:00 2001 From: Matt Watson Date: Thu, 2 May 2024 18:16:11 -0400 Subject: [PATCH 1/3] make only maxele and obs layers visible by default this is accomplished by offloading the determining of default layer state to a new function, `newLayerDefaultState`, that looks at the layer object. --- src/components/map/default-layers.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/components/map/default-layers.js b/src/components/map/default-layers.js index dadffda5..3a2e4001 100644 --- a/src/components/map/default-layers.js +++ b/src/components/map/default-layers.js @@ -4,6 +4,22 @@ import { CircleMarker } from 'leaflet'; import { useLayers } from '@context'; import { markClicked } from '@utils/map-utils'; +const newLayerDefaultState = layer => { + console.log(layer.properties.product_type) + const { product_type } = layer.properties + + if (['obs', 'maxele63'].includes(product_type)) { + return ({ + visible: true + }) + } + + return ({ + visible: false + }); +}; + + export const DefaultLayers = () => { const [obsData, setObsData] = useState(""); @@ -92,9 +108,7 @@ export const DefaultLayers = () => { if (layer) layer_list.push({ ...layer, - state: { - visible: true, - } + state: newLayerDefaultState(layer) }); // TODO: do we really need to do this here??! From aa81be87bc9973ed90c43ef09c1bec72f1e51c48 Mon Sep 17 00:00:00 2001 From: Matt Watson Date: Thu, 2 May 2024 18:19:34 -0400 Subject: [PATCH 2/3] remove debug logging --- src/components/map/default-layers.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/map/default-layers.js b/src/components/map/default-layers.js index 3a2e4001..c206f2ba 100644 --- a/src/components/map/default-layers.js +++ b/src/components/map/default-layers.js @@ -5,7 +5,6 @@ import { useLayers } from '@context'; import { markClicked } from '@utils/map-utils'; const newLayerDefaultState = layer => { - console.log(layer.properties.product_type) const { product_type } = layer.properties if (['obs', 'maxele63'].includes(product_type)) { From 420f18c9ffd3f45921cc7867583f26ff299f5d67 Mon Sep 17 00:00:00 2001 From: Matt Watson Date: Thu, 2 May 2024 18:20:15 -0400 Subject: [PATCH 3/3] fix eslint warnings --- src/components/map/default-layers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/map/default-layers.js b/src/components/map/default-layers.js index c206f2ba..36d2aacc 100644 --- a/src/components/map/default-layers.js +++ b/src/components/map/default-layers.js @@ -5,12 +5,12 @@ import { useLayers } from '@context'; import { markClicked } from '@utils/map-utils'; const newLayerDefaultState = layer => { - const { product_type } = layer.properties + const { product_type } = layer.properties; if (['obs', 'maxele63'].includes(product_type)) { return ({ visible: true - }) + }); } return ({