Atlaslog
Atlaslog / Leaflet / API reference / DomUtil
Leaflet · API reference

DomUtil

Quick answer

L.DomUtil provides framework-free helpers for creating elements, toggling class names, setting opacity and positioning children inside map panes. It is the toolkit Leaflet uses internally, and custom overlays rely on it to stay in sync with map translation. Class helpers cover adding, removing and replacing class names.

Last verified 2026-11-03 · Leaflet 1.9.4 · Cite this page
L.DomUtil.get( id ) → HTMLElement
Key points
Example
var pane = map.getPane('overlayPane');

var badge = L.DomUtil.create('div', 'count-badge', pane);
badge.textContent = '12 个要素';

L.DomUtil.setPosition(badge, L.point(12, 12));
L.DomUtil.setOpacity(badge, 0.85);
.count-badge {
  position: absolute;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(18, 24, 38, 0.82);
  color: #fff;
  font-size: 12px;
}
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). DomUtil. https://www.jingweizhi.com/en/leaflet/api/dom-util.html (accessed 2026-11-03).