Atlaslog
Atlaslog / Leaflet / API reference / Popup
Leaflet · API reference

Popup

Quick answer

L.popup renders a floating panel anchored to a map coordinate, usually opened by a bound layer's click, with a close button and optional auto pan. Standalone popups opened with openOn handle cases such as reporting coordinates for arbitrary map clicks.

Last verified 2026-11-03 · Leaflet 1.9.4 · Cite this page
L.popup( options? , latlng? , content? ) → Popup
Key points
Example
var map = L.map('map', { center: [39.907359, 116.391263], zoom: 13 });

L.marker([39.907359, 116.391263])
  .bindPopup('<b>天安门</b><br>39.907359, 116.391263', {
    maxWidth: 240,
    closeOnClick: true
  })
  .addTo(map);

/* 独立弹窗,不依赖图层 */
var popup = L.popup()
  .setLatLng([39.92, 116.42])
  .setContent('独立弹窗')
  .openOn(map);

map.on('popupopen', function (e) {
  console.log('已打开', e.popup.getLatLng());
});
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). Popup. https://www.jingweizhi.com/en/leaflet/api/popup.html (accessed 2026-11-03).