×
Namespaces

Variants
Actions
(Difference between revisions)

HERE Maps API - Reading and displaying Map Features

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 - Bot addition of Template:ArticleMetaData)
Line 1: Line 1:
 +
{{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= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|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= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|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= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate=20110627
 +
|author=[[User:Maveric]]
 +
}}
 +
 
[[Category:Web]][[Category:Browser]][[Category:Nokia Maps]]
 
[[Category:Web]][[Category:Browser]][[Category:Nokia Maps]]
 
{{Abstract|This article features and example on how to read and display plus load Map Features }}  
 
{{Abstract|This article features and example on how to read and display plus load Map Features }}  

Revision as of 02:56, 2 January 2012

Article Metadata
Article
Created: Maveric (27 Jun 2011)
Last edited: hamishwillee (02 Jan 2012)

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

Contents

Introduction

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

http://api.maps.ovi.com/apireference/symbols/ovi.mapsapi.Features.html?s=Features

Please check it out for detailed description on the subject.


Prerequisites

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


Example code

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

<html>
<head>
<script src="http://api.maps.ovi.com/jsl.js" type="text/javascript" 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 display first 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 ovi.mapsapi.map.Display(document.getElementById("map"),
{
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: [52.51, 13.4] // default map center point (not the location retrieved)
 
});
 
//Retrieve Feature Map
 
var list = ovi.mapsapi.Features.getFeatureMap();
 
// Loop thru the features and show them in an alert
// Returns a map of registered feature implementation names per feature.
 
for( var i in list )
{ if ( list.hasOwnProperty(i) )
alert("Feature Map: "+list[i]);
}
 
// Retrieve Loaded Map
 
var list = ovi.mapsapi.Features.getLoadedMap();
 
// Loop thru 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]);
}
 
// Let's try add routing feature, it's not implemented in this example:
 
ovi.mapsapi.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.

Tested with

Windows XP Pro

Safari 5.0.5

Firefox 5.0

156 page views in the last 30 days.
×