メインコンテンツまでスキップ

Camera

Navigation SDK UX Framework allows you to fine-tune the default camera parameters to achieve the optimal viewport for your specific needs.

Camera states defaults

When navigation is getting into a particular state the camera has some built-in behavior. You may control options of that behavior with this API. Every NavigationState has corresponding default camera values represented by SimpleDefaults object in DashCameraConfig. By filling available properties in SimpleDefaults object you are able to influence camera options for corresponding state.

Dash.init(
applicationContext = applicationContext,
accessToken = getString(R.string.mapbox_access_token)
) {
camera {
freeDriveDefaults = SimpleDefaults(zoom = 15.0, pitch = 10.0)
freeDrive3DMode = SimpleDefaults(zoom = 18.0, pitch = 60.0)
tripPlanningDefaults = SimpleDefaults(zoom = 17, pitch = 0.0)
activeGuidanceDefaults = SimpleDefaults(zoom = 17, pitch = 45.0)
arrivalDefaults = SimpleDefaults(zoom = 19, pitch = 10.0)
}
}

Camera bounds

A bounding box is a rectangular area defined on the map projection that the camera is restricted to. This is useful when you want to limit user interaction to a specific region, such as a city, country or continent, rather than allowing panning the map across the entire world. If set to null, the camera will not be constrained, and users will be able to explore the full map.

Dash.init(
applicationContext = applicationContext,
accessToken = getString(R.string.mapbox_access_token)
) {
camera {
// USA bounds
cameraBounds = DashCameraBounds(
northeast = Point.fromLngLat(-63.38831162391119,45.35995755169171),
southwest = Point.fromLngLat(-123.18041468544814,32.25704927274879),
)
}
}

Look ahead distance in active guidance

When NavigationState sets to ActiveGuidance and the camera is following the puck, you can configure the distance the camera should look ahead along the route. This distance determines how much of the route (in meters) the camera attempts to frame ahead of the puck—either up to the specified distance or until the next maneuver, whichever comes first.

By default, this value is 1000 meters, which may affect the camera's zoom level in active guidance and override your SimpleDefaults for that state. If you want to prevent this override and keep your default zoom settings, set this parameter to the minimum available value (1.0).

To better understand how this parameter works, refer to the screenshots below:

lookAheadMeters sets to 1200 meters
lookAheadMeters sets to 100 meters
  • In both screenshots, the default zoom level for active guidance sets to 16.5.
  • The dark blue line over the route represents the distance the camera attempts to frame.
  • In the first screenshot (parameter set to 1200), the camera zooms out to fit the longer segment ahead of the puck.
  • In the second screenshot (parameter set to 100), the shorter distance does not affect the zoom level.

Adjust the parameter lookAheadMeters to fine-tune the camera behavior and achieve the experience that fits your use case.

Dash.init(
applicationContext = applicationContext,
accessToken = getString(R.string.mapbox_access_token)
) {
camera {
lookAheadMeters = 1.0
}
}
この{Type}は役に立ちましたか?