Reputation: 7
While discovering Folium got an AttributeError while trying to add a Marker to a folium map.
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')
However, I get the following error:
AttributeError: 'Map' object has no attribute 'Marker'
Appreciate any help on how to get around this!
Upvotes: 0
Views: 9971
Reputation: 101
You probably have an old version of Folium. Try:
pip install -U folium
Upvotes: 0
Reputation: 913
The correct syntax is the following:
folium.Marker([45.463612, 29.294559], popup='Solar Power Station').add_to(map_osm)
So your code should look like
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')
Upvotes: 1