Problem when user changes map tiles

Hi,

I want to give the user the option of changing the map tiles (as in satellite vs map).

I have an example running here:

http://54.191.230.199:5006/bokeh_map

The problem is that after switching the tiles a few times, the data points disappear and the plot becomes unresponsive. No errors/warnings given; same behavior in several browsers I tried.

(Note that sometimes the tiles do not update until there is some action (pan/zoom). Although not ideal, I can live with that.)

It seems to me that if the user zooms in/out before changing the tiles, the problem is delayed, but it will manifest itself eventually.

My code:

bokeh serve --show bokeh_map.py

from bokeh.io import curdoc
from bokeh.models import WMTSTileSource
from bokeh.layouts import column, row
from bokeh.plotting import Figure
from bokeh.models.widgets import RadioButtonGroup

from pyproj import Proj, transform

tiles = [(‘OpenMap’, WMTSTileSource(url=‘http://c.tile.openstreetmap.org/{Z}/{X}/{Y}.png’)),
(‘ESRI’, WMTSTileSource(url=‘https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}.jpg’)),
(‘Wikimedia’, WMTSTileSource(url=‘https://maps.wikimedia.org/osm-intl/{Z}/{X}/{Y}@2x.png’))]
active_init=1

def update_tiles(active):
plot.add_tile(tiles[active][1])

layer_group = RadioButtonGroup(labels=[tiles[i][0] for i in range(len(tiles))], width=600, active=active_init)
layer_group.on_click(update_tiles)

plot = Figure(plot_width=800, plot_height=800, active_scroll=‘wheel_zoom’)
plot.circle(x=[-10875914, -10880367, -10884819], y=[3540881, 3529283, 3540881], size=8, fill_color=“blue”)
plot.add_tile(tiles[active_init][1])

curdoc().add_root(column(layer_group, plot))

``

Any ideas why this happens are much appreciated,

Alex

Edit: no errors/warnings given on the terminal.
The browser gives this error:

Uncaught TypeError: this.model.tile_source.get_level_by_extent is not a function
at e.r.TileRendererView.e._map_data (tile_renderer.js:103)
at e.r.TileRendererView.e.render (tile_renderer.js:207)
at e.r.PlotCanvasView.e._paint_levels (plot_canvas.js:846)
at e.r.PlotCanvasView.e.paint (plot_canvas.js:807)
at e. (plot_canvas.js:606)
at t.emit (signaling.js:61)
at e. (plot_canvas.js:120)
at o (throttle.js:22)

``

Hi,

I believe you are seeing this issue:

  https://github.com/bokeh/bokeh/issues/6590#issuecomment-336458918

There is a workaround described in the issue. Basically you will need to create your own tile sources in your app instead of using the ones in tile_providers.py (you can just copy the code in tile_providers.py) so that it's not trying to share the same literal Bokeh objects across sessions (which is not permissible)

Thanks,

Bryan

···

On Oct 13, 2017, at 15:44, [email protected] wrote:

Edit: no errors/warnings given on the terminal.
The browser gives this error:
Uncaught TypeError: this.model.tile_source.get_level_by_extent is not a function
    at e.r.TileRendererView.e._map_data (tile_renderer.js:103)
    at e.r.TileRendererView.e.render (tile_renderer.js:207)
    at e.r.PlotCanvasView.e._paint_levels (plot_canvas.js:846)
    at e.r.PlotCanvasView.e.paint (plot_canvas.js:807)
    at e.<anonymous> (plot_canvas.js:606)
    at t.emit (signaling.js:61)
    at e.<anonymous> (plot_canvas.js:120)
    at o (throttle.js:22)

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4a37adf7-4970-4cc4-86c1-53cafa4722fe%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hey Bryan,

Spot on; when I generate the tiles inside the update_tiles
function I don’t get the problem.

Thank you so much.

···

On Friday, October 13, 2017 at 3:59:44 PM UTC-5, Bryan Van de ven wrote:

Hi,

I believe you are seeing this issue:

    [https://github.com/bokeh/bokeh/issues/6590#issuecomment-336458918](https://github.com/bokeh/bokeh/issues/6590#issuecomment-336458918)

There is a workaround described in the issue. Basically you will need to create your own tile sources in your app instead of using the ones in tile_providers.py (you can just copy the code in tile_providers.py) so that it’s not trying to share the same literal Bokeh objects across sessions (which is not permissible)

Thanks,

Bryan

On Oct 13, 2017, at 15:44, [email protected] wrote:

Edit: no errors/warnings given on the terminal.
The browser gives this error:

Uncaught TypeError: this.model.tile_source.get_level_by_extent is not a function

at e.r.TileRendererView.e._map_data (tile_renderer.js:103)
at e.r.TileRendererView.e.render (tile_renderer.js:207)
at e.r.PlotCanvasView.e._paint_levels (plot_canvas.js:846)
at e.r.PlotCanvasView.e.paint (plot_canvas.js:807)
at e.<anonymous> (plot_canvas.js:606)
at t.emit (signaling.js:61)
at e.<anonymous> (plot_canvas.js:120)
at o (throttle.js:22)


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4a37adf7-4970-4cc4-86c1-53cafa4722fe%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,

A PR to fix this was merged, the original code will work after the next release.

Thanks,

Bryan

···

On Oct 13, 2017, at 16:27, [email protected] wrote:

Hey Bryan,
Spot on; when I generate the tiles inside the update_tiles function I don’t get the problem.
Thank you so much.

On Friday, October 13, 2017 at 3:59:44 PM UTC-5, Bryan Van de ven wrote:

Hi,

I believe you are seeing this issue:

        https://github.com/bokeh/bokeh/issues/6590#issuecomment-336458918

There is a workaround described in the issue. Basically you will need to create your own tile sources in your app instead of using the ones in tile_providers.py (you can just copy the code in tile_providers.py) so that it's not trying to share the same literal Bokeh objects across sessions (which is not permissible)

Thanks,

Bryan

> On Oct 13, 2017, at 15:44, [email protected] wrote:
>
> Edit: no errors/warnings given on the terminal.
> The browser gives this error:
> Uncaught TypeError: this.model.tile_source.get_level_by_extent is not a function
> at e.r.TileRendererView.e._map_data (tile_renderer.js:103)
> at e.r.TileRendererView.e.render (tile_renderer.js:207)
> at e.r.PlotCanvasView.e._paint_levels (plot_canvas.js:846)
> at e.r.PlotCanvasView.e.paint (plot_canvas.js:807)
> at e.<anonymous> (plot_canvas.js:606)
> at t.emit (signaling.js:61)
> at e.<anonymous> (plot_canvas.js:120)
> at o (throttle.js:22)
>
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4a37adf7-4970-4cc4-86c1-53cafa4722fe%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/d893870a-ab44-4ded-828c-45b5f0fc24fe%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.