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 over the next few weeks. Thanks for all your past and future contributions.

Show my location using HTML5 Geolocation API and HERE Maps

From Wiki
Jump to: navigation, search

This article explains how to capture a user location using HTML Geolocation API and display the user's location on nokia map


HTML5 geolocation api provides support to capture one's location by capturing the latitude and longitude where the user is based. So by using a combination of geolocation api and HERE Maps it is possible to display one's location on a web page. Please note that the accuracy of the location depends on the correctness of the latitude and longitude that is captured.


The geolocation api comes along with HTML 5 and hence it is supported in almost all the latest browsers - Firefox, Chrome, Internet Explorer, Safari, Opera etc. In order to retrieve geolocation, the user needs to explicitly give permission to share his/her location.

The "if (nokia.maps.positioning.Manager)" condition provides whether the browser used by the user supports geolocation or not.

The following code captures the latitude and longitude of the user

 function locateUser(map){
if (nokia.maps.positioning.Manager) {
var positioning = new nokia.maps.positioning.Manager();
// Alternatrively : navigator.geolocation.getCurrentPosition()
function (position) {
var coords = position.coords,
marker = new,
accuracyCircle = new, coords.accuracy);
map.objects.addAll([accuracyCircle, marker]);
map.zoomTo(accuracyCircle.getBoundingBox(), false, "default");
// Something went wrong we were unable to retrieve the GPS location
function (error) {
var errorMsg = "Location could not be determined: ";
if (error.code < 4){
errorMsg += errors[i-1]
} else {
errorMsg += "UNKNOWN ERROR";
}, {maximumAge: 750}

The following fully working example can be found at:

Finding the Address of a Geolocation

This can be done through simply the adding a reverseGeocode() call after obtaining the geolocation coordinate:

function (position) {
map.set("center", position.coords);{
latitude: position.coords.latitude,
longitude: position.coords.longitude,
onComplete: displayAddress

With the code to display the address being added to the callback function displayAddress()

function displayAddress(data, requestStatus, requestId)  {


The following fully working example can be found at:

Article Metadata
Code ExampleTested with
Devices(s): Internet Explorer, Firefox, Google Chrome, Safari
Platform(s): Web
Dependencies: HERE Maps 2.5.3
Keywords: Geocoding, Positioning
Created: wang_shui (27 Dec 2011)
Last edited: jasfox (28 Nov 2013)
This page was last modified on 28 November 2013, at 12:00.
138 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.