×
Namespaces

Variants
Actions
(Difference between revisions)

HERE Maps API - Reading and displaying Map Features

From Nokia Developer Wiki
Jump to: navigation, search
Maveric (Talk | contribs)
m (Maveric - - Example code)
jasfox (Talk | contribs)
m (Jasfox - update to 2.2.4)
(14 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Category:Ovi]][[Category:Web]][[Category:Browser]]
+
[[Category:Browser]][[Category:Nokia Maps]][[Category:JavaScript]][[Category:Code Snippet]]
{{Abstract|This article features and example on how to read and display plus load Map Features }}  
+
{{ArticleMetaData
 +
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= Google Chrome 20.0 x, Firefox 13.0
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies= Nokia Maps 2.2.4
 +
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= Nokia Maps, JavaScript, features
 +
|id= <!-- Article Id (Knowledge base articles only) -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by=<!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= [[User:avnee.nathani]]
 +
|update-timestamp= 20120118
 +
|creationdate=20110627
 +
|author=[[User:Maveric]]
 +
}}
 +
 
 +
 
 +
{{Abstract|This article features an example on how to read, display and load Map {{Icode|Features}} }}  
  
 
== Introduction ==
 
== Introduction ==
  
This example uses the Ovi Maps API Feature manipulation functionality, described in the API Reference here:
+
This example uses the Nokia Maps API {{Icode|Feature}} manipulation functionality, described in the API Reference here:
  
http://api.maps.ovi.com/apireference/symbols/ovi.mapsapi.Features.html?s=Features
+
http://developer.here.net/docs/maps_js/topics_api_pub/nokia.Features.html
  
 
Please check it out for detailed description on the subject.
 
Please check it out for detailed description on the subject.
 
  
 
== Prerequisites ==
 
== Prerequisites ==
  
Ovi Maps API supported web browser (basically any modern web browser will do).
+
Nokia Maps API supported web browser (basically any modern web browser will do).
  
  
 
== Example code ==
 
== Example code ==
  
This example loops thru and displays the all supported features/sets and features of the current map. Then it also
+
This example loops through and displays all supported features/sets and features of the current map. It also
 
attempts to load features and handles success and failure, and in this example the load should be a success.
 
attempts to load features and handles success and failure, and in this example the load should be a success.
  
<code java>
+
<code javascript>
<html>
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
+
<html xmlns="http://www.w3.org/1999/xhtml">
<script src="http://api.maps.ovi.com/jsl.js" type="text/javascript" charset="utf-8"></script>
+
    <head>
</head>
+
      <title>Map Features</title>
<body>
+
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<center>
+
      <script type="text/javascript"
<div id="map" style="width:80%; height:80%"></div>
+
            src="http://api.maps.nokia.com/2.2.4/jsl.js" charset="utf-8">
</center>
+
        </script>
<p>
+
    </head>
<script type="text/javascript"><!--
+
    <body>
  
// This example will display first the full Feature Map components and then of those what
+
        <div id="mapContainer" style="z-index: -1; left:0px; top:0px; width: 100%; height: 80%; position: absolute;"></div>
// are being used in the current map that is loaded and in use.
+
        <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 http://api.developer.nokia.com/
 +
//
 +
nokia.Settings.set( "appId", "YOUR APP ID GOES HERE");
 +
nokia.Settings.set( "authenticationToken", "YOUR AUTHENTICATION TOKEN GOES HERE");
  
var map;
+
//
 +
/////////////////////////////////////////////////////////////////////////////////////
  
map = new ovi.mapsapi.map.Display(document.getElementById("map"),  
+
// This example will first display the full Feature Map components and then of those what
 +
// are being used in the current map that is loaded and in use.
 +
 +
var map;
 +
map = new nokia.maps.map.Display(document.getElementById("mapContainer"),
 
     {
 
     {
                   components: [ new ovi.mapsapi.map.component.Behavior(),
+
                   components: [ new nokia.maps.map.component.Behavior(),
                             new ovi.mapsapi.map.component.ZoomBar(),
+
                             new nokia.maps.map.component.ZoomBar(),
                             new ovi.mapsapi.map.component.Overview(),                             
+
                             new nokia.maps.map.component.Overview(),                             
                             new ovi.mapsapi.map.component.TypeSelector(),     
+
                             new nokia.maps.map.component.TypeSelector(),     
                             new ovi.mapsapi.map.component.ScaleBar() ],
+
                             new nokia.maps.map.component.ScaleBar() ],
 
                   zoomLevel: 4,  
 
                   zoomLevel: 4,  
 
                   center: [52.51, 13.4]  // default map center point (not the location retrieved)
 
                   center: [52.51, 13.4]  // default map center point (not the location retrieved)
 
   
 
   
 
     });
 
     });
   
+
 
     //Retrieve Feature Map
 
     //Retrieve Feature Map
   
+
     var list = ovi.mapsapi.Features.getFeatureMap();  
+
     var list = nokia.maps.Features.getFeatureMap();  
   
+
     // Loop thru the features and show them in an alert
+
     // Loop through the features and show them in an alert
     // Returns a map of registered feature implementation names per feature.  
+
     // Returns a map of implementations for each registered feature.  
   
+
 
     for( var i in list )  
 
     for( var i in list )  
 
     { if ( list.hasOwnProperty(i) )  
 
     { if ( list.hasOwnProperty(i) )  
 
     alert("Feature Map: "+list[i]);  
 
     alert("Feature Map: "+list[i]);  
 
     }
 
     }
 
+
 
     // Retrieve Loaded Map
 
     // Retrieve Loaded Map
   
+
     var list = ovi.mapsapi.Features.getLoadedMap();  
