Hello all!
I am trying to control visibility of WMTSTileSource layers with a radio button in a bokeh server app. What I want is to switch from one wms layer to the other by clicking a different radio button option.
What I did so far is set up a list of wms layers, add these with add_tile and group the handles in a list. Upon radio button callback, I set visible to False. The callback works fine as I print the result just to check. Whatever I do, both layer are always visible! Does anyone know how I should do this? Code snippets are as follows:
Setting up of the wms layers
p = figure(plot_height=550, plot_width=900)
wms = []
for url, attribution in zip(urls, attributions):
bkg_tile = WMTSTileSource(url=url,
attribution=attribution
)
wms.append(p.add_tile(bkg_tile))
Setup of radiogroup
# Widgets and callbacks
radio_group = RadioGroup(
labels=url_names, active=0)
radio_group.on_change('active', radio_group_change)
Callback (including check on the status of the visible property afterwards)
def radio_group_change(attrname, old, new):
update_background()
def update_background():
print('Active layer is {:d}'.format(radio_group.active))
for n, w in enumerate(wms):
if n == radio_group.active:
w.visible = True
else:
w.visible = False
print('Layer 1 is {:s}'.format(str(wms[0].visible)))
print('Layer 2 is {:s}'.format(str(wms[1].visible)))