how to map.off my events

21 views
Skip to first unread message

fofofo

unread,
Dec 7, 2017, 2:50:26 PM12/7/17
to Leaflet
hi ,

here is my map.on event :

 
   
function test(e ,ee ) {
    console
.log(ee);
   
}
     
    map
.on("mousemove",  function(e){ test(e,"zzzz")} );
   
     

I dont know how to remove my event , how to do ?

Thx

Linus Kamb

unread,
Jan 19, 2018, 5:49:52 PM1/19/18
to Leaflet
from the documentation:


Usage example

map.on('click', function(e) {
    alert(e.latlng);
} );

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);
Reply all
Reply to author
Forward
0 new messages