我正在尝试在地图活动上创建一个“选择位置”(就像谷歌地图应用程序中的那个,在选择方向的起点时)。
基本上,我在地图的中心放了一个标记,然后在相机移动时重新定位它。问题是标记不能顺利移动(它口吃)。我尝试了一些关于堆栈溢出的解决方案,但没有一个有效。
我的代码是这样的:
getGoogleMap().moveCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(location.getLatitude(),
location.getLongitude()), 14));
LatLng target = getGoogleMap().getCameraPosition().target;
chooseMarker = getGoogleMap().addMarker(new MarkerOptions()
.position(target));
getGoogleMap().setOnCameraMoveListener(new GoogleMap.OnCameraMoveListener() {
@Override
public void onCameraMove() {
// Get the center of the Map.
LatLng centerOfMap = getGoogleMap().getCameraPosition().target;
// Update your Marker's position to the center of the Map.
chooseMarker.setPosition(centerOfMap);
}
});
呼唤远方
有只小跳蛙
随时随地看视频慕课网APP
相关分类