MapController

interface MapController

Interface for controlling the map from Android Auto.

This interface abstracts the map control functionality needed by Android Auto, allowing different applications to provide their own implementations while sharing the same Android Auto integration code.

Purpose

  • Abstraction: Decouples Android Auto module from specific MapViewModel implementations

  • Reusability: Allows the Android Auto module to be used by different apps

  • MSDK Integration: Designed to be migrated into the MSDK in the future

Methods

The interface exposes only the methods needed by Android Auto:

  • Camera control: centerOn, zoomIn, zoomOut, setZoomLevel, panBy

  • State observation: uiStateSharedFlow for reactive updates

Implementation

Applications should create an adapter that wraps their MapViewModel and implements this interface. Example:

class MapControllerAdapter(private val mapViewModel: MapViewModel) : MapController {
override fun centerOn(longitude: Double, latitude: Double, zoomLevel: Double, tilt: Double) {
mapViewModel.centerOn(longitude, latitude, zoomLevel, tilt)
}
// ... other methods
}

See also

Properties

Link copied to clipboard

Gets the current map state containing camera position, layers, and style information.

Link copied to clipboard

Flow of state updates for reactive observation.

Functions

Link copied to clipboard
abstract fun centerOn(longitude: Double, latitude: Double, zoomLevel: Double = 13.0, tilt: Double = 0.0)

Centers the map on the specified coordinates.

Link copied to clipboard
abstract fun panBy(deltaLon: Double, deltaLat: Double, currentTilt: Double? = null)

Pans the map by the specified offset in geographic coordinates.

Link copied to clipboard
abstract fun setZoomLevel(zoomLevel: Double)

Sets the map zoom level to a specific value.

Link copied to clipboard
abstract fun zoomIn()

Increases the map zoom level by one step.

Link copied to clipboard
abstract fun zoomOut()

Decreases the map zoom level by one step.