use of com.mapbox.mapboxsdk.maps.MapboxMap in project mapbox-navigation-android by mapbox.
the class NavigationCamera method animateCameraFromRoute.
/**
* Creates an initial animation with the given {@link RouteInformation#route()}.
* <p>
* This is the first animation that fires prior to receiving progress updates.
* <p>
* If a user interacts with the {@link MapboxMap} while the animation is in progress,
* the animation will be cancelled. So it's important to add the {@link ProgressChangeListener}
* in both onCancel() and onFinish() scenarios.
*
* @param routeInformation with route data
*/
private void animateCameraFromRoute(RouteInformation routeInformation) {
Camera cameraEngine = navigation.getCameraEngine();
Point targetPoint = cameraEngine.target(routeInformation);
LatLng targetLatLng = new LatLng(targetPoint.latitude(), targetPoint.longitude());
double bearing = cameraEngine.bearing(routeInformation);
double zoom = cameraEngine.zoom(routeInformation);
CameraPosition position = new CameraPosition.Builder().target(targetLatLng).bearing(bearing).zoom(zoom).build();
updateMapCameraPosition(position, new MapboxMap.CancelableCallback() {
@Override
public void onCancel() {
navigation.addProgressChangeListener(progressChangeListener);
}
@Override
public void onFinish() {
navigation.addProgressChangeListener(progressChangeListener);
}
});
}
Aggregations