Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes issue #152 - default the layer visibility when model runs are deleted. #153

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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