How to request Bokeh maps tile updates?

Google maps in Bokeh has become too difficult with their API keys and registration, so I’m exploring alternatives but really like the Bokeh framework, especially with periodic callbacks.

What’s the right way to coerce Bokeh to update the basemap tile better? I assume map tiles are supposed to be updated automatically, and they are, sort of, but it’s not working as well as expected.

Here’s a simple code clip to convert (lat/lon) pairs into Northing and Easting values to display a region of a basemap.

Zooming and panning works but sometimes leaves large blank tiles that never fill-in.

How can this be addressed?

from bokeh.plotting import figure, show, output_file, curdoc
from bokeh.models.widgets import Slider, Div
from bokeh.layouts import column, layout
from bokeh.tile_providers import get_provider, Vendors
from pyproj import Proj, transform

def LatLon_to_EN(lat, lon):
    try:
      easting, northing = transform( Proj('epsg:4326'), Proj('epsg:3857'), lat, lon) # from WGS-84 to Web Mercator Easting/Northing
      return easting, northing
    except:
      return None, None

tile_provider = get_provider(Vendors.STAMEN_TERRAIN_RETINA)
#tile_provider = get_provider(Vendors.STAMEN_TERRAIN)

# SouthWest and NorthEast corners
SW_corner=(29.191391, -81.049014) # center of campus foot bridge
NE_corner=(29.239598, -80.949180) # out in the ocean

# Convert to mercator Easting and Northing coordinates
SW_corner_EN = LatLon_to_EN( SW_corner[0] , SW_corner[1] )
NE_corner_EN = LatLon_to_EN( NE_corner[0] , NE_corner[1] )

# x_axis_type, y_axis_type may be: "linear", "log", "datetime", "mercator"
plot = figure(x_range=(SW_corner_EN[0], NE_corner_EN[0]), y_range=(SW_corner_EN[1], NE_corner_EN[1]), x_axis_type="mercator", y_axis_type="mercator")
plot.add_tile(tile_provider)

curdoc().add_root(plot)
curdoc().title = "Bokeh example for basemap with non-Google tile 
providers"

@comperem just FYI (in case it is not evident) the API key restrictions are coming from Google, not Bokeh. I wish they had left some level of open usage, but they didn’t and there is not anything we can do about that, alas.

In running your example I did notice these 404s using the retina tiles:

[bokeh] – “unable to load http://tile.stamen.com/terrain/13/2250/[email protected] image after 1 attempts”
http://tile.stamen.com/terrain/13/2251/[email protected]

which are presumably also nothing we can do anything about directly. That said there were still issues even with the non-retina tiles, which also did not have any of those 404 errors. I’d not seen these issues previously, so I’d say perhaps there are some regressions with TileProvider plots, and a GitHub issue with this MRE would be appropriate.

Hello Bryan,

Thanks for your response. I’m aware it’s Google’s API causing the difficulty and, yes, it is disappointing. I’m trying to keep new-user barriers low for my own open-source project and Google has added complexity with the map plotting.

But, Bokeh seems quite vibrant and active and is hopefully still the right interface.

I didn’t see any 404’s as you mentioned. My bokeh serve command executed with all normal outputs and no errors despite tiles not filling in.

I’ll open a Github issue with this same example.

Thanks,
Marc