Get the bounding box of the visible leaflet map?

前端 未结 2 882
鱼传尺愫
鱼传尺愫 2020-12-28 12:44

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

2条回答
  •  时光说笑
    2020-12-28 13:06

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

提交回复
热议问题