Search in sources :

Example 1 with Camera

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);
}
Also used : ProgressChangeListener(com.mapbox.services.android.navigation.v5.routeprogress.ProgressChangeListener) MapboxNavigation(com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation) Test(org.junit.Test)

Example 2 with Camera

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);
}
Also used : ProgressChangeListener(com.mapbox.services.android.navigation.v5.routeprogress.ProgressChangeListener) MapboxNavigation(com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation) Test(org.junit.Test)

Example 3 with Camera

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);
}
Also used : CameraPosition(com.mapbox.mapboxsdk.camera.CameraPosition) Camera(com.mapbox.services.android.navigation.v5.navigation.camera.Camera) Point(com.mapbox.geojson.Point) LatLng(com.mapbox.mapboxsdk.geometry.LatLng)

Example 4 with Camera

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);
        }
    });
}
Also used : CameraPosition(com.mapbox.mapboxsdk.camera.CameraPosition) Camera(com.mapbox.services.android.navigation.v5.navigation.camera.Camera) Point(com.mapbox.geojson.Point) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) MapboxMap(com.mapbox.mapboxsdk.maps.MapboxMap)

Aggregations

Point (com.mapbox.geojson.Point)2 CameraPosition (com.mapbox.mapboxsdk.camera.CameraPosition)2 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)2 MapboxNavigation (com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation)2 Camera (com.mapbox.services.android.navigation.v5.navigation.camera.Camera)2 ProgressChangeListener (com.mapbox.services.android.navigation.v5.routeprogress.ProgressChangeListener)2 Test (org.junit.Test)2 MapboxMap (com.mapbox.mapboxsdk.maps.MapboxMap)1