MyLocationViewModel

Manages the state and behavior of the My Location control. Provides information about the current follow mode, permission status, and handles user interactions.

Thread Safety

This ViewModel is not thread-safe and must only be accessed from the Main thread.

  • All methods must be called from the Main (UI) thread

  • All StateFlow properties emit values on the Main thread

  • Concurrent access from multiple threads may lead to undefined behavior

Inheritors

Properties

Link copied to clipboard
abstract val followState: StateFlow<CameraFollowState>

Observable state of the current camera follow mode.

Link copied to clipboard
abstract val isEnabled: StateFlow<Boolean>

Observable state indicating whether the My Location control is enabled. When false, the button should appear disabled (e.g., when location source is unavailable).

Link copied to clipboard
abstract val isPermissionRequired: StateFlow<Boolean>

Observable state indicating whether location permission is required.

Functions

Link copied to clipboard
abstract fun onCleared()

Releases resources when the view model is no longer needed.

Link copied to clipboard
abstract fun onClicked()

Called when the user clicks the My Location button.