问题描述
使用“ ipywidgets.embed.embed_minimal_html”将jupyter-gmaps基本地图和路线导出到HTML之后,当我重新打开HTML地图时,我无法显示路线图层。
基本地图和方向图层在jupyter笔记本中显示得很好,如下所示: Map and directions rendered in Jupyter Notebook
但是,使用服务器(使用“ python -m http.server 8080”打开),双击保存的文件或使用下面的代码段重新打开HTML文件时,仅基本层渲染如下所示,以及一些奇怪的工件:What is rendered when the exported HTML is opened
import IPython
IPython.display.HTML(filename='testest.html')
方向层似乎正在HTML中保存,因为在尝试保存图像时出现关于方向层的错误,但是脚本未在浏览器中呈现(Error about directions layer when opening the HTML file)。 the following errors are displayed Chrome console。
这是我用来生成此地图的代码,如果有人可以帮助我弄清楚如何获取要在导出的地图中呈现的方向图层,我将不胜感激:)
import gmaps
from ipywidgets.embed import embed_minimal_html,embed_data
import IPython
import os
#configure api
api_key = 'YOUR-API-KEY-HERE'
gmaps.configure(api_key=api_key)
#Define location 1,2,and 3
Durango = (37.2753,-107.880067)
meow = (37.3654,-106.880067)
SF = (37.7749,-122.419416)
#Create the map
fig = gmaps.figure()
#create the layers
layer1 = gmaps.directions_layer(Durango,meow,travel_mode="DRIVING")
fig.add_layer(layer1)
layer2 = gmaps.directions_layer(Durango,SF,travel_mode="DRIVING")
fig.add_layer(layer2)
#Export the map and layers to HTML
embed_minimal_html(os.getcwd() + '\{}.html'.format("testest"),views=[fig],title='test')
#show the map in Jupyter
fig
谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)