简体   繁体   English

android相机位置,谷歌地图

[英]android camera position, google maps

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. 我正在尝试一个if语句,但是它不起作用。

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. // if语句在到达第一个位置时更改摄像机的位置,然后将其移至另一个位置。

  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. 注册以回覆onFinish,然后只需呼叫下一个动画即可。 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);

    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM