Skip to content

Commit

Permalink
[Fixes #1117] Layer legend is not updated (#1161)
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap committed Aug 23, 2022
1 parent 481e4b2 commit 8c67c0d
Showing 1 changed file with 7 additions and 1 deletion.
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

0 comments on commit 8c67c0d

Please sign in to comment.