Bokeh tile renderer wont become visible/invisible based on .visible attribute


I’m trying to turn on/off renderers in a map using a checkbox and the renderer.visible property.
This works for glyph renderers, but using the same method on tile renderers has no effect.


@beder Without code/details there is no way to know if there is some problem with your code, or with the library itself. Please supply a complete, minimal, reproducer that can be investigated.

I was able to reproduce the problem I believe using bokeh server. My version is 2.0.2.

Here’s a minimal example and workaround in one file. Remove the alpha setting logic to reproduce the problem.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from bokeh.plotting import figure, curdoc
from bokeh.layouts import column

from bokeh.tile_providers import CARTODBPOSITRON, get_provider
from bokeh.models import Button

tile_provider = get_provider(CARTODBPOSITRON)

# range bounds supplied in web mercator coordinates
p = figure(x_range=(-2000000, 6000000), y_range=(-1000000, 7000000),
           x_axis_type="mercator", y_axis_type="mercator")

r = p.add_tile(tile_provider)

def cb():
    r.visible = not r.visible
    print("cb() INFO visible {:}".format(r.visible))
    if r.visible:
        r.alpha = 1.0
        r.alpha = 0.0

b = Button()


I just created