我有一个使用 folium 库创建的 HeatMapWithTime。热图随时间变化。我想将此地图导出为动态格式的 HTML。我想使用这张地图进行演示,而无需运行代码。如果有人可以告诉我如何在不丢失时间步长的情况下导出地图,我将不胜感激。
我的地图代码:
map_Oslo = folium.Map(location=[Latitude, Longitude], zoom_start=5)
plugins.HeatMapWithTime(heat_data,
radius=10,
gradient={0.1: 'blue', 0.2: 'blue', 0.4: 'lime', 0.6: 'orange', 0.8: 'red', 0.99: 'purple'},
min_opacity=0.5, max_opacity=0.8, use_local_extrema=False).add_to(map_Oslo)
map_Oslo
Run Code Online (Sandbox Code Playgroud)
我尝试了一些建议,但收到错误WebDriverException: Message: 'geckodriver' executable needs to be in PATH.,并且无法判断代码是否有效。:
import os
import time
from selenium import webdriver
delay=5
fn='testmap.html'
tmpurl='file://{path}/{mapfile}'.format(path=os.getcwd(),mapfile=fn)
map_Oslo.save(fn)
browser = webdriver.Firefox()
browser.get(tmpurl)
#Give the map tiles some time to load
time.sleep(delay)
browser.save_screenshot('map.png')
browser.quit()
Run Code Online (Sandbox Code Playgroud)