Maps SDK for Web
Class UnitFormatConverter
Static class with util methods to format and convert values from metric to imperial systems.
Methods
convertMetersToYards(distanceMeters): Number
Convert a distance in meters to yards.
Parameters
Name | Description | Required | Type/Values | Default |
---|---|---|---|---|
distanceMeters | Yes | Number | None |
Returns
convertYardsToMeters(distanceYards): Number
Convert a distance in yards to meters.
Parameters
Name | Description | Required | Type/Values | Default |
---|---|---|---|---|
distanceYards | Distance in yards | Yes | Number | None |
Returns
formatDistance(distanceMeters, [imperial=false]): String
formatHourAndMinute([dateInMs]): String
Converts a date in the machine format to a more human readable form.
Returns a formatted string created from the given date in UTC format.
Parameters
Name | Description | Required | Type/Values | Default |
---|---|---|---|---|
dateInMs | Date and time specified in the RFC-3339 format with an optional time zone offset | No | String | None |
Returns
Formatted time in hours and minutes
Example
tomtom.unitFormatConverter.formatHourAndMinute('2016-03-01T15:45:58+01:00') // gives '3:45'
formatTime([seconds]): String | Undefined
Converts the given time in seconds to a string with the the format of 'HH h MM min' or 'MM min SS s'.
HH - hours MM - minutes SS - seconds.
Parameters
Name | Description | Required | Type/Values | Default |
---|---|---|---|---|
seconds | Number of seconds | No | Number | None |
Returns
Formatted time
Example
tomtom.unitFormatConverter.formatTime(3600); / returns 1 h 0 min
unitsScheme([newUnit]): String Deprecated
Gets ore sets the default units scheme for new widgets and services.
Parameters
Name | Description | Required | Type/Values | Default |
---|---|---|---|---|
newUnit | If isn't provided then this method will only return then current units scheme | No | "imperial" | "metric" | None |
Returns
Current units scheme
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.
change
Properties
Name | Description | Type/Values | Default |
---|---|---|---|
newMeasurementUnit | "metric" | "imperial" | None |