4
votes

Here is my code.

function onMapClick(e) {
    e.originalEvent.defaultPrevented = true;
    var orig = e.originalEvent;
    console.log(orig.target);
}
map.on('click', onMapClick);

console.log will show the tile i.e

<img class="leaflet-tile leaflet-tile-loaded" ... />

But i could not able to find the tile when I use leaflet marker cluster. How to get the tile in leaflet marker cluster with map click event?

1

1 Answers

2
votes

Best way to get tile is to calculate it from coordinates. There are many calculating implementations on OpenStreetMap wiki.

Here you have working example in JSFiddle. Just use it in map.on event method:

map.on('click', function(e) {
 console.log(getTileURL(e.latlng.lat, e.latlng.lng, map.getZoom()));
});