(Difference between revisions)

HERE Maps API - Performing multiple concurrent search requests

From Nokia Developer Wiki
Jump to: navigation, search
Maveric (Talk | contribs)
m (Maveric - - Implementation)
Maveric (Talk | contribs)
m (Maveric - - For more on Ovi Maps API)
Line 109: Line 109:
==For more on Ovi Maps API==   
==For more on Ovi Maps API==   
Please check out the Ovi Maps API full documentation and API reference here: [link]http://api.maps.ovi.com[/link] 
Please check out the Ovi Maps API full documentation and API reference here: http://api.maps.ovi.com
==Tested with==   
==Tested with==   

Revision as of 16:22, 25 October 2011


In this article we will examine the following use case on Ovi Maps:

1. Multiple addresses exist, a total of 10 for this example. 2. A Map Marker is needed to be displayed for each of the addresses. 3. Finally the ZoomLevel needs to be set to cover all of the Markers.

This article enforces the correct use of the search.Manager in case of multiple sequential requests.



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 titled "Acquiring API credentials".


This is a fully working example code in HTML and JavaScript.

<script src="http://api.maps.ovi.com/jsl.js" type="text/javascript" charset="utf-8"></script>
<div id="map" style="width:100%; height:80%;"></div>
</body> <script type="text/javascript"> //initialize a map
var display = new ovi.mapsapi.map.Display(document.getElementById("map"),
{ "components": [ new ovi.mapsapi.map.component.ZoomBar(),
new ovi.mapsapi.map.component.Behavior(),
new ovi.mapsapi.map.component.TypeSelector()],
"zoomLevel": 10 });
var addresses = ["Helsinki, Finland", "Zaragoza, Spain", "Berlin, Germany", "Colorado Springs, USA", "Houston, TX", "London, UK", "Vancouver, Canada", "Hyderabad, India", "Beijing, China", "Ilomantsi, Finland" ], i = addresses.length,
// we will put our address Markers into this Container
venueContainer = new ovi.mapsapi.map.Container(), // this function will be used when all managers have returned
onAllManagersFinished = function() {
//we get the Bounding Box of the Container
var bbox = addressContainer.getBoundingBox();
// if the bounding box is null then there are no objects inside
// meaning no markers have been added to it
if (bbox != null) {
// we have at least one address mapped
// so we add the container and zoomTo it
} else {
// otherwise we'll pop up an error message
alert("There are no addresses to show :(")
// we will use the same state observer function for all Managers
onManagerStateChange = function(manager, propertyName, value)
if(value === "finished") { // if we are finished, we add a marker for the mapped position
addressContainer.objects.add(new ovi.mapsapi.map.StandardMarker(manager.locations[0].displayPosition));
//increment the counter to notify another manager has finished
} else if(value === "failed")
// we'll also increment in case of an error
// if all managers are finished, we call the final function
if(managersFinished === venues.length)
{ onAllManagersFinished(); }
}, manager, managersFinished = 0;
// iterate over all venues, create a manager for each of them,
// add the observer and call the geocode method while(i--)
{ manager = new ovi.mapsapi.search.Manager();
manager.addObserver("state", onManagerStateChange);

For more on Ovi Maps API

Please check out the Ovi Maps API full documentation and API reference here: http://api.maps.ovi.com

Tested with

Google Chrome 14.0.835.202 m

Mozilla Firefox 8.0

428 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.