Event for marker position change

耗尽温柔 提交于 2019-12-06 08:51:25

问题


I'm using the new Google Maps for Android v2. Is there a way to set a listener for marker position change? For example when the user drag the marker.


回答1:


Quoting 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 demonstrating the use of an OnMarkerDragListener.



来源:https://stackoverflow.com/questions/14491069/event-for-marker-position-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!