The Evented section of the Leaflet documentation shows how to set an event listener for the map object:

Leaflet deals with event listeners by reference, so if you want to add a listener and then remove it, define it as a function:

function onClick(e) { ... }
map.on('click', onClick);
map.off('click', onClick);

In my application, there are various functions which may run on a map click event, depending on which mode the application is in (along the lines of having an "active tool" mode).

How can I determine which function is currently set as the map's on click event?

For example, if the line map.on('click', xyz) has been run, I would like to know that the current on click function is called xyz. And if map.off('click', xyz) has been run and there is no current click event I would like to know this.

1 Answer 1


There is a property ._events on the map which can be used to determine the presence of any event listeners:

map._events.click.length shows the number of listeners for the click event.

map._events.click[0].fn provides details of the first function that has been set to run on click, including its name via map._events.click[0].fn.name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.