×
Namespaces

Variants
Actions

HERE Maps API - getting and setting the default language in application context

From Nokia Developer Wiki
Jump to: navigation, search

This articles shows how to get and set the default language in application context.

Article Metadata
Code Example
Source file: [map-language.html]
Tested with
Devices(s): Internet Explorer, Google Chrome, Firefox, Opera
Compatibility
Platform(s): Web browsers
Dependencies: HERE Maps 2.5.3
Article
Keywords: HERE Maps, JavaScript, default language
Created: Maveric (25 Oct 2011)
Last edited: jasfox (28 Nov 2013)

Prerequisites

HERE Maps API supported web browser (basically any modern web browser)

Important note about maps credentials

Nokia provides several services options within the Maps API offering. The service is free to use, but you must obtain and use authentication and authorization credentials to use the services. Please read the Terms and Conditions and check the Pricing Plans page to decide which business model best fits your needs. Authentication requires unique Maps API credentials, namely an AppId and a token. You can get these credentials free for free following the instructions here

Implementation

The following code displays and alters the map language. Note that the language must be set prior to instantiating the map.

function setMapLanguage(){
var availableLanguages = ["en-US", "en-GB", "de-DE", "es-ES",
"fr-FR", "it-IT", "ru-RU", "zh-CN"] ,
randomLanguageIndex = Math.floor(Math.random() * availableLanguages.length),
randomLanguage = availableLanguages[randomLanguageIndex];
 
$("#initialLangauge").text("The Initial Default Language is " +
nokia.Settings.defaultLanguage);
 
nokia.Settings.set("defaultLanguage", randomLanguage);
$("#currentLanguage").text("Now the Default Language is " +
nokia.Settings.defaultLanguage);
 
 
map = new nokia.maps.map.Display(document.getElementById('mapContainer'), {
center: [53.1, 13.1],
zoomLevel: 4,
components: [
new nokia.maps.map.component.ZoomBar(),
new nokia.maps.map.component.Behavior()
]
});
}

The following fully working example can be found at:

http://rawgithub.com/heremaps/examples/master/maps_api_for_javascript/advanced-examples/map-language.html

This page was last modified on 28 November 2013, at 14:57.
253 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×