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.

Revision as of 11:20, 4 January 2013 by jasfox (Talk | contribs)

HERE Maps API - How to add map markers

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Google Chrome, Firefox, Internet Explorer, Safari
Platform(s): Web
Dependencies: Nokia Maps Api 2.2.3
Keywords: Nokia Maps, JavaScript, Markers
Created: Maveric (21 Jun 2011)
Updated: jasfox (06 Feb 2012)
Last edited: jasfox (04 Jan 2013)



In this article we will go through how to add one or more Markers to the map. A Marker defines an Object that may display an icon on the map view.


A supported web browser (basically any modern web browser)

The example assumes you have already added the Nokia Maps to your web page as explained in the previous article Nokia Maps API - Add Maps To Any Web Page

Important note about maps credentials

Nokia provides several services options within the Maps API offering. The service is free to use, but you must obtain and use authentication and authorization credentials to use the services. Please read the Terms and Conditions and check the Pricing Plans page to decide which business model best fits your needs. Authentication requires unique Maps API credentials, namely an AppId and a token. You can get these credentials free for free following the instructions here


Defining a Marker

First we will need to define the Marker. This will be done by specifying the location as a geo.Coordinate and then defining the Marker:

   var center =    new nokia.maps.geo.Coordinate(40.738728,-73.99236);
var marker = new;

The Marker needs geocoordinates as parameters, that is, its latitude and longitude on the map. In our example we are using 40.738728 for the latitude and -73.99236 for the longitude This will place a marker in Central New York. marker now contains a new StandardMarker object.

Adding a Marker directly

We may place the StandardMarker on the map by adding it directly as shown:


Adding a Marker via a Container

As an alternative to adding a marker directly, we can add it to a Container and then add the Container to the map. A Container is used to group Objects, and thus allows them all to be operated on at once without the need to iteratively visit each one (e.g. for changing the visibility).

First create a Container:

   var container = new;

Now that we have the Container ready, we can add the StandardMarker into it:

    container .objects.add(marker);
//or another way of putting this e.g. container.objects.add( new new nokia.maps.geo.Coordinate(40.738728,-73.99236)));

And then when the StandardMarker is in the Container, we will need to add the Container to the map objects collection, to be able to show the content on it:


Manipulating the Marker

The properties of the StandardMarker can be further manipulated, e.g. you can make the Marker draggable (it is static by default) if you wish:


And to make the StandardMarker static again, you would give:


For a StandardMarker you can set the text property as shown:

    marker.set("text","Your marker!")

Retrieving information about the marker

Sometimes it may be useful to know if a Container has been added to the Display. Earlier we could have initiated the Display object e.g. like this:

var map ="map"),

Now, with the reference to "map", we can request:

    test = marker.isAdded (map)

Our case test would result in true.

With the isVisible (display) : Boolean we will get true if the object's visibility as well as all parent's visibilities are true and if the object is attached to a map (i.e. parent chain ends with a map). The returned value is only valid for the given object.


{} display The display to check.

In our case we could ask:

    test = marker.isVisible(map);

Again, this would result in “true”.

With the getParent (display) we can get the parent of the map object.


{} display The display for which to return the parent object.

Returns: {} The parent object of this object for the given display or undefined if this map object has no parent.

    test = marker.getParent(map);

If we want to get the Display names that the Container is attached to, this could be queried as follows:

    test = marker.getDisplays();

In this case we would know already that there is the "map" Display, so now asking the question marker.isAdded (test) would give us true, because marker is attached to the "map".

Example code

Here is a full example with required HTML and embedded JavaScript. Remember to add in your own AppId and Token.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<title>Adding a marker.</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript"
src="" charset="utf-8">
<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
nokia.Settings.set( "appId", "YOUR APP ID GOES HERE");
nokia.Settings.set( "authenticationToken", "YOUR AUTHENTICATION TOKEN GOES HERE");
var center = new nokia.maps.geo.Coordinate(40.738728,-73.99236);
// Get the DOM node to which we will append the map
var mapContainer = document.getElementById("mapContainer");
// Create a map inside the map container DOM node
var map = new, {
// initial center and zoom level of the map
center: center,
zoomLevel: 15,
components: [
var marker = new;

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

203 page views in the last 30 days.