bokeh: GMapPlot doesn't display anything in Jupyter v.4
Hi,
Just started using Bokeh more extensively and I wanted to display maps within a Jupyter notebook. I tried running the example provided in the repo (with the world_cities dataset) and while it displays when ran alone, it only displays a blank area in Jupyter (and I could only see the data once (without a map) when I refreshed, but this is not consistent). I have both latest versions for bokeh and Jupyter (from Anaconda).
import bokeh
import bokeh.plotting as plotting
plotting.output_notebook()
from bokeh.io import push_notebook
from bokeh.resources import INLINE
from bokeh.models.glyphs import Circle
from bokeh.models import (
GMapPlot, Range1d, ColumnDataSource,
PanTool, WheelZoomTool, GMapOptions)
from bokeh.resources import INLINE
from bokeh.sampledata.world_cities import data
x_range = Range1d(-160, 160)
y_range = Range1d(-80, 80)
map_options = GMapOptions(lat=15, lng=0, zoom=10)
plot = GMapPlot(
x_range=x_range,
y_range=y_range,
plot_width=1000,
plot_height=500,
map_options=map_options,
title="Cities of the world with a population over 5,000 people.",
webgl=True,
)
circle = Circle(x="lng", y="lat", size=5, line_color=None, fill_color='firebrick', fill_alpha=0.2)
plot.add_glyph(ColumnDataSource(data), circle)
plot.add_tools(PanTool(), WheelZoomTool())
plotting.show(plot)
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 41 (21 by maintainers)
I can confirm exactly the behavior that @canavandl has described:
I’d also add that a brand new instance of IPython ntb creates the plot for about ~1 second correctly: map loads, points appear wrongly (1 sec), points move to the correct position (1 sec), map disappears as:
(Code almost unchanged from here http://bokeh.pydata.org/en/0.11.1/docs/user_guide/geo.html, the only thing is output_file -> output_notebook)
Oh one last thing: adding
api-keyargument does not change any of the behavior described above.I’m able to reproduce the issue described by @colliand and using his notebook from nbviewer.
With a hard-refreshed browser window (with the cache deleted), the gmap plot will load the first time. Rerunning the cell containing the
showcall causes a white window (containing the google watermark) to appear instead of the map:Opening the dev tools will cause the plot to be rendered (presumably doing so causes the page to reflow), but the map coords aren’t the requested ones and the circle glyphs are missing:
Inspecting the network activity tab in the dev tools, it seems that there isn’t a gmap response payload when running the
showmethod a second time even though AFAICT the request is happening. I would think that it’s an issue of how we’re interacting w/ the Google maps API, but it will require further investigation.(thanks @colliand for the helpful notebook and bug description!)
@benuklove I just mean there have been various issues / possible issues and I think several of them got combined in this issue. It’s fine, I am going to work off the other issue first and see if it solves the problems described here too.
I can confirm this, no map on first run, no map and no glyphs after kernel restart. Page refresh causes glyphs to reappear, but still no map. No meaningful error messages in JS console. There are some related to comms when there are no glyphs rendered. I presume those errors obscure relevant information.