HERE Maps API - How to add an HTML InfoBubble on the map
Ovi Maps API - How to add an HTML infoBubble on the map
Contents |
Introduction
An infoBubble must have a ovi.mapsapi.geo.Coordinate and content which can be either provided as a string or as a ovi.mapsapi.search.Location object.
API defines:
Extends ovi.mapsapi.map.component.Component.
new ovi.mapsapi.map.component.InfoBubbles ()
Options Interface defining the info bubbles' options (keys)
Prerequisites
Ovi Maps API supported web browser (basically any modern web browser)
Important about Maps credentials
With Ovi Maps API you can start without having any credentials given, but you might face a performance gap. In order to get the full potential out of the offering, you must get the credentials that authenticate your application against the Services. Please read through the Location API.
For more information on how to obtain the credentials, please start with the Ovi Maps API Developers Guide section "Acquiring API credentials"
Implementation
In this example we will create one infoBubble with video content from YouTube. Location is Bermuda Triangle near Bahamas and the video will show a plane flying on that area.
Example code
<html>
<head>
<script src="http://api.maps.ovi.com/jsl.js" type="text/javascript" charset="utf-8">
</script>
<link rel="stylesheet" href="style.css" />
</head>
<body style = "width:100%; height:100%;">
<div id="map" style="width:100%; height:100%;"></div>
</body>
<script type="text/javascript">
var myInfoBubbles = new ovi.mapsapi.map.component.InfoBubbles();
var myHTMLcontent = "<div class=\"myHtmlContent\">"+"<iframe width='425' height='349' src='http://www.youtube.com/embed/9hVAFzo30qE' frameborder='0' allowfullscreen></iframe>"+"</div>";
var map = new ovi.mapsapi.map.Display(document.getElementById("map"), // new instance of Ovi Maps
{
components: [
myInfoBubbles,
new ovi.mapsapi.map.component.Behavior(),
new ovi.mapsapi.map.component.ZoomBar(),
new ovi.mapsapi.map.component.Overview(),
new ovi.mapsapi.map.component.TypeSelector(),
new ovi.mapsapi.map.component.ScaleBar()
],
'zoomLevel': 6,
'center':[25, -71]
});
map.set("baseMapType", map.SATELLITE);
myInfoBubbles.addBubble(myHTMLcontent, new ovi.mapsapi.geo.Coordinate(25, -71));
</script>
</body>
</html>
For more on Ovi Maps API
Please check out the Ovi Maps API full documentation and API reference here:
Tested on
Google Chrome 11.0x
Mozilla Firefox 5.0b

