huong
huong

Reputation: 4564

Android - Dragging marker without having to hold in map api v2

I'm implementing a feature in my app that allows user to manually locate themselves on a map. So I use a pin to represent their location and let user drag it to the place they currently are. The simple solution is to use setDraggable(true) on the marker, but this requires users to hold the marker for 3 or 5 seconds until it is draggable. I think this is quite confusing for many user to use the feature. So, what I want is to make the dragging more responsive by letting users drag them immediately without having to hold it for a while - like how Foursquare does!

enter image description here

What should I do to implement my own dragging feature? If you have any suggestions, please help me and thanks.

Upvotes: 10

Views: 1626

Answers (1)

Chris Broadfoot
Chris Broadfoot

Reputation: 5112

Check out the Hailo application. They have a neat workaround for this. It only works when you have one marker to drag.

The trick is to pan the map, instead of moving the marker. They just keep the marker in a view on top of the MapFragment (it's not actually a Marker on the map).

You can then use the map's cameraPosition.target as the location of your marker.

Upvotes: 1

Related Questions