Atlaslog
Atlaslog / Leaflet / API reference / LatLng
Leaflet · API reference

LatLng

Quick answer

L.latLng represents a geographic coordinate with lat, lng and an optional alt, and nearly every position argument in Leaflet is normalized into it. Construct it from two numbers, an array or a plain object depending on where the data comes from.

Last verified 2026-11-03 · Leaflet 1.9.4 · Cite this page
L.latLng( lat , lng , alt? ) → LatLng
Key points
Example
var a = L.latLng(39.907359, 116.391263);
var b = L.latLng(39.914700, 116.410600);

console.log(a.distanceTo(b));        // 约 2360 米
console.log(a.toBounds(1000));       // 边长约 1 km 的矩形
console.log(L.latLng(10, 190).wrap()); // 经度折回 -170
var bounds = L.latLngBounds([[39.88, 116.30], [39.95, 116.48]]);
bounds.extend([40.00, 116.55]);

map.fitBounds(bounds, { padding: [20, 20] });

console.log(bounds.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). LatLng. https://www.jingweizhi.com/en/leaflet/api/latlng.html (accessed 2026-11-03).