OGeek|极客世界-中国程序员成长平台

标题: android - 标记位置更改事件 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-9 06:49
标题: android - 标记位置更改事件

我正在使用新的 Android 版 Google map v2。 有没有办法为标记位置更改设置监听器?例如当用户拖动标记时。



Best Answer-推荐答案


引用 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演示 OnMarkerDragListener 的使用。

关于android - 标记位置更改事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14491069/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (https://www.ogeek.cn/) Powered by Discuz! X3.4