Skip to content

Instantly share code, notes, and snippets.

@SpencerCooley
Created April 26, 2012 00:57
Show Gist options
  • Save SpencerCooley/2494913 to your computer and use it in GitHub Desktop.
Save SpencerCooley/2494913 to your computer and use it in GitHub Desktop.
function enableClick(){
map.on('click', function(e) {
var marker = new L.Marker(e.latlng, {draggable:true});
map.addLayer(marker);
});//closes the click function
if(map.hasEventListeners('click') == true){
alert('map still has an event listener');
}
else{
alert('map has no event listener');
}
}
function disableClick(){
map.off('click', function(){
});
if(map.hasEventListeners('click') == true){
alert('map still has an event listener');
}
else{
alert('map has no event listener');
}
}
//when
$('#enable_click').click(function(){
var enable_click = new enableClick()
});
$('#disable_click').click(function(){
var disable_click = new disableClick();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment