Get the bounding box of the visible leaflet map?

bernie2436 picture bernie2436 · Apr 8, 2014 · Viewed 37.6k times · Source

I have a leaflet map that pans and zooms. How can I dynamically get the lat/long of the edges of the map (after zooming in/out + panning)?

Answer

tmcw picture tmcw · Apr 9, 2014

It is, as you may guess:

map.getBounds();

If you want to get the bounds after panning and zooming, use events, like

map.on('moveend', function() { 
     alert(map.getBounds());
});