react-mapbox-gl icon indicating copy to clipboard operation
react-mapbox-gl copied to clipboard

Support dynamically updating opacity via props for WMS (raster) layers.

Open Ry-DS opened this issue 3 years ago • 0 comments

Hey! We are currently trying to use react-mapbox-gl to create an opacity slider for our application: https://github.com/WFP-VAM/prism-frontend/pull/138

However, we ran into a roadblock. If you try updating the opacity of a raster layer like demonstrated here: https://codesandbox.io/s/react-mapbox-gl-opacity-prop-tu0h2 The entire layer is reloaded. This isn't great in terms of user experience, and we were hoping if we can rework the way prop changes are handled, so opacity - and possibly other properties - when changed via state, update the layer seamlessly without reloading.

We managed to create a seamless opacity slider for raster layers here: http://prism-opacity.surge.sh (click the hazard layers dropdown at the top, then choose "Snow Coverage". Note: link is not permanent). However, we didn't achieve this using props. We instead had to set the opacity manually as follows.

Adding support for seamless opacity changes via props would be great, as we can then stop worrying about our tiles being redownloaded every state change.

cc @ericboucher @hav142

Ry-DS avatar Apr 30 '21 14:04 Ry-DS