Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Dhruv Gupta
Dhruv Gupta
4,320 Points

How to get position of a Marker moved by a User Google Maps API V2

Hi, So I place a marker and have a user move it. I then try and get the position of that Marker

I use the following code

LatLng StartingPosition = mSpecificMarker.getPosition();

But, StartingPosition always returns to me the value initially assigned to the Marker Position, Not the new position once the marker is dragged.

Dhruv Gupta
Dhruv Gupta
4,320 Points

Nevermind I figured it out, the very next attempt after putting up this question.

For anyone who might be interested, the trick is to set an OnDraggableListener and inside the listener do the getPosition Command. Like as folllows

mMap.setOnMarkerDragListener(new GoogleMap.OnMarkerDragListener() { @Override public void onMarkerDragStart(Marker marker) { mSpecificMarker.getPosition(); mCityMarker.getPosition(); }