I make some circles in JS
as follow:
L.circle(
[46.765735535841024, 23.58344078063965], 5, {
color: "blue"
}).addTo(map).bindPopup("Description: This is my description");
I want to replace that bindPopup
with a function. When I click the circle, instead of my description display, I want to run a function, for example I made this function:
function circleClick() {
// my implementations;
}
Would someone tell me how could I do this possible?
Best Answer
Simply assign your
circleClick
function as listener on each of your circles:Alternatively, you can gather all your circles within a Feature Group, and attach the event listener to that group only: