Search code examples
leaflet

Get the bounding box of the visible leaflet map?


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)?


Solution

  • 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());
    });