Atlaslog
Atlaslog / Leaflet / API reference / Map Events
Leaflet · API reference

Map Events

Quick answer

The Map event catalog covers view changes, mouse and touch input, layer additions, popups and geolocation, each delivering a typed event object. Listen with map.on, map.once or map.off, then read fields such as latlng, center, layer and originalEvent from the payload.

Last verified 2026-11-03 · Leaflet 1.9.4 · Cite this page
map.on( type , fn , context ?) · map.off(...) · map.once(...) · map.fire(type, data?)
Key points
Example
['click', 'dblclick', 'moveend', 'zoomend', 'layeradd'].forEach(function (name) {
  map.on(name, function (e) {
    console.log(name, e.latlng ? e.latlng.toString() : '', e.layer ? L.Util.stamp(e.layer) : '');
  });
});

/* 只触发一次,适合「地图首次就绪后再加载数据」 */
map.once('load', function () { loadPoints(); });

/* 临时监听,回调里自行摘掉 */
function onFirstMove() {
  console.log('第一次移动结束');
  map.off('moveend', onFirstMove);
}
map.on('moveend', onFirstMove);

/* 主动派发自定义事件 */
map.on('dataset:ready', function (e) { console.log(e.count); });
map.fire('dataset:ready', { count: 128 });
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). Map Events. https://www.jingweizhi.com/en/leaflet/api/map-events.html (accessed 2026-11-03).