android camera position, google maps

匿名 (未验证) 提交于 2019-12-03 01:44:01

问题:

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

回答1:

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


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!