DefaultTrafficViewModel

Default implementation of TrafficViewModel that integrates with TrafficControlModel.

Listens to the native traffic control model and exposes the current traffic score and status as kotlinx.coroutines.flow.StateFlow. Delegates click actions to the model.

Parameters

map

The map instance to control traffic for.

Constructors

Link copied to clipboard
constructor(map: Map)

Properties

Link copied to clipboard
open override val score: StateFlow<Int?>

Observable state of the current traffic score (congestion level). null means the score is not available (e.g., region without traffic data).

Link copied to clipboard
open override val status: StateFlow<TrafficControlStatus>

Observable state of the current traffic control status. Determines the visual state of the control (enabled, disabled, loading, hidden).

Functions

Link copied to clipboard
open override fun onCleared()

Releases resources when the view model is no longer needed.

Link copied to clipboard
open override fun onClicked()

Called when the user clicks the traffic button. Typically toggles traffic layer visibility on the map.