Skip to content

Commit

Permalink
Merge pull request #19 from RENCI/bugfix/layer-visibility
Browse files Browse the repository at this point in the history
filter layers to only visible ones
  • Loading branch information
PhillipsOwen authored May 2, 2024
2 parents f4fc3be + 92b0b13 commit 1f67ab2
Showing 1 changed file with 37 additions and 35 deletions.
72 changes: 37 additions & 35 deletions src/components/map/default-layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<GeoJSON
key = {index}
data = {obsData}
pointToLayer = {obsPointToLayer}
onEachFeature = {onEachObsFeature}
/>
);
}
else {
return (
<WMSTileLayer
key = {index}
/* eventHandlers={{
click: () => {
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 (
<GeoJSON
key = {index}
data = {obsData}
pointToLayer = {obsPointToLayer}
onEachFeature = {onEachObsFeature}
/>
);
} else {
return (
<WMSTileLayer
key = {index}
/* eventHandlers={{
click: () => {
console.log('marker clicked')
},
}} */
url={gs_wms_url}
layers={layer.layers}
params={{
format:"image/png",
transparent: true,
}}

/>
);
}
})
};
</>
);
};

0 comments on commit 1f67ab2

Please sign in to comment.