pacificclimate / climate-explorer-frontend

6 stars 1 forks source link

Map sometimes has opacity set to 100% on overlay layers #91

Closed corviday closed 6 years ago

corviday commented 7 years ago

This bug seems to happen on initial load; changing datasets or timestamps fixes it. Need to look at calls to ncWMS and see what opacity value is being passed. If the overlay layers are opaque, context isn't visible to the user.

corviday commented 6 years ago

When you set an "opacity" parameter on a wms layer in leaflet, one of two things happens:

  1. Leaflet passes the parameter to ncWMS and gets a transparent image from ncWMS, which Leaflet puts unmodified into a layer.
  2. Leaflet requests an opaque image from ncWMS, and then Leaflet itself applies transparency to the image based on the opacity parameter.

It looks like the latter sequence usually happens when the map is first loaded, but the former happens when you switch timestamps or variables. This inconsistency is an issue because ncWMS accepts opacity parameters that are integers between 0 and 100, but Leaflet accepts opacity parameters between 0 and 1.

Not entirely sure what the best way to deal with this is. I wonder if upgrading to a newer version of Leaflet would fix it?

corviday commented 6 years ago

Okay, it looks like when you initialize a layer and pass in a set of params, anyparams the layer itself understands are used to initialize the layer. It stores any parameter it doesn't understand and passes them to ncWMS on the assumption that they are WMS parameters.

After the layer is already initialized, it assumes all params it receives are for WMS, which makes some sense, though it does result in strange behaviours around parameter names used by both ncWMS and Leaflet.