Maps SDK for Web
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"])
UnitService.getSupportedUnits( ): Unit[] Static
Static method that returns an array with the supported units.
Returns
Events
All the class events are keys of the Events static member.
To learn more about how to listen events please refer to this documentation.
UNIT_CHANGED : String
Example
var unitService = new UnitService();
unitService.on(L.UnitService.Events.UNIT_CHANGED, function(eventData) {
console.log(eventData);
});