Maps Web SDK

Class UnitService

Service for store and retrieve an specific unit measurement.

This service is used by map instances, widgets and services to store their unit measurement configuration.

If its constructor receive a UnitService instance as argument it will start listen changes in the given instance and apply the same change in its own. That behavior allows the instances of this class to be updated in cascade.

Constructor

UnitService([parent])

Parameters
Name Description Required Type/Values Default
parent If is defined makes the new instance a "slave" of the given instance No UnitService None

Methods

getCurrentUnit( ): Unit

Gets currently setted unit.

Returns

setCurrentUnit([unit="metric"])

Sets a new measurement unit.

Fires the event UnitService.Events.UNIT_CHANGED.

Parameters
Name Description Required Type/Values Default
unit accepts a string (metric, imperial) or a Unit instance No String | Unit "metric"

UnitService.getSupportedUnits( ): Unit[]

Static method that returns an array with the supported units.

Returns

Events

UnitService.Events.UNIT_CHANGED

Fired after the unit is set.