Maps Web SDK
Class LocaleService
Extends | L.Evented |
Category | Services |
Service for store and retrieve an specific locale setting.
This service is used by map instances, widgets and services to store their locale configuration.
If its constructor receive a LocaleService 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
LocaleService([parent])
Parameters
Name | Description | Required | Type/Values | Default |
---|---|---|---|---|
parent | If is defined makes the new instance a "slave" of the given instance | No | LocaleService | None |
Example
// Will use the global LocaleService
// You can obtain the global LocaleService calling tomtom.globalLocaleService()
tomtom.nearbySearch()
.go()
// Will ignore the global LocaleService and use the provided language
tomtom.nearbySearch()
.language('pl-PL')
.go();
// Example how to use locales which are set per map instance
var mapLanguage = mapInstance.getLocaleService().getCurrentLocale();
tomtom.nearbySearch()
.language(mapLanguage)
.go();
Methods
getCurrentLocale( ): Locale
Returns the current locale.
Returns
LocaleService.getLocalesFor([serviceType=null]): Locale[]
Static method that returns an array with the supported locales which are supported by given service type.
Parameters
Name | Description | Required | Type/Values | Default |
---|---|---|---|---|
serviceType | No | "traffic" | "routing" | "search" | "maps" | null |
Returns
setCurrentLocale([locale="en-GB"])
Events
To learn more about how to listen events please refer to
this documentation.
LocaleService.Events.LOCALE_CHANGED
Fired after the locale was changed.