Folium&Map对象没有属性M

2024-06-06 03:27:12 发布

您现在位置:Python中文网/ 问答频道 /正文

当发现叶面时,在尝试向叶面地图添加标记时出现属性错误。

import folium

map_osm=folium.Map(location=[50.4547,30.5238], zoom_start=6, tiles='Stamen Terrain')
map_osm.Marker(location=[45.463612, 29.294559], popup='Solar Power Station')

map_osm.save('spst.html')

但是,我得到以下错误:

AttributeError: 'Map' object has no attribute 'Marker'

感谢你的帮助!


Tags: 标记importmap属性osm错误地图location
2条回答

正确的语法如下:

folium.Marker([45.463612, 29.294559], popup='Solar Power Station').add_to(map_osm)

所以你的代码应该看起来像

import folium

map_osm=folium.Map(location=[50.4547,30.5238], zoom_start=6, tiles='Stamen Terrain')
folium.Marker([45.463612, 29.294559], popup='Solar Power Station').add_to(map_osm)

map_osm.save('spst.html')

你可能有一个老版本的叶状体。尝试:

pip install -U folium

相关问题 更多 >