0

Here is the code:

for lat,lon,name,elev in zip(df['LAT'],df['LON'],df['NAME'],df['ELEV']):
    fg.add_child(folium.Marker(location=
    [lat,lon],popup=name,icon=folium.Icon(color=color_ori(elev))))

I am creating a map for volcanoes in the USA, and I want to show a marker with their names in the popup. I can't do that with the code above, but when I use popup=str(elev)+"m", it works fine. How do I include the names from my CSV file into a popup ?

SherylHohman
  • 16,580
  • 17
  • 88
  • 94

1 Answers1

0

You can just apply a method add_child to each marker with a popup object as an argument.

The code is:

import folium

lats = range(59, 63)
lons = range(10, 14)
names = ['marker' + str(i) for i in range(4)]
elevations = range(4)

m = folium.Map([60, 10], tiles='Mapbox Bright', zoom_start=5)
for lat, lon, name, elev in zip(lats, lons, names, elevations):
    folium.Marker([lat, lon], icon=folium.Icon(color='red')).add_child(folium.Popup(name)).add_to(m)

Output:

enter image description here

korvinos
  • 509
  • 3
  • 7