From 92b0b13e1cb9c0827f5e400070c8b739628417c1 Mon Sep 17 00:00:00 2001 From: Matt Watson Date: Thu, 2 May 2024 12:34:40 -0400 Subject: [PATCH] filter layers to only visible ones --- src/components/map/default-layers.js | 72 ++++++++++++++-------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/src/components/map/default-layers.js b/src/components/map/default-layers.js index b0c3f358..dadffda5 100644 --- a/src/components/map/default-layers.js +++ b/src/components/map/default-layers.js @@ -142,41 +142,43 @@ export const DefaultLayers = () => { return ( <> - {defaultModelLayers.map((layer, index) => { - const pieces = layer.id.split('-'); - const type = pieces[pieces.length-1]; - //console.log("type: " + JSON.stringify(type, null, 2)) - if( type === "obs" && obsData !== "") { - //console.log("obsData: " + JSON.stringify(obsData, null, 2)); - return ( - - ); - } - else { - return ( - { - console.log('marker clicked') - }, - }} */ - url={gs_wms_url} - layers={layer.layers} - params={{ - format:"image/png", - transparent: true, - }} - - /> - ); - } - })}; + {defaultModelLayers + .filter(({state }) => state.visible) + .map((layer, index) => { + const pieces = layer.id.split('-'); + const type = pieces[pieces.length-1]; + //console.log("type: " + JSON.stringify(type, null, 2)) + if( type === "obs" && obsData !== "") { + //console.log("obsData: " + JSON.stringify(obsData, null, 2)); + return ( + + ); + } else { + return ( + { + console.log('marker clicked') + }, + }} */ + url={gs_wms_url} + layers={layer.layers} + params={{ + format:"image/png", + transparent: true, + }} + + /> + ); + } + }) + }; ); }; \ No newline at end of file