其他分享
首页 > 其他分享> > android – 标记位置更改的事件

android – 标记位置更改的事件

作者:互联网

我正在使用新版Google Maps for Android v2.
有没有办法为标记位置变化设置监听器?例如,当用户拖动标记时.

解决方法:

引用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,android-maps,android-maps-v2
来源: https://codeday.me/bug/20190718/1493911.html