×
Namespaces

Variants
Actions
(Difference between revisions)

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

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Automated change of category from Ovi Maps to Nokia Maps)
hamishwillee (Talk | contribs)
m (Hamishwillee - Add dependencies field to ArticleMetaData)
Line 1: Line 1:
 
[[Category:Code Examples]][[Category:Web]][[Category:Nokia Maps]]
 
[[Category:Code Examples]][[Category:Web]][[Category:Nokia Maps]]
 +
{{Abstract|This articles shows how to get and set the default language in application context.  }}
 
{{ArticleMetaData
 
{{ArticleMetaData
 
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
Line 7: Line 8:
 
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
+
|dependencies=Nokia Maps 2.1.0
 
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 
|capabilities=<!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 
|capabilities=<!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
Line 20: Line 21:
 
|author=[[User:Maveric]]
 
|author=[[User:Maveric]]
 
}}
 
}}
==Introduction== 
 
 
Nokia Maps API - Getting and setting the default language in application context. 
 
  
 
==Prerequisites==   
 
==Prerequisites==   

Revision as of 02:36, 2 January 2012

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

Article Metadata
Dependencies: Nokia Maps 2.1.0
Article
Created: Maveric (25 Oct 2011)
Last edited: hamishwillee (02 Jan 2012)

Contents

Prerequisites

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

Important about Maps credentials

With Nokia Maps API you can start without having any credentials given, but you might face a performance gap. In order to get the full potential out of the offering, you must get the credentials that authenticate your application against the Services. Please read through the Location API. For more information on how to obtain the credentials, please start with the Nokia Maps API Developers Guide section "Acquiring API credentials".

Implementation

This is a full HTML & JavaScript example. Feel free to modify and use for your own purposes.


<html> 
<head>
<script src="http://api.maps.ovi.com/jsl.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="style.css" />
</head>
<div id="map" style="width:100%; height:80%;"></div>
<body style = "width:80%; height:80%;"></div>
</body>
<script type="text/javascript">
// Define the Nokia Maps
var map= new ovi.mapsapi.map.Display(document.getElementById("map"), // new instance of Nokia Maps {
components: [ new ovi.mapsapi.map.component.Behavior(),
new ovi.mapsapi.map.component.ZoomBar(),
new ovi.mapsapi.map.component.Overview(),
new ovi.mapsapi.map.component.TypeSelector(),
new ovi.mapsapi.map.component.ScaleBar()],
'zoomLevel': 4,
'center':[53.1, 13.1] });
 
var appContext = ovi.mapsapi.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 current 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);
// Write line break document.write("<br />");
</script>
</body>
</html>

Tested with

Mozilla FireFox 8.0 Google Chrome 14.0.835.202 m

258 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.

×