Python AssertionError:如果该元素不在图形中,则无法呈现该元素
我编写了以下代码:Python AssertionError:如果该元素不在图形中,则无法呈现该元素,python,folium,Python,Folium,我编写了以下代码: 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.
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.
回溯(最近一次呼叫最后一次):
文件“c:/Users/king/Desktop/applications/mapping/maps.py”,第6行,在
保存(“map.html”)
文件“C:\Users\king\AppData\Local\Programs\Python38-32\lib\site packages\branca\element.py”,第169行,保存
html=root.render(**kwargs)
文件“C:\Users\king\AppData\Local\Programs\Python38-32\lib\site packages\branca\element.py”,第614行,在render中
断言isinstance(图,图),(“无法呈现此元素”
AssertionError:如果该元素不在图形中,则无法呈现该元素。
我正在尝试保存我正在构建的地图的进度,它会不断显示错误消息,根据标记应添加到地图
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)