×
Namespaces

Variants
Actions
Revision as of 17:52, 23 August 2013 by jasfox (Talk | contribs)

HERE Maps API - get the geocoordinates when user clicks mouse over the map

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Code ExampleTested with
Devices(s): Internet Explorer, Google Chrome, Firefox, Opera
Compatibility
Platform(s): Web
Dependencies: HERE Maps 2.2.4 or higher
Article
Keywords: NokiaMaps, JavaScript, geocoordinates
Created: Maveric (31 Dec 2010)
Last edited: jasfox (23 Aug 2013)

This article shows how to get the geolocation of the user's mouse click.

The code example sets up an Event Listener on the click event of the Map Display. The x and y pixel values are extracted from evt.displayX and evt.displayY and converted to geo.Coordinates. Remember to add in your own AppId and Token to get the example to work.

function setUpClickListener(map){
/* Attach an event listener to map display
* obtain the coordinates an display in an alert box.
*/

map.addListener("click", function (evt) {
var coord = map.pixelToGeo(evt.displayX, evt.displayY);
alert("Clicked at " + coord);
});
}


Example alert window

Geocoordinatesmouseclick.png

A fully working example can be found at:

http://rawgithub.com/heremaps/examples/master/maps_js/geocoordinate-on-click.html

269 page views in the last 30 days.
×