Last active
January 26, 2019 14:34
-
-
Save nadar71/91b86d6e7a862037717dd26ee0d57e40 to your computer and use it in GitHub Desktop.
Google maps : animate camera moving to a defined target. Working.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* --------------------------------------------------------------------------------------------- | |
* Animating camera to a target point | |
* @param lat | |
* @param lon | |
* --------------------------------------------------------------------------------------------- | |
*/ | |
private void animateCameraTo(double lat, double lon){ | |
final CameraPosition target = | |
new CameraPosition.Builder().target(new LatLng(lat, lon)) | |
.zoom(6f) | |
.bearing(0) | |
.tilt(25) | |
.build(); | |
mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(target), | |
new GoogleMap.CancelableCallback() { | |
@Override | |
public void onFinish() { | |
// Toast.makeText(getBaseContext(), "Animation to target complete", | |
// Toast.LENGTH_SHORT).show(); | |
} | |
@Override | |
public void onCancel() { | |
// Toast.makeText(getBaseContext(), "Animation to Sydney canceled", | |
// Toast.LENGTH_SHORT).show(); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment