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 #1117] Layer legend is not updated #1161

Merged
merged 2 commits into from
Aug 23, 2022
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
8 changes: 7 additions & 1 deletion geonode_mapstore_client/client/js/plugins/Legend.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import { updateNode } from '@mapstore/framework/actions/layers';
import VisibilityCheck from '@mapstore/framework/components/TOC/fragments/VisibilityCheck';
import Message from '@mapstore/framework/components/I18N/HTML';

function applyVersionParamToLegend(layer) {
// we need to pass a parameter that invalidate the cache for GetLegendGraphic
// all layer inside the dataset viewer apply a new _v_ param each time we switch page
return { ...layer, legendParams: { ...layer?.legendParams, _v_: layer?._v_ } };
}

function Legend({
layers,
onUpdateNode
Expand Down Expand Up @@ -45,7 +51,7 @@ function Legend({
disabled={!layer.visibility}
onChange={(opacity) => onUpdateNode(layer.id, 'layers', { opacity })}
/>
<LegendImage layer={layer} />
<LegendImage layer={applyVersionParamToLegend(layer)} />
</li>
</Fragment>
)}
Expand Down