VehiclePositionStrategy

Strategy for computing the vehicle icon position on the Android Auto map surface.

The MSDK's Navigation.setVehicleHorizontalPosition() and setVehicleVerticalPosition() use fractions relative to the full MapView surface. However, the MapView occupies the entire surface while template UI elements (turn cards, action strips, panels) overlay portions of it. This strategy computes positions that account for the actual visible area.

Implement this interface to customize how the vehicle icon is positioned. Return null from computePosition to skip repositioning for a given state.

Default Behavior

The DefaultVehiclePositionStrategy centers the vehicle horizontally in the unobscured visible area and uses the default vertical position (0.5). It also performs split screen detection during NAVIGATION state.

Disabling

Set SurfaceCallbackConfig.vehiclePositionStrategy to null to disable vehicle repositioning entirely (vehicle stays at the MapView's default center).

See also

Inheritors

Functions

Link copied to clipboard
abstract fun computePosition(visibleArea: Rect, containerWidth: Int, containerHeight: Int, screenState: AndroidAutoScreenState): VehiclePosition?

Computes the vehicle icon position from the visible area and surface dimensions.