Display WMS layer on integrated Leaflet with interactive opacity

WMS URL and parameters


In [1]:
from jupytep.maps.leaflet.layer import WMSLayer

In [2]:
addressWMS = 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}'
parameters = {'opacity': '0.1', 'transparent': 'true', 'format': 'image/png'}

Create WMS layer


In [5]:
wmsL = WMSLayer()
wmsL.add_wms_layer(addressWMS, "nameOfLayer", parameters)
wmsL.show_layer()


Create slider


In [6]:
int_range = widgets.IntSlider()
display(int_range)


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-6-a75a8af083cf> in <module>()
----> 1 int_range = widgets.IntSlider()
      2 display(int_range)

NameError: name 'widgets' is not defined

Slider event handler


In [7]:
def onOpacityChange(change):
    wmsL.removeLayer()
    x = (str(change['new'] / 100))
    wmsL.changeAttributes('opacity', x)
    wmsL.showLayer()


int_range.observe(onOpacityChange, names='value')


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-7-5909f51f43d0> in <module>()
      6 
      7 
----> 8 int_range.observe(onOpacityChange, names='value')

NameError: name 'int_range' is not defined

In [ ]: