python - 如何从 Google Colab 笔记本中的 gmplot draw 命令查看 html 输出文件?
问题描述
我正在尝试使用 colab 和 googlemaps 来显示覆盖在谷歌地图上的热图图像。我做了一些研究,并在此链接上找到了 2 个可能的解决方案,但两个解决方案都不起作用。
在 Google Colab 平台上的 Jupyter Notebook 中显示/渲染 HTML 文件
也许最近发生了一些变化?这是我的代码:
pip install gmplot
import gmplot
gmap1 = gmplot.GoogleMapPlotter(30.3164945,
78.03219179999999, 13, apikey='AIzaSyBCyhpxDYIxIq9uINYxDK5aIjWSokUvsvY' )
gmap1.draw( "map11.html" )
import os
print(os.getcwd())
!ls
/content
map11.html sample_data
import IPython
IPython.display.HTML(filename='/content/map11.html')
nothing is displayed.
from IPython.display import IFrame
IFrame(src='/content/map11.html', width=900, height=600)
localhost refused to connect.
解决方案
您的本地浏览器无法从远程 VM 文件系统读取文件。尝试直接显示 HTML 内容,而不是通过文件名传递 HTML:
IPython.display.HTML(open('/content/map11.html').read())
推荐阅读
- c# - 试图完成一个问题,我一直遇到 get Object Reference not set to an instance of an object line 31
- go - Go Rod If 按钮
- c++ - 在 CMake 中将标头编译为可执行文件
- angular - 刷新令牌请求被发送两次 - 寻找除 HttpBackend 之外的另一种解决方案
- python - 如何不断更新 Flask 中视图函数中使用的变量?
- javascript - 我怎样才能让我的机器人对反应做出反应?
- r - 使用 sapp() 将 terra::focal 应用于 SpatRaster 的每一层
- python - 将文本输入到 SVG2RLG Python 库
- go - 无效的工作空间配置:golang 中路径中的大小写不匹配
- data-science - 如何解决不可哈希类型的类型错误?