Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

HERE Maps API - Map UI components

From Wiki
Jump to: navigation, search

This article shows how to use a static Nokia map and add interactive UI controls to it.

Tip.pngTip: The HERE Maps API for JavaScript is generally used to display an interactive map on screen. i.e. a map which is pannable, zoomable or clickable for further information. If you don't need any UI components, a simpler solution for displaying a non-interactive static map would be to use the RESTful Map API where the location of the map is encoded into the URL of the image. For example, the following URL will display a static map without using any JavaScript:

<img id="gmapcanvas" src=",0&w=600&z=1&nord&nodot" 
alt="Hello World" />

Article Metadata
Code Example
Source file: map-components.html
Tested with
Devices(s): Internet Explorer, Google Chrome, Firefox, Opera
Platform(s): Web
Dependencies: HERE Maps 2.5.3
Keywords: HERE Maps, JavaScript, UI, components
Created: Maveric (21 Jun 2011)
Last edited: jasfox (12 Mar 2014)



In this article we will make a static map interactive by adding some UI control components. By default, when the map is initiated without parameters or components, it will set the coordinates to 0,0 and zoom level to zero (0). We would be adding controls like zoom bar, scale bar and map type selector.


HERE Maps API supported device and browser (basically any modern browser)


To make the map 'intelligent', to be able to zoom it and move within the map, we need to add some components to it.

ZoomBar This will add a slider UI component, which enables the user to increase or decrease the map zoom level. The four zoom level bookmark buttons that also will appear, allow for setting predefined zoom levels.

Overview Defines a panel showing an overview of the map of the currently visible viewport.

TypeSelector Provides a user interface to change the current base map type (Satellite, Terrain, Map)

ScaleBar Defines a panel providing a scalebar. The scalebar is a ruler displaying distance measurements at different zoom levels of the map. By default, the scalebar is collapsed showing only one ruler section. When expanded, the scalebar shows more ruler sections. The measurement type can be changed from metric to imperial, which will be reflected in the distance measurements.

Example Static non-interactive map example code

The code below taken from the <body> of a working example would show us a map which has no presets defined, so it will default to the map origin 0,0 and zoom level minimum (0) with no possibility for the user to interact with the map: it does not respond to the user mouse click and all the UI components are removed (Zoom Bar, Scale Bar, Map Type Selector).

Note.pngNote: As from HERE Maps API 2.2 The authorization token is now required

<div id="mapContainer" style="width:540px; height:334px;"></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
nokia.Settings.set("app_id", "YOUR APP ID");
nokia.Settings.set("app_code", "YOUR TOKEN");
var map = new"mapContainer"));

Example: Dynamic, interactive map with scale bar, overview and map type selector

To add the map components, the set-up of the map in the example is altered as follows:

var map = new"mapContainer"), {
components: [
new ],
zoomLevel: 8,
center: [19.119, 72.8957]

To see an example in action, try the following link:

For more on the HERE Maps API

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

You may also access the interactive API explorer

And additional examples on GitHub

Tested on

  • Google Chrome 20.0x
  • Mozilla Firefox 13.0x
This page was last modified on 12 March 2014, at 17:28.
111 page views in the last 30 days.