Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

(Difference between revisions)

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

From Wiki
Jump to: navigation, search
jasfox (Talk | contribs)
m (Jasfox - - Important about Maps credentials)
jasfox (Talk | contribs)
m (Jasfox - - Implementation)
Line 37: Line 37:
This is a full HTML & JavaScript example.  Add in your own [ AppId and Token] and feel free to modify and use for your own purposes.
This is a full HTML & JavaScript example.  Add in your own [[How to Obtain Your Own Nokia appID and Token| AppId and Token]] and feel free to modify and use for your own purposes.
<code javascript>
<code javascript>

Revision as of 11:12, 4 January 2013

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

Article Metadata
Tested with
Devices(s): Internet Explorer, Google Chrome, Firefox, Opera
Platform(s): Web browsers
Dependencies: Nokia Maps 2.2.3
Keywords: Nokia Maps, JavaScript, default language
Created: Maveric (25 Oct 2011)
Last edited: jasfox (04 Jan 2013)


Nokia 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


This is a full HTML & JavaScript example. Add in your own AppId and Token and feel free to modify and use for your own purposes.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="">
<meta http-equiv="content-type" content=
"text/html; charset=us-ascii" />
<meta http-equiv="X-UA-Compatible" content="IE=7; IE=EmulateIE9" />
<title>Setting the map language</title>
<!-- This file loads up a map of Europe and displays it in a variety of languages. -->
<!-- No additional support is required here, just load basic capabilities -->
<script type="text/javascript" charset="UTF-8" src=""></script>
<div id="mapContainer" style=
"z-index: -1; left:0px; top:0px; width: 50%; height: 50%; position: absolute;">
<script type="text/javascript">
// Don't forget to set your API credentials
// Replace with your appId and token which you can obtain when you
// register on
nokia.Settings.set( "appId", "YOUR APP ID GOES HERE");
nokia.Settings.set( "authenticationToken", "YOUR AUTHENTICATION TOKEN GOES HERE");
<script type="text/javascript">
var appContext = nokia.maps.util.ApplicationContext;
// Go thru all the language options
var availableLanguages = ["en-US", "en-GB", "de-DE", "es-ES", "fr-FR", "it-IT", "ru-RU", "zh-CN"]
//get a random language
var randomLanguageIndex = Math.floor(Math.random() * availableLanguages.length); var randomLanguage = availableLanguages[randomLanguageIndex];
// Get and store the current map default language
var currentLanguage = appContext.get("defaultLanguage");
// Display a note to the user within the document
document.write("The Initial Default Language is " + currentLanguage);
// Write line break
document.write("<br />");
// Set the default language of the map
appContext.set("defaultLanguage", randomLanguage);
// Get the language we have just set
currentLanguage = appContext.get("defaultLanguage");
// Write the new language
document.write("Now the Default Language is " + currentLanguage);
// Get the DOM node to which we will append the map
var mapContainer = document.getElementById("mapContainer");
// Define the Nokia Maps
var map = new, {
// initial center and zoom level of the map
center: [53.1, 13.1],
zoomLevel: 4,
components: [
new nokia.maps.positioning.component.Positioning()
105 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.