gpt4 book ai didi

python - 断言错误 : You cannot render this Element if it is not in a Figure

转载 作者:太空宇宙 更新时间:2023-11-04 01:46:16 26 4
gpt4 key购买 nike

我写了下面的代码:

import folium
map = folium.Marker(location=[80, -100], zoom_start=6, tiles="Mapbox Bright")
fg = folium.FeatureGroup(name="My map")
fg.add_child(folium.Marker(location=[80, -100], popup="Marker Here", icon=folium.Icon(color="green")))

map.save("Map.html")

我不断收到此错误消息:

Traceback (most recent call last):
File "c:/Users/king/Desktop/applications/mapping/maps.py", line 6, in <module>
map.save("Map.html" )
File "C:\Users\king\AppData\Local\Programs\Python\Python38-32\lib\site-packages\branca\element.py", line 169, in save
html = root.render(**kwargs)
File "C:\Users\king\AppData\Local\Programs\Python\Python38-32\lib\site-packages\branca\element.py", line 614, in render
assert isinstance(figure, Figure), ('You cannot render this Element '
AssertionError: You cannot render this Element if it is not in a Figure.

我正在尝试保存正在构建的 map 的进度,但它一直显示错误消息

最佳答案

根据docs Marker 应该添加到 Map

map = folium.Map(
location=[80, -100],
zoom_start=6,
tiles="Mapbox Bright"
)

fg = folium.FeatureGroup(name="My map")

folium.Marker(
location=[80, -100],
popup="Marker Here",
icon=folium.Icon(icon='green')
).add_to(map)

关于python - 断言错误 : You cannot render this Element if it is not in a Figure,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59032519/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com