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

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

问题描述

嗨?我正在 Android 中开发 MapView 应用程序.我有三个标记,我希望稍后能够在其上使用 Google Map API getlocation-function.为了尝试一下,我想使用拖放功能移动标记,然后检查位置.

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天全站免登陆