Folium:如何显示 ipynb 中保存的 html 文件中的地图

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

我有一个 folium 地图在本地保存为 html 文件,现在我想读取该

map.html
文件以在另一个 ipynb 单元/笔记本中显示地图。

生成本地文件的最少代码:

import folium

m = folium.Map(location=[45.5236, -122.6750]) 
m # to view the map if needed
m.save('map.html')

本质上我正在尝试找到任何方法来在本地保存地图(不需要是html)并稍后在其他一些 ipynb 笔记本中阅读它。

我能够找到在 web 上共享它的方法,但我的用例仅限于 ipynb。

python folium
1个回答
0
投票

您是否尝试过将其加载为第二个IFrame

中的
ipynb

import folium

# op map
m = folium.Map([45.5236, -122.6750])

# adding a blue marker/icon
folium.Marker(location=[45.5236, -122.6750], icon=folium.Icon(color="blue")).add_to(m)

m.save("map.html") # saving it locally

from IPython.display import IFrame

IFrame(src="map.html", width=800, height=350)

输出(在 Jupyterlab):

© www.soinside.com 2019 - 2024. All rights reserved.