map.setOnMarkerClickListener(new OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker arg0) {
// TODO Auto-generated method stub
LatLng point = arg0.getPosition();
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(point)
.tilt(90).zoom(map.getCameraPosition().zoom)
.build();
map.animateCamera(CameraUpdateFactory
.newCameraPosition(cameraPosition),
new CancelableCallback() {
@Override
public void onFinish() {
// TODO Auto-generated method stub
Toast.makeText(getActivity(), "finsih",
10000).show();
}
@Override
public void onCancel() {
// TODO Auto-generated method stub
Toast.makeText(getActivity(), "cancel",
10000).show();
}
});
return false;
}
});
这是我的代码。我在谷歌地图上显示一个标记,我希望当我点击标记时,相机应该在街道上移动到最大缩放级别。
我怎样才能做到这一点?我应该如何编写oncancel
和onfinish
方法的代码?
答案 0 :(得分:2)
你可以尝试一下,它适合我。 。 。所以我希望它可以帮到你
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(final Marker arg0) {
// TODO Auto-generated method stub
LatLng point = arg0.getPosition();
CameraPosition cameraPosition1 = new CameraPosition.Builder()
.target(point)
.tilt(90)
.zoom(17)
.build();
mMap.animateCamera(CameraUpdateFactory
.newCameraPosition(cameraPosition1));
return true;
}
});