使用 gmap 和 Bokeh 显示 GoogleMap 的问题

问题描述 投票:0回答:0

我正在尝试按照博客说明here.

在Jypyter Notebook中显示谷歌地图(带有一些坐标作为散点图)

方法一:

在 Jypyter 中使用以下代码块,错误提示,查看 JavaScript 控制台以获取错误信息。我该如何解决?

import gmaps
gmaps.configure(api_key='AIzaSyAyRAMSfG6ic9oYV9bemRkn2sYqOh8VQSE')
from bokeh.io import output_notebook
output_notebook()
#bokeh_width, bokeh_height = 500, 400
import os
api_key = 'AIzaSyAyRAMSfG6ic9oYV9bemRkn2sYqOh8VQSE'  # os.environ['AIzaSyAyRAMSfG6ic9oYV9bemRkn2sYqOh8VQSE']
from bokeh.io import show
from bokeh.plotting import gmap
from bokeh.models import GMapOptions

lat, lon = 46.2437, 6.0251

def plot(lat, lng, zoom=1, map_type='terrain'):
    gmap_options = GMapOptions(lat=lat, lng=lng, map_type=map_type, zoom=zoom)
    p = gmap(api_key, gmap_options, title='Google Map for Arctic Canada')     #,width=bokeh_width, height=bokeh_height)
    show(p)
    return p

方法二:

使用下面的代码块,解决了 JavaScript 问题,但是 Axis label 错误,Google 地图没有显示。

import gmaps
gmaps.configure(api_key='AIzaSyAyRAMSfG6ic9oYV9bemRkn2sYqOh8VQSE')
from bokeh.io import output_notebook
from bokeh.io import show
from bokeh.plotting import figure, gmap
from bokeh.models import GMapOptions

bokeh_width, bokeh_height =500,400
api_key = 'AIzaSyAyRAMSfG6ic9oYV9bemRkn2sYqOh8VQSE'  # os.environ['AIzaSyAyRAMSfG6ic9oYV9bemRkn2sYqOh8VQSE']
# %%
output_notebook()
figure(height=300, width=600, x_range=(-100,-70), y_range=(50, 70))
def plot(lat, lng, zoom=10, map_type='roadmap'):
    gmap_options = GMapOptions(lat=lat, lng=lng,
                               map_type=map_type, zoom=zoom)
    p = gmap(api_key, gmap_options, title='Google Map',
             width=bokeh_width, height=bokeh_height)
    show(p)
    return p

p = plot(62, -80)

python-3.x bokeh gmap.net
© www.soinside.com 2019 - 2024. All rights reserved.