Overview

Camera Engine

Before you begin reading this document, you might want to begin with the general overview and basics of the map's camera.

MapboxNavigation creates a SimpleCamera by default that you can access with theMapboxNavigation#getCameraEngine() method.

SimpleCamera extends from Camera and is required to provide values for bearing, tilt, zoom, and a target Point given a RouteInformation.

A RouteInformation object can be created from a DirectionsRoute, Location, or RouteProgress. Depending on which objects are provided, SimpleCamera will return a value for each camera method:

RouteInformation.create(route, location, routeProgress);

For example, if RouteInformation has a DirectionsRoute, the SimpleCamera will return theList of Points based on the route geometry for Camera#overview(RouteInformation routeInformation):

public List<Point> overview(RouteInformation routeInformation) {
...
if (invalidCoordinates) {
buildRouteCoordinatesFromRouteData(routeInformation);
}
return routeCoordinates;
}

You can then use the returned List to update the MapboxMap camera. In this case, you can use the list to build a LatLngBounds that the camera will move to include:

Camera cameraEngine = navigation.getCameraEngine();
List<Point> routePoints = cameraEngine.overview(routeInformation);
LatLngBounds routeBounds = ...
CameraUpdateFactory.newLatLngBounds(routeBounds, padding[0], padding[1], padding[2], padding[3]);
mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(position));

Creating a custom Camera

The Navigation SDK provides a SimpleCamera by default. You're also able to create your own CameraEngine and give it to the Navigation SDK like so: MapboxNavigation#setCameraEngine(CameraEngine cameraEngine).

An example of this would be the DynamicCamera provided by the libandroid-navigation-uilibrary. In DynamicCamera, calculations are being made based on the user's location along the given route.