Atlaslog
Atlaslog / Leaflet / API reference / Control.Scale
Leaflet · API reference

Control.Scale

Quick answer

L.control.scale displays a scale bar computed from ground distance along the horizontal center line at the current zoom. It supports metric and imperial units and recalculates automatically whenever the map moves or zooms. Position, maximum bar width and idle updating are all configurable.

Last verified 2026-11-03 · Leaflet 1.9.4 · Cite this page
L.control.scale( options ) → Control.Scale
Key points
Example
var scale = L.control.scale({
  position: 'bottomleft',
  maxWidth: 120,
  metric: true,
  imperial: false,
  updateWhenIdle: false
}).addTo(map);

/* 同时显示公制与英制会撑成两行 */
L.control.scale({ maxWidth: 90, imperial: true }).addTo(map);

/* 比例尺文字随地图缩放自动重算,监听 zoomend 只用于读取 */
map.on('zoomend', function () {
  console.log(map.getZoom(), scale.getContainer().textContent.trim());
});
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). Control.Scale. https://www.jingweizhi.com/en/leaflet/api/control-scale.html (accessed 2026-11-03).