use of com.mapbox.services.android.navigation.v5.navigation.camera.Camera in project mapbox-navigation-android by mapbox.
the class NavigationCameraTest method onStartWithNullRoute_progressListenerIsAdded.
@Test
public void onStartWithNullRoute_progressListenerIsAdded() throws Exception {
MapboxNavigation navigation = mock(MapboxNavigation.class);
ProgressChangeListener listener = mock(ProgressChangeListener.class);
NavigationCamera camera = buildCamera(navigation, listener);
camera.start(null);
verify(navigation, times(1)).addProgressChangeListener(listener);
}
use of com.mapbox.services.android.navigation.v5.navigation.camera.Camera in project mapbox-navigation-android by mapbox.
the class NavigationCameraTest method onResumeWithNullLocation_progressListenerIsAdded.
@Test
public void onResumeWithNullLocation_progressListenerIsAdded() throws Exception {
MapboxNavigation navigation = mock(MapboxNavigation.class);
ProgressChangeListener listener = mock(ProgressChangeListener.class);
NavigationCamera camera = buildCamera(navigation, listener);
camera.resume(null);
verify(navigation, times(1)).addProgressChangeListener(listener);
}
use of com.mapbox.services.android.navigation.v5.navigation.camera.Camera in project mapbox-navigation-android by mapbox.
the class NavigationCamera method animateCameraFromLocation.
/**
* Creates an animation with the given {@link RouteInformation#location()}.
* <p>
* This animation that fires for new progress update.
*
* @param routeInformation with location data
*/
private void animateCameraFromLocation(RouteInformation routeInformation) {
Camera cameraEngine = navigation.getCameraEngine();
Point targetPoint = cameraEngine.target(routeInformation);
LatLng target = new LatLng(targetPoint.latitude(), targetPoint.longitude());
double bearing = cameraEngine.bearing(routeInformation);
float tilt = (float) cameraEngine.tilt(routeInformation);
double zoom = cameraEngine.zoom(routeInformation);
CameraPosition position = new CameraPosition.Builder().target(target).bearing(bearing).tilt(tilt).zoom(zoom).build();
easeMapCameraPosition(position);
}
use of com.mapbox.services.android.navigation.v5.navigation.camera.Camera 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