Home

Awesome

Leaflet.Nanoscale

Leaflet.Nanoscale is a sub-millimeter scale indicator for Leaflet. It displays a scale in nanometers, micrometers or millimeters, calculating it from a known ratio of absolute pixels (i.e. pixels at maximum zoom) to nanometers.

Screenshot

Screenshot

Usage

Include the script:

<script type="text/javascript" src="Leaflet.Nanoscale/Control.Nanoscale.js"></script>

Add the control to the map:

L.control.nanoscale({
  nanometersPerPixel: scale,
}).addTo(map);

Options

OptionTypeDefaultDescription
nanometersPerPixelNumber1000The ratio between pixels at known zoom and nanometers.
ratioAtZoomNumbermap.getMaxZoom()The zoom level used for translating pixels to distances.
positionString'topright'The position of the control (one of the map corners). See control positions.
maxWidthNumber100Maximum width of the control in pixels. The width is set dynamically to show round values (e.g. 100, 200, 500).
updateWhenIdleBooleanfalseIf true, the control is updated on moveend, otherwise it's always up-to-date (updated on move).

License

MIT license