Point
Quick answer
L.point stores a pixel coordinate with x growing right and y growing down, carrying no geographic meaning at all. Layers, panes and mouse handlers exchange Point values, and its arithmetic methods return new objects so chained calls stay safe. The optional round flag snaps both components at construction time.
L.point( x , y , round ?) → Point
Key points
- All arithmetic methods return new points, so p.add(q).round leaves p untouched.
- round, floor, ceil and trunc snap coordinates for sharp pixel alignment.
- latLngToLayerPoint converts geographic positions into points for offset math.
Example
var latlng = L.latLng(39.907359, 116.391263);
/* 图层像素坐标,随缩放变化 */
var p = map.latLngToLayerPoint(latlng);
var labelPos = p.add(L.point(16, -16));
var label = L.marker(map.layerPointToLatLng(labelPos), {
icon: L.divIcon({ className: 'poi-label', html: '站点 A' })
}).addTo(map);
Notes
- contains compares component magnitudes and is not a rectangle containment test.
- Caching pixel points across zoom changes misplaces labels after the view moves.
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Atlaslog (2026). Point. https://www.jingweizhi.com/en/leaflet/api/point.html (accessed 2026-11-03).