Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've found that using the optional callback as a final parameter to manifest a recursive solution provides smooth animation. This code zooms in, changes angle for a panoramic spin, then zooms in again; it doesn't like it, though, when the initial parameters and the initial callback are identical; I'm sure there's a better way to call the recursion, but hopefully this can give you an idea of how you can animate functionally:</p> <pre><code> //initial zoom static final int initZoom = 8; //steps the zoom int stepZoom = 0; // number of steps in zoom, be careful with this number! int stepZoomMax = 5; //number of .zoom steps in a step int stepZoomDetent = (18 - initZoom) / stepZoomMax; //when topause zoom for spin int stepToSpin = 4; //steps the spin int stepSpin = 0; //number of steps in spin (factor of 360) int stepSpinMax = 4; //number of degrees in stepSpin int stepSpinDetent = 360 / stepSpinMax; Intent detailIntent; Intent intent; Marker marker; final int mapHopDelay = 2000; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map_affirm); try {MapsInitializer.initialize(this);} catch (GooglePlayServicesNotAvailableException impossible) { /* Impossible */ Log.e(TAG, "the impossible occurred");} intent = this.getIntent(); latLng = new LatLng(intent.getDoubleExtra("Latitude", 0.0), intent.getDoubleExtra("Longitude", 0.0)); map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); map.animateCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.builder() .target(latLng) .zoom(initZoom-1) .build()) , mapHopDelay , cameraAnimation ); marker = map.addMarker(new MarkerOptions() .draggable(true) .position(latLng) .title("Location of Photographer")); } public CancelableCallback cameraAnimation = new CancelableCallback(){ @Override public void onFinish() { if (stepZoom &lt; stepZoomMax &amp;&amp; stepZoom != stepToSpin) { stepZoom++; map.animateCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.builder() .target(latLng) .zoom(initZoom + (stepZoomDetent * (stepZoom - 1))) // .bearing(40*aniStep) // .tilt(60) .build()), mapHopDelay, cameraAnimation); } else if (stepZoom &gt;= stepZoomMax)// ending position hard coded for this application {map.animateCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.builder() .target(latLng) .zoom(18) // .bearing(0) .tilt(0) .build())); } else { if (stepSpin &lt;= stepSpinMax) { stepSpin++; map.animateCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.builder() .target(latLng) .zoom(initZoom + stepZoomDetent * stepZoom) .bearing(stepSpinDetent * (stepSpin - 1)) .tilt(60) .build()), mapHopDelay, cameraAnimation); } else { stepZoom++; map.animateCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.builder() .target(latLng) .zoom(initZoom + stepZoomDetent * stepZoom) .bearing(0) .tilt(0) .build()), mapHopDelay, cameraAnimation); } } } @Override public void onCancel() {} }; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload