Class: ScaleLine

ol/control/ScaleLine~ScaleLine


import ScaleLine from 'ol/control/ScaleLine';

A control displaying rough y-axis distances, calculated for the center of the viewport. For conformal projections (e.g. EPSG:3857, the default view projection in OpenLayers), the scale is valid for all directions. No scale line will be shown when the y-axis distance of a pixel at the viewport center cannot be calculated in the view projection. By default the scale line will show in the bottom left portion of the map, but this can be changed by using the css selector .ol-scale-line.

new ScaleLine(opt_options)

control/ScaleLine.js, line 63
Name Type Description
options

Scale line options.

Name Type Default Description
className string 'ol-scale-line'

CSS Class name.

minWidth number 64

Minimum width in pixels.

render function

Function called when the control should be re-rendered. This is called in a requestAnimationFrame callback.

target HTMLElement | string

Specify a target if you want the control to be rendered outside of the map's viewport.

units module:ol/control/ScaleLine~Units | string 'metric'

Units.

Methods

getUnits(){module:ol/control/ScaleLine~Units|undefined}

control/ScaleLine.js, line 136

Return the units to use in the scale line.

Returns:
The units to use in the scale line.

setUnits(units)

control/ScaleLine.js, line 155

Set the units to use in the scale line.

Name Type Description
units module:ol/control/ScaleLine~Units

The units to use in the scale line.