I can retrieve and set a WMSLayer with the code below, but I'd like to pass some extra options to the server (in particular, to use a logscale and set a colorscale range). The WMSLayer
constructor takes an options
argument, but this is required to be a list of (unicode) strings, and I'm not able to set the values corresponding to arguments.
That is, I can pass options=['logscale']
(as below), but trying to set it to True or False (or "true" or "false") fail, with variants tried such as options=['logscale', 'true']
or options=['logscale=true']
.
Examining the arguments sent to the server (the JS console will show errors) shows that "logscale" is used, but always set to be undefined. That is, something like, https://some-server.domain.tld/thredds/wms/somefile.nc?service=WMS&request=...&logscale=undefined&...
.
How do I pass values for the extra options in the WMSLayer constructor?
Is there indeed a way to get extra options with their values from ipyleaflet to the underlying leaflet.js?
import ipyleaflet
from owslib.wms import WebMapService
wms_url = "https://some-server.domain.tld/thredds/wms/somefile.nc"
wms_layers = list(WebMapService(wms_url).contents.keys())
wms = ipyleaflet.WMSLayer(url=wms_url, layers=wms_layers[0], transparent=True,
format='image/png', opacity=0.33, options=['logscale'])
m = ipyleaflet.Map(zoom=3)
m.add_layer(wms)
# fetch map and display in Jupyter cell
m