Leaflet - bug with twice event handling - leaflet 0.8 dev
by Leo
HTML
<script src="//rawgit.com/gorshkov-leonid/Leaflet/master/dist/leaflet-src.js"></script>
<link rel="stylesheet" href="//rawgit.com/gorshkov-leonid/Leaflet/master/dist/leaflet.css">
<body>
<div id="map" ></div>
</body>
CSS
html, body, #map {
margin: 0;
width: 100%;
height: 100%;
}
JavaScript
var map = new L.Map('map', {
center: new L.LatLng(45.5 + 0.003,-73.5 + 0.003),
zoom: 16
});
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'}).addTo(map);
var polygon = L.polygon(
[[45.5 ,-73.5],
[45.5 + 0.005,-73.5],
[45.5 + 0.005,-73.5 + 0.005],
[45.5 ,-73.5 + 0.005]],
{
fillColor: 'red',
fillOpacity: 1
});
var marker = L.marker(
new L.LatLng(45.5 + 0.003,-73.5 + 0.003)
);
map.addLayer(polygon);
map.addLayer(marker);
map.addEventListener('click', function(e){ console.log("map " + e.target); })
marker.addEventListener('click', function(e){ console.log("marker "+ e.target); })
polygon.addEventListener('click', function(e){ console.log("polygon " + e.target); })