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:04, 4 January 2013 by jasfox (Talk | contribs)

HERE Maps API - Performing multiple concurrent search requests

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Internet Explorer, Google Chrome , Firefox, Opera
Platform(s): Web
Dependencies: Nokia Maps 2.2.3
Keywords: Nokia Maps, JavaScript, Search
Created: Maveric (25 Oct 2011)
Last edited: jasfox (04 Jan 2013)



In this article we will examine the following usage of the Nokia Maps API.

  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 concurrent requests.


Nokia 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


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

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<script type="text/javascript" charset="UTF-8" src=""></script>
<title>Concurrent Search example</title>
<div id="map" style="width:100%; height:100%; 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");
//initialize a new map
var display = new"map"),
{ "components": [
"zoomLevel": 10 });
// we will put our address markers into this container
var addressContainer = new;
// this function will be used when all managers have returned
var 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
display.zoomTo(bbox, true);
} 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
var onSearchComplete = function (data, requestStatus) {
if (requestStatus == "OK") {
// if we are finished, we add a marker for the mapped position
//increment the counter to notify another manager has finished
} else if(requestStatus === "ERROR") {
// we'll also increment in case of an error
// if all managers are finished, we call the final function
if(managersFinished === addresses.length) {
//Addresses to be displayed
var addresses = ["Helsinki, Finland", "Zaragoza, Spain", "Berlin, Germany", "Colorado Springs, USA", "Houston, TX",
"London, UK", "Vancouver, Canada", "Hyderabad, India", "Beijing, China", "Ilomantsi, Finland" ];
var i = addresses.length;
var managersFinished = 0;
// iterate over all addresses, create a manager for each of them,
// add the observer and call the geocode method
while(i--) {{
searchTerm :addresses[i],
onComplete: onSearchComplete


The following screenshot shows the resultant map after making the search.


186 page views in the last 30 days.