Reputation: 20342
I am trying to get a tooltip and/or a popup to show on a map. When I zoom in, this is all that I see.
Here is the code that I am testing.
import folium
import requests
from xml.etree import ElementTree
from folium import plugins
m = folium.Map(location=[40.6976701, -74.2598704], zoom_start=10)
m.save('path')
for lat,lon,name,tip in zip(df_final['Latitude(DecDeg)'], df_final['Latitude(DecDeg)'], df_final['Market Description'], df_final['Project Description']):
folium.Marker(location=[lat,lon], tooltip = tip, popup = name)
m.add_child(cluster)
m
I feel like I'm missing a library, or some such thing. Any idea why this is not working correctly?
Upvotes: 7
Views: 12077
Reputation: 143001
It seems you forgot to use .add_to(m)
to add it to map
folium.Marker(...).add_to(m)
or
marker = folium.Marker(...)
marker.add_to(m)
Minimal working code:
import folium
import webbrowser # open file in webbrowser
m = folium.Map(location=[40.6976701, -74.2598704], zoom_start=10)
marker = folium.Marker(location=[40.6976701, -74.2598704],
tooltip='<b>Stackoverflow</b><br><br>2021.01.01',
popup='<h1>Happy New Year!</h1><br><br>www: <a href="https://stackoverflow.com">Stackoverflow.com</a><br><br>date: 2021.01.01')
marker.add_to(m)
m.save('map.html')
webbrowser.open('map.html') # open file in webbrowser
Upvotes: 9