Jan Guardian
Jan Guardian

Reputation: 313

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.

Upvotes: 1

Views: 3518

Answers (4)

Marco
Marco

Reputation: 501

As of 2021 the actual way to go is:

marker.getGeometry().lat;
marker.getGeometry().lng;

Upvotes: 2

DDOc
DDOc

Reputation: 31

The following will return it:

marker.getPosition().lat;

and

marker.getPosition().lng;

Upvotes: 0

Aseem Ahir
Aseem Ahir

Reputation: 743

I think the following should do:

marker.getPosition()

Upvotes: 1

Jan Guardian
Jan Guardian

Reputation: 313

Turns out to be pretty simple:

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

Upvotes: 0

Related Questions