Skip to content

Commit

Permalink
Merge pull request #153 from RENCI/#152-fix-default-layers-on-model-r…
Browse files Browse the repository at this point in the history
…un-delete

fixes issue #152 - default the layer visibility when model runs are deleted.
  • Loading branch information
lstillwe authored Aug 7, 2024
2 parents 30d79ae + 137f0f6 commit 4030237
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/context/map-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,28 @@ export const LayersProvider = ({ children }) => {
return;
}
const newLayers = defaultModelLayers.filter(l => l.group !== groupId);

// now update the visible layer state for the top most model run
[...newLayers].forEach((layer) => {
// perform the visible state logic
layer.state = newLayerDefaultState(layer, newLayers[0].group);
});

setDefaultModelLayers(newLayers);
};

const newLayerDefaultState = (layer, group) => {
// if this is an obs layer and is the one just added
if (layer.group === group &&
(layer.properties['product_type'] === 'obs' || layer.properties['product_type'] === 'maxele63'))
// make this layer visible
return ({ visible: true, opacity: 1.0 });
// remove layer visibility
else
// make this layer invisible
return ({ visible: false, opacity: 1.0 });
};

const setLayerOpacity = (id, newOpacity) => {
const newLayers = [...defaultModelLayers];
const index = newLayers.findIndex(l => l.id === id);
Expand Down

0 comments on commit 4030237

Please sign in to comment.