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 - How to add an HTML InfoBubble on the map

From Wiki
Jump to: navigation, search

This article explains how to add an info bubble on the map. The info bubble can contain any HTML content.

Article Metadata
Code ExampleTested with
Devices(s): Internet Explorer, Google Chrome, Firefox, Opera
Platform(s): Web browser
Dependencies: HERE Maps 2.5.3 or higher
Created: Maveric (21 Jun 2011)
Updated: avnee.nathani (31 Dec 2011)
Last edited: jasfox (20 Dec 2013)



An infoBubble must have a nokia.maps.geo.Coordinate and content which can be either provided as a string or as a object.

API defines:

new ()
Options Interface defining the info bubbles' options (keys)


HERE Maps API supported web browser (basically any modern web browser)

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

Adding an Infobubble directly onto the Map

In this example we will create one infoBubble with video content from YouTube. Location is mumbai, where a info bubble would be shown with out youtube video. Remember to add in your own AppId and Token.

function addInfoBubble(map){
map.set("baseMapType", map.SATELLITE);
map.set("center", new nokia.maps.geo.Coordinate(19.119, 72.8957));
var infoBubbles = new;
var myHTMLcontent = "<div class=\"myHtmlContent\">"+"<iframe width='425' height='349' " +
" src='' frameborder='0' allowfullscreen>" +
new nokia.maps.geo.Coordinate(19.119, 72.8957)) ;


A fully working example can be found at:

Adding an InfoBubble to a map marker

Assuming we already have a map, the first thing to do is to create an info bubble and add it as a map component, and a container with an onclick event

var infoBubbles = new;
container = new;
container.addListener("click" , function(evt) {
}, false);

The function described below, will add a marker and HTML content to the container

function addMarkerToContainer(container, coordinate , html) {
var marker = new
coordinate, {html: html});

Finally the markers themselves must be added. Clicking on the marker brings up the embedded HTML.

addMarkerToContainer(container, [53.439,-2.221], 
"<div><a href='' >Manchester City</a>" +
"</div><div >City of Manchester Stadium<br>Capacity: 48,000</div>");
addMarkerToContainer(container, [53.430,-2.961],
"<div ><a href='' >Liverpool</a>" +
"</div><div >Anfield<br>Capacity: 45,362</div>");



Working Example:

Pre-opening an InfoBubble

It is possible to use the dispatch() method, to fire an onclick event, which causes the infobubble to be opened when the page is loaded. Image a URL of the form ../open-infobubble-with-id.html?id=2 - the query string of this url can be read to determine which infobubble should be opened.

First create a helper function to obtain the query string parameters:

function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(;
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));

The call the function below to open the relevant id

function openInfoBubble(){
var param = getParameterByName('id');
if (param == ""){
return; // Don't open a bubble.
// Iterate through the markers to find the correct id.
for (var i = 0; i < container.objects.getLength(); i++){
if (param === container.objects.get(i).id){
// fire an event to open the bubble.
new nokia.maps.dom.Event(
{type: "click",
target: container.objects.get(i)}));

The markers must be assigned a unique id when instantiated as shown:

var marker = new
new nokia.maps.geo.Coordinate(52.516237, 13.377686),
{html: "Brandenburger Tor",
id : "1" }
var fernsehturmMarker = new
new nokia.maps.geo.Coordinate(52.520816, 13.409417),
{html: Fernsehturm,
id : "2" }

Working Example - click on the links:

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

This page was last modified on 20 December 2013, at 15:43.
520 page views in the last 30 days.