HERE Maps API - Reading and displaying Map Features
hamishwillee
(Talk | contribs) m (Hamishwillee - Bot addition of Template:ArticleMetaData) |
(Avnee.nathani -) |
||
| Line 1: | Line 1: | ||
| + | [[Category:Web]][[Category:Browser]][[Category:Nokia Maps]][[Category:Code Examples]] | ||
{{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]] --> | ||
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) --> | |installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) --> | ||
| − | |devices= | + | |devices= Google Chrome 11.0 x, Safari 5.0.5, Firefox 5.0 |
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) --> | |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 --> | |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= | + | |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 17: | Line 18: | ||
|review-by=<!-- After re-review: [[User:username]] --> | |review-by=<!-- After re-review: [[User:username]] --> | ||
|review-timestamp= <!-- After re-review: YYYYMMDD --> | |review-timestamp= <!-- After re-review: YYYYMMDD --> | ||
| − | |update-by= | + | |update-by= [[User:avnee.nathani]] |
| − | |update-timestamp= | + | |update-timestamp= 20120118 |
|creationdate=20110627 | |creationdate=20110627 | ||
|author=[[User:Maveric]] | |author=[[User:Maveric]] | ||
}} | }} | ||
| − | + | ||
| − | {{Abstract|This article features | + | {{Abstract|This article features an example on how to read, display and load Map Features }} |
== Introduction == | == Introduction == | ||
| − | This example uses the | + | This example uses the Nokia Maps API Feature manipulation functionality, described in the API Reference here: |
| − | http://api.maps. | + | http://api.maps.nokia.com/2.1.0/apireference/symbols/nokia.Features.html |
Please check it out for detailed description on the subject. | Please check it out for detailed description on the subject. | ||
| Line 37: | Line 38: | ||
== Prerequisites == | == Prerequisites == | ||
| − | + | Nokia Maps API supported web browser (basically any modern web browser will do). | |
== Example code == | == Example code == | ||
| − | This example loops | + | 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 | + | <code javascript> |
<html> | <html> | ||
<head> | <head> | ||
| − | <script src="http://api.maps. | + | <script type="text/javascript" src="http://api.maps.nokia.com/2.0.0/jsl.js" charset="utf-8"></script> |
</head> | </head> | ||
<body> | <body> | ||
| Line 55: | Line 56: | ||
</center> | </center> | ||
<p> | <p> | ||
| − | <script type="text/javascript"> | + | <script type="text/javascript"> |
| − | + | ||
| − | // This example will | + | // 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. | // are being used in the current map that is loaded and in use. | ||
| − | + | ||
var map; | var map; | ||
| − | + | map = new nokia.maps.map.Display(document.getElementById("map"), | |
| − | map = new | + | |
{ | { | ||
| − | components: [ new | + | components: [ new nokia.maps.map.component.Behavior(), |
| − | new | + | new nokia.maps.map.component.ZoomBar(), |
| − | new | + | new nokia.maps.map.component.Overview(), |
| − | new | + | new nokia.maps.map.component.TypeSelector(), |
| − | new | + | 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 = | + | var list = nokia.maps.Features.getFeatureMap(); |
| − | + | ||
| − | // Loop | + | // Loop through the features and show them in an alert |
| − | // Returns a map of registered | + | // 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 = | + | var list = nokia.maps.Features.getLoadedMap(); |
| − | + | ||
| − | // Loop | + | // 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 99: | Line 99: | ||
} | } | ||
| − | + | 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){ | 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> | |
</p> | </p> | ||
</body> | </body> | ||
</html> | </html> | ||
| − | |||
</code> | </code> | ||
| Line 123: | Line 121: | ||
Feel free to modify the code for your own purposes. | Feel free to modify the code for your own purposes. | ||
| − | == | + | ==For more on Nokia Maps API== |
| − | + | Please check out the Nokia Maps API full documentation and API reference here: | |
| + | * http://api.maps.nokia.com/ | ||
| − | + | You may also access the interactive Nokia Maps API playground, | |
| + | * http://api.maps.nokia.com/2.1.0/playground/index.html | ||
| + | |||
| + | == Tested with == | ||
| − | Firefox 5.0 | + | * Google Chrome 11.0 x |
| + | * Safari 5.0.5 | ||
| + | * Firefox 5.0 | ||
Revision as of 09:14, 18 January 2012
Article Metadata
Tested with
Article
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://api.maps.nokia.com/2.1.0/apireference/symbols/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.
<html>
<head>
<script type="text/javascript" src="http://api.maps.nokia.com/2.0.0/jsl.js" charset="utf-8"></script>
</head>
<body>
<center>
<div id="map" style="width:80%; height:80%"></div>
</center>
<p>
<script type="text/javascript">
// 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("map"),
{
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>
</p>
</body>
</html>
Summary
Feel free to modify the code for your own purposes.
For more on Nokia Maps API
Please check out the Nokia Maps API full documentation and API reference here:
You may also access the interactive Nokia Maps API playground,
Tested with
- Google Chrome 11.0 x
- Safari 5.0.5
- Firefox 5.0

