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
}