Atlaslog
Atlaslog / Leaflet / API reference / LatLngBounds
Leaflet · API reference

LatLngBounds

Quick answer

L.latLngBounds defines an axis-aligned geographic rectangle from a south-west and north-east corner, powering fitBounds, containment tests and WMS bounding box strings. It can also absorb many points into a single extent through repeated extend calls. Corners may be passed in either order because the constructor normalizes them.

Last verified 2026-11-03 · Leaflet 1.9.4 · Cite this page
L.latLngBounds( corner1 , corner2 ) → LatLngBounds
Key points
Example
var pts = [
  [39.907359, 116.391263],
  [39.934, 116.432],
  [39.881, 116.355]
];

var bounds = L.latLngBounds(pts);

map.fitBounds(bounds, {
  padding: [24, 24],
  maxZoom: 15
});
var extent = L.latLngBounds();

geojson.features.forEach(function (feature) {
  L.geoJSON(feature).getLayers().forEach(function (layer) {
    if (layer.getBounds) {
      extent.extend(layer.getBounds());
    }
  });
});

console.log(extent.toBBoxString());
Notes
Runnable examplesChinese originalAll API references
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). LatLngBounds. https://www.jingweizhi.com/en/leaflet/api/latlng-bounds.html (accessed 2026-11-03).