Revision as of 19:27, 14 November 2011 by Maveric (Talk | contribs)

HERE Maps API - Managing map Features

From Nokia Developer Wiki
Jump to: navigation, search

This article explains the use of class Nokia.Features



Since the version 2.0.0 of the Nokia Maps API, it will offer the possibility to display, load and manage Maps features including e.g. “routing” and “search”. Each of the features may exist in different implementations for different target environments. A feature implementation is a set of classes that enable certain functionality and which can be loaded to enrich the functionality. By default the API loads all possible features in the optimal implementation for the environment in which it runs. However, the loading of certain features may also be deferred by explicitly disallowing certain or all features at page load time. This may reduce the initial page load time as not all of the API's code is transferred and executed during the page's start up. The Features object makes possible to load individual features of the API manually. It automatically resolves dependencies between different features and provides mechanisms to detect the best feature implementation for the current environment. The Features object is a static object that is not to be instantiated, it is intented to be used directly instead.

Example use

In the example below we first need to have the Nokia Maps instantiated. Please use the following code to get the Nokia Maps visible first. You can use either Firefox with Firebug, or Chrome's tools or what debug tool you prefer.

<script type="text/javascript" charset="UTF-8" src="http://api.maps.nokia.com/2.0.0/jsl.js?">
<div id="map" style="width:100%; height:100%;"></div>
<script type="text/javascript">
var map = new nokia.maps.map.Display(document.getElementById("map"),
{ components: [ new nokia.maps.map.component.Behavior(),],
'zoomLevel': 4,
'center':[53.1, 13.1]});

After this you can just use the web development console for testing as follows:

For example, if we would like to see what is currently loaded, we could issue the following:

>>> nokia.maps.Features.getFeatureMap();

Firebug Object Display shows:

Object { search=[1], routing=[1], positioning=[1], more...}

Based on this information, we can find out that all the components that are listed are currently loaded, and we will also be able to see how many instances there are of them, so "[1]" means there is one loaded.

You can reveal the rest with “more…”. Please note that it depends on your map implementation ofcourse, how many features there are, this is just given as an example. After clicking "more..." you could see e.g.:

["canvas", "svg", "vml"]
["en-GB", "en-US", "de-DE", 5 more...]
["js-p2d-canvas", "js-p2d-dom"]
["nokia_generic", "ovi_web"]

Tested with

Firefox 7.0.1 Firebug 1.8.4


Add categories below. Remove Category:Draft when the page is complete or near complete

161 page views in the last 30 days.