ScaleControl class

A control to display a scale bar on the map.

Extends

Constructors

ScaleControl(ScaleControlOptions)

Constructs a ScaleControl.

Methods

onAdd(Map, ControlOptions)

Initialization method for the control which is called when added to the map.

onRemove()

Method that is called when the control is removed from the map. Should perform any necessary cleanup for the control.

setUnit("imperial" | "metric" | "nautical")

Set the scale's unit of the distance

Inherited Methods

buildContainer<K>(Map, ControlStyle, string, K)

Build the outermost container for the control, applies styling including any listeners for auto styling.

Constructor Details

ScaleControl(ScaleControlOptions)

Constructs a ScaleControl.

new ScaleControl(options?: ScaleControlOptions)

Parameters

options
ScaleControlOptions

The options for the control.

Method Details

onAdd(Map, ControlOptions)

Initialization method for the control which is called when added to the map.

function onAdd(map: Map, options?: ControlOptions): HTMLElement

Parameters

map
Map

The map that the control will be added to.

options
ControlOptions

The ControlOptions for this control.

Returns

HTMLElement

An HTMLElement to be placed on the map for the control.

onRemove()

Method that is called when the control is removed from the map. Should perform any necessary cleanup for the control.

function onRemove()

setUnit("imperial" | "metric" | "nautical")

Set the scale's unit of the distance

function setUnit(unit: "imperial" | "metric" | "nautical")

Parameters

unit

"imperial" | "metric" | "nautical"

Unit of the distance ('imperial', 'metric' or 'nautical').

Inherited Method Details

buildContainer<K>(Map, ControlStyle, string, K)

Build the outermost container for the control, applies styling including any listeners for auto styling.

function buildContainer<K>(map: Map, style: ControlStyle, ariaLabel?: string, tagName?: K): HTMLElementTagNameMap[K]

Parameters

map
Map
style
ControlStyle
ariaLabel

string

tagName

K

Returns

HTMLElementTagNameMap[K]

Inherited From ControlBase.buildContainer