Maps Web SDK

Class LocaleService

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"])

Sets locale used by a service instance.

Fires the event LocaleService.Events.LOCALE_CHANGED.

Parameters
Name Description Required Type/Values Default
locale String (with language code) or Locale instance No String | Locale "en-GB"

Events

LocaleService.Events.LOCALE_CHANGED

Fired after the locale was changed.