如何实现Android标记拖放? [英] How does one implement drag and drop for Android marker?

查看:140
本文介绍了如何实现Android标记拖放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好?
我正在Android中使用MapView应用程序。我有三个标记,我希望能够使用Google Map API getlocation函数。为了尝试,我想用拖放功能移动标记,然后检查位置。

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.

任何人谁可以拖放工作在Android的标记,或者知道一种方法来开始弄清楚?

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

/ AK

推荐答案

以下是我的一个示例项目书籍显示Android版Google地图上标记的拖放移动。

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

简而言之,它使用 onTouchEvent( )以检测用户何时触摸并将其手指保持在标记附近。然后它从叠加层中删除标记,但使用 RelativeLayout 将相同的图像放在地图的顶部。然后,在移动触摸事件时,图像被移动(比强制整个叠加层重新绘制更快)。当手指被提起时,图像被移除,但是标记将被重新放回到新的位置。

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.

这篇关于如何实现Android标记拖放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