Reputation: 113
I have a problem with a Leaflet map not responding to click events. I add a map using the tutorial code:
var mymap = L.map('mapid').setView([51.505, -0.09], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors',
maxZoom: 19
}).addTo(mymap);
mymap.on('click', function(e) {alert('map click!')});
After this I get a nice responsive map. I can pan and zoom, but it doesnt respond to clicks. What can cause it to not propagate events I register to ?
EDIT: When I add a marker and hover over it the tooltip added using bindTooltip() doesnt show and a popup added using bindPopup() doesnt show when I click on the marker. It is as if the map doesnt propagate mouse events to registered handlers and doesnt respond to hover events.
Upvotes: 0
Views: 906
Reputation: 1172
Maybe your browser blocks alert popup.
Try
mymap.on('click', function (e) { console.log(e) });
Upvotes: 1