-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
I am making a folium map where I have some CircleMarker.
These CircleMarkers are based on GPS(latitude,longitude).
I already know how to make popup. But I want to add onClick event to CircleMarker.
The reason to add onClick event to CircleMarker is: I want to display the data hold by each CircleMarker in a separate HTML div.
Note: The CircleMarker are based on data from dataframe.
import folium
from branca.element import Element
m = folium.Map(location=[lat,lon],zoom_start=15,control_scale=True)
mk =folium.CircleMarker(location=[lat,long],
radius=7,fill=True,
opacity=0.8,fill_opacity=1).add_to(m)
map_id = m.get_name()
my_js = '''
onclick = function(){ console.log('I am clicked'); }
}
'''
mk.get_root().script.add_child(Element(my_js))
m.save('mymap.html')
If I click on the map I get the output 'I am clicked'.
What I need is that I want to get the output in console when I click CircleMarker.