+
     var list = nokia.maps.Features.getLoadedMap();  
   
+
     // Loop thru the features and show them in an alert
+
     // Loop through the features and show them in an alert
 
     // Returns a map of the names of fully loaded feature implementations per feature.  
 
     // Returns a map of the names of fully loaded feature implementations per feature.  
   
+
   
+
 
     for( var i in list )  
 
     for( var i in list )  
 
     { if ( list.hasOwnProperty(i) )  
 
     { if ( list.hasOwnProperty(i) )  
Line 75: Line 112:
 
     }
 
     }
 
   
 
   
    // Let's try add routing feature, it's not implemented in this example:
+
    nokia.maps.Features.load({"map": "auto", "routing": "auto"}, load_Successful, load_Failed);
   
+
     ovi.mapsapi.Features.load({"map": "auto", "search": "auto"}, load_Successful, load_Failed);  
+
     nokia.maps.Features.load({"map": "auto", "search": "auto"}, load_Successful, load_Failed);  
 
+
 
+
 
     function load_Successful(result){
 
     function load_Successful(result){
 
       alert("SUCCESSFUL FEATURE LOADING");
 
       alert("SUCCESSFUL FEATURE LOADING");
 
     }
 
     }
   
+
 
     function load_Failed(result){
 
     function load_Failed(result){
 
       alert("FEATURE LOADING FAILED");
 
       alert("FEATURE LOADING FAILED");
 
     }
 
     }
// --></script>
+
</script>
</p>
+
 
</body>
 
</body>
 
</html>
 
</html>
 
 
</code>
 
</code>
 
  
 
== Summary ==
 
== Summary ==
Line 99: Line 132:
 
Feel free to modify the code for your own purposes.
 
Feel free to modify the code for your own purposes.
  
== Tested with ==
+
==For more on the Nokia Maps API==
  
Windows XP Pro
+
Please check out the Nokia Maps API full documentation and API reference here:
 +
* [http://developer.here.net/javascript_api Nokia Maps API]
  
Safari 5.0.5
+
You may also access the interactive API explorer
 +
* [http://developer.here.net/javascript_api_explorer API explorer]
 +
 
 +
== Tested with ==
  
Firefox 5.0
+
* Google Chrome 20.0 x
 +
* Firefox 13.0

Revision as of 14:34, 14 March 2013

Article Metadata
Tested with
Devices(s): Google Chrome 20.0 x, Firefox 13.0
Dependencies: Nokia Maps 2.2.4
Article
Keywords: Nokia Maps, JavaScript, features
Created: Maveric (27 Jun 2011)
Updated: avnee.nathani (18 Jan 2012)
Last edited: jasfox (14 Mar 2013)


This article features an example on how to read, display and load Map Features

Contents

Introduction

This example uses the Nokia Maps API Feature manipulation functionality, described in the API Reference here:

http://developer.here.net/docs/maps_js/topics_api_pub/nokia.Features.html

Please check it out for detailed description on the subject.

Prerequisites

Nokia Maps API supported web browser (basically any modern web browser will do).


Example code

This example loops through and displays all supported features/sets and features of the current map. It also attempts to load features and handles success and failure, and in this example the load should be a success.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Map Features</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript"
src="http://api.maps.nokia.com/2.2.4/jsl.js" charset="utf-8">
</script>
</head>
<body>
 
<div id="mapContainer" style="z-index: -1; left:0px; top:0px; width: 100%; height: 80%; position: absolute;"></div>
<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 http://api.developer.nokia.com/
//
nokia.Settings.set( "appId", "YOUR APP ID GOES HERE");
nokia.Settings.set( "authenticationToken", "YOUR AUTHENTICATION TOKEN GOES HERE");
 
//
/////////////////////////////////////////////////////////////////////////////////////
 
// This example will first display the full Feature Map components and then of those what
// are being used in the current map that is loaded and in use.
 
var map;
map = new nokia.maps.map.Display(document.getElementById("mapContainer"),
{
components: [ new nokia.maps.map.component.Behavior(),
new nokia.maps.map.component.ZoomBar(),
new nokia.maps.map.component.Overview(),
new nokia.maps.map.component.TypeSelector(),
new nokia.maps.map.component.ScaleBar() ],
zoomLevel: 4,
center: [52.51, 13.4] // default map center point (not the location retrieved)
 
});
 
//Retrieve Feature Map
 
var list = nokia.maps.Features.getFeatureMap();
 
// Loop through the features and show them in an alert
// Returns a map of implementations for each registered feature.
 
for( var i in list )
{ if ( list.hasOwnProperty(i) )
alert("Feature Map: "+list[i]);
}
 
// Retrieve Loaded Map
 
var list = nokia.maps.Features.getLoadedMap();
 
// Loop through the features and show them in an alert
// Returns a map of the names of fully loaded feature implementations per feature.
 
 
for( var i in list )
{ if ( list.hasOwnProperty(i) )
alert("Loaded Map:" +list[i]);
}
 
nokia.maps.Features.load({"map": "auto", "routing": "auto"}, load_Successful, load_Failed);
 
nokia.maps.Features.load({"map": "auto", "search": "auto"}, load_Successful, load_Failed);
 
function load_Successful(result){
alert("SUCCESSFUL FEATURE LOADING");
}
 
function load_Failed(result){
alert("FEATURE LOADING FAILED");
}
</script>
</body>
</html>

Summary

Feel free to modify the code for your own purposes.

For more on the Nokia Maps API

Please check out the Nokia Maps API full documentation and API reference here:

You may also access the interactive API explorer

Tested with

  • Google Chrome 20.0 x
  • Firefox 13.0
83 page views in the last 30 days.
×