Java 如何使人类标记在地图上移动?
我在地图上有一个标记。当用户移动时,如何使其移动Java 如何使人类标记在地图上移动?,java,android,google-maps,google-maps-android-api-2,marker,Java,Android,Google Maps,Google Maps Android Api 2,Marker,我在地图上有一个标记。当用户移动时,如何使其移动 private Marker humanMarker; humanMarker = map.addMarker(new MarkerOptions() .position(new LatLng(mLocation.getLatitude(), mLocation.getLongitude())) .icon(BitmapDescriptorFactory.fromResource(
private Marker humanMarker;
humanMarker = map.addMarker(new MarkerOptions()
.position(new LatLng(mLocation.getLatitude(), mLocation.getLongitude()))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.human)));
尝试重写onLocationChanged方法。当用户位置更改时,humanMarker将移动
@Override
public void onLocationChanged(Location location) {
// Update current location of the marker
humanMarker.setPosition(new LatLng(location.getLatitude(), location.getLongitude()));
}