Atlaslog
Atlaslog / Leaflet / API reference / Tooltip
Leaflet · API reference

Tooltip

Quick answer

L.tooltip shows a lightweight label anchored to a layer or coordinate, without a close button and without panning the map. Permanent tooltips label features in place, while sticky ones follow the cursor to report live positions. It also exposes setLatLng and setContent for runtime updates without rebinding.

Last verified 2026-11-03 · Leaflet 1.9.4 · Cite this page
L.tooltip( options , source ?) → Tooltip
Key points
Example
var marker = L.marker([39.907359, 116.391263]).addTo(map);

marker.bindTooltip('天安门 · 客流 2.4 万/日', {
  direction: 'top',
  offset: [0, -14],
  opacity: 1
});

/* 常驻提示:适合标注名称,不需要鼠标悬停 */
L.circleMarker([39.9147, 116.4106], { radius: 6, fillOpacity: 0.9 })
  .bindTooltip('王府井', { permanent: true, direction: 'right', className: 'label-fixed' })
  .addTo(map);

/* 跟随鼠标的要素提示 */
map.on('mousemove', function (e) {
  tip.setLatLng(e.latlng).setContent(e.latlng.lat.toFixed(4) + ', ' + e.latlng.lng.toFixed(4));
});
var tip = L.tooltip({ sticky: true }).openOn(map);
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). Tooltip. https://www.jingweizhi.com/en/leaflet/api/tooltip.html (accessed 2026-11-03).