Search code examples
javascripthere-api

How do I retrieve custom marker coordinates in HERE Maps API for Javascript?


How do I retrieve custom marker coordinates in HERE Maps API for Javascript?

This is how I add a custom marker:

var marker = new nokia.maps.map.StandardMarker([52.51, 13.4], {
   text: "Hi!", // Small label
   draggable: true // Make the marker draggable
});

map.objects.add(marker);

The problem: I need to get new coordinates when a user drags this marker to another position and clicks 'ok' (so no listeners are needed).

Neither var 123 = marker(coordinate); alert(123);nor var 123 = marker.coordinate; alert(123); do the trick. The API seems to be silent about that issue.


Solution

  • Turns out to be pretty simple:

    var latitude = marker.coordinate.latitude.toString();