Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使人类标记在地图上移动?_Java_Android_Google Maps_Google Maps Android Api 2_Marker - Fatal编程技术网

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()));
}