Android的摄像头位置,谷歌地图 [英] android camera position, google maps
本文介绍了Android的摄像头位置,谷歌地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我有以上code这动画的相机到一定位置。反正是有,我可以一旦它从第一的位置完成了动画摄像机位置移动到不同的位置?我想if语句,但它不工作。
例如:
CameraPosition cameraPosition =新CameraPosition.Builder()
.TARGET(1stlocation)
.zoom(12)
.bearing(300)
.tilt(30)
。建立();
map.addMarker(新的MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.green))
.POSITION(第一位置)
.flat(真)
.rotation(245));
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)
30000,NULL);
// if语句来改变摄像机的位置,当它到达第一位置,然后将其移动到另一
CameraPosition坎波斯= map.getCameraPosition(); 如果(坎波斯== cameraPosition)
{ map.moveCamera(CameraUpdateFactory.newLatLngZoom(2ndloc,3));
}
解决方案
注册一个回调onFinish,然后就打电话给你的下一个动画。你可以用一个简单的计数器链它们。
map.animateCamera(CameraUpdateFactory.newLatLng(cameraPositiom),新CancelableCallback(){ @覆盖
公共无效onFinish(){
googleMap.getUiSettings()setScrollGesturesEnabled(真)。
} @覆盖
公共无效onCancel(){
googleMap.getUiSettings()setAllGesturesEnabled(真)。 }
});
Hi I have the above code which animates the camera to a certain location. Is there anyway that I could move the camera position to a different position once it has finished the animation from the first location ? I am trying an if statement but it doesn't work.
for instance:
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(1stlocation)
.zoom(12)
.bearing(300)
.tilt(30)
.build();
map.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.green))
.position(1st Location)
.flat(true)
.rotation(245));
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition ),
30000, null);
//if statement to change the position of the camera when it reaches the first location then move it to another.
CameraPosition campos = map.getCameraPosition();
if(campos == cameraPosition )
{
map.moveCamera(CameraUpdateFactory.newLatLngZoom(2ndloc, 3));
}
解决方案
Register for a call back onFinish, then just call your next animation. You could chain them with a simple counter.
map.animateCamera(CameraUpdateFactory.newLatLng(cameraPositiom), new CancelableCallback(){
@Override
public void onFinish(){
googleMap.getUiSettings().setScrollGesturesEnabled(true);
}
@Override
public void onCancel(){
googleMap.getUiSettings().setAllGesturesEnabled(true);
}
});
这篇关于Android的摄像头位置,谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文