Federico Navarrete
Federico Navarrete

Reputation: 3274

How can I get the longitude and latitude of a draggable marker in Nokia Maps?

I have found this code and it works very well but I'd like to know how to get that information, longitude and latitude of the draggable marker. This is the code: Draggable Marker

Upvotes: 1

Views: 822

Answers (1)

Nicolas Boonaert
Nicolas Boonaert

Reputation: 2952

If you want to retrieve the coordinate of the marker while you're dragging the marker in the map control (or after), you can use the dedicated events.

Here is a updated version based on your code:

// Place this anywhere in the world.
var draggableMarker = new nokia.maps.map.StandardMarker([52.500556, 13.398889], 
{  
text:  "X",  
brush: {color: '#FF0000'} ,                 
draggable: true,                     
});   

// Add the listener function to the bubbling phase of the "dragend" event
draggableMarker.addListener("dragend", function(e) {
    var coordinate = display.pixelToGeo(e.displayX, e.displayY);
    alert(coordinate);
}, false);
// Add the marker to the map.
display.objects.add(draggableMarker);

Here is also a complete example: http://developer.here.com/apiexplorer/examples/api-for-js/markers/draggable-markers.html

Upvotes: 2

Related Questions