(Difference between revisions)

HERE Maps API - How to add an HTML InfoBubble on the map

From Nokia Developer Wiki
Jump to: navigation, search
jasfox (Talk | contribs)
m (Jasfox - Added Marker InfoBubble example.)
jasfox (Talk | contribs)
m (Jasfox - Add category)
Line 1: Line 1:
[[Category:Web]][[Category:Browser]][[Category:Nokia Maps]][[Category:Code Snippet]][[Category:How To]]
[[Category:Web]][[Category:Browser]][[Category:Nokia Maps]][[Category:Code Snippet]][[Category:How To]][[Category:Location]]
{{Abstract|This article explains how to add an info bubble on the map. The info bubble can contain any HTML content.}}
{{Abstract|This article explains how to add an info bubble on the map. The info bubble can contain any HTML content.}}

Revision as of 17:16, 11 January 2012

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

Article Metadata
Platform(s): Web browser
Dependencies: Nokia Maps 2.1.0
Created: Maveric (21 Jun 2011)
Updated: avnee.nathani (31 Dec 2011)
Last edited: jasfox (11 Jan 2012)



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

API defines:

Extends nokia.maps.map.component.Component.
new nokia.maps.map.component.InfoBubbles ()
Options Interface defining the info bubbles' options (keys)


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

Important about Maps credentials

Nokia provides several services options within the Maps API offering. The service is free to use, but if you complete the free registration process and obtain authentication and authorization credentials, your application will have priority access to the service and will thus avoid a potential performance penalty. Please read the Location API Business Models and Usage Restrictions 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 from the Nokia Developer API Registration page.

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.

<script type="text/javascript"
src="http://api.maps.nokia.com/2.0.0/jsl.js" charset="utf-8">
<link rel="stylesheet" href="style.css" />
<body style = "width:100%; height:100%;">
<div id="map" style="width:100%; height:100%;"></div>
<script type="text/javascript">
var myInfoBubbles = new nokia.maps.map.component.InfoBubbles();
var myHTMLcontent = "<div class=\"myHtmlContent\">"+"<iframe width='425' height='349' src='http://www.youtube.com/embed/Nr41eRzUnrg' frameborder='0' allowfullscreen></iframe>"+"</div>";
var map = new nokia.maps.map.Display(document.getElementById("map"), // new instance of Nokia maps
components: [
new nokia.maps.map.component.Behavior(),
new nokia.maps.map.component.ZoomBar(),
new nokia.maps.map.component.Overview(),
new nokia.maps.map.component.TypeSelector(),
new nokia.maps.map.component.ScaleBar()
'zoomLevel': 10,
'center':[19.119, 72.8957]
map.set("baseMapType", map.SATELLITE);
myInfoBubbles.addBubble(myHTMLcontent, new nokia.maps.geo.Coordinate(19.119, 72.8957)) ;



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.

var infoBubbles = new nokia.maps.map.component.InfoBubbles();
map.addComponent( infoBubbles);

The function described below, will add an onclick event to a marker and display the associated HTML content.

function addInfoBubble(infoBubbles, marker, html) {
marker.html = html;
marker.addListener("click" , function(evt) {
infoBubbles.addBubble(evt.target.html, evt.target.coordinate);
}, false);

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

var marker;
var markers = new Array();
marker = new nokia.maps.map.StandardMarker(new nokia.maps.geo.Coordinate(53.4393381986981,-2.2211828827858));
addInfoBubble( infoBubbles, marker, "<div><a href='http://www.mcfc.co.uk' >Manchester City</a></div><div >City of Manchester Stadium<br>Capacity: 48,000</div>");
marker = new nokia.maps.map.StandardMarker(new nokia.maps.geo.Coordinate(53.4308166986509,-2.96082615852356));
addInfoBubble( infoBubbles, marker, "<div ><a href='http://www.liverpoolfc.tv' >Liverpool</a></div><div >Anfield<br>Capacity: 45,362</div>");



For more on Nokia Maps API

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

You may also access the interactive Nokia Maps API playground,

Tested on

  • Google Chrome 11.0x
  • Mozilla Firefox 5.0b
4817 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.