views:

79

answers:

1

Hi? I am working on a MapView app in Android. I have three markers that I want to be able to use the Google Map API getlocation-function on, later on. In order to try it out I would like to move the marker with a drag and drop-function, and then check the location.

Anyone who has gotten a drag and drop to work on an android marker, or know a way to start figuring it out?

/AK

+1  A: 

Here is a sample project from one of my books showing drag-and-drop movement of markers on a Google Map in Android.

In a nutshell, it uses onTouchEvent() to detect when the user touches and holds their finger near a marker. It then removes the marker from the overlay, but puts the same image over top of the map using RelativeLayout. Then, on "move" touch events, the image is moved (faster than forcing the whole overlay to redraw). When the finger is lifted, the image is removed, but the marker is put back in the overlay at the new spot.

CommonsWare
Thanks a lot for the link and explanation! I am new to Android, so it is good for me to look at the structure of a well working project, to get the idea of how to get things done for real and not just throw things in there. Thank you.
Anna-Karin