Daniele Vitali
Daniele Vitali

Reputation: 3858

Event for marker position change

I'm using the new Google Maps for Android v2. Is there a way to set a listener for marker position change? For example when the user drag the marker.

Upvotes: 3

Views: 6364

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007339

Quoting the documentation:

You can use an OnMarkerDragListener to listen for drag events on a marker. To set this listener on the map, call GoogleMap.setOnMarkerDragListener. To drag a marker, a user must long press on the marker. When the user takes their finger off the screen, the marker will stay in that position. When a marker is dragged, onMarkerDragStart(Marker) is called initially. While the marker is being dragged, onMarkerDrag(Marker) is called constantly. At the end of the drag onMarkerDragEnd(Marker) is called. You can get the position of the marker at any time by calling Marker.getPosition().

Here is a sample project demonstrating the use of an OnMarkerDragListener.

Upvotes: 11

Related Questions