MapControlsViewModel

Manages the visibility and state of map controls (zoom, compass, my location, etc.). Handles visibility logic based on available space and route type.

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 addRoadEventButtonVisibility: StateFlow<Boolean>

Observable state indicating whether the add road event button should be visible. Only shown in free roam mode when there's sufficient space.

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

Observable state indicating whether the compass control should be visible. Visibility depends on available vertical space.

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

Observable state indicating whether the follow button can be hidden. True for non-pedestrian routes, false for pedestrian routes.

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

Observable state indicating whether the my location (follow) button should be visible. This control has the highest priority and is shown when any space is available.

Link copied to clipboard
abstract val map: Map

The map instance used for map controls.

Link copied to clipboard
abstract val mapControlsUnusedHeight: StateFlow<Int?>

Observable state of the remaining vertical space after all visible controls are placed. Null if controls haven't been measured yet, otherwise the unused height in pixels.

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

Observable state indicating whether the traffic and parking button should be visible. Visibility depends on available space and whether the route is pedestrian.

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

Observable state indicating whether the zoom controls should be visible. Visibility depends on available vertical space.

Functions

Link copied to clipboard
abstract fun onCleared()

Releases resources when the view model is no longer needed.

Link copied to clipboard
abstract fun setAddRoadEventButtonHeight(height: Int)

Sets the measured height of the add road event button.

Link copied to clipboard
abstract fun setCompassHeight(height: Int)

Sets the measured height of the compass control.

Link copied to clipboard
abstract fun setFollowHeight(height: Int)

Sets the measured height of the my location (follow) button.

Link copied to clipboard
abstract fun setIsFreeRoam(value: Boolean)

Updates the free roam state which affects the visibility of certain controls.

Link copied to clipboard
abstract fun setMapControlsAreaHeight(height: Int)

Sets the total available height for map controls area.

Link copied to clipboard
abstract fun setTrafficAndParkingHeight(height: Int)

Sets the measured height of the traffic and parking control.

Link copied to clipboard
abstract fun setZoomHeight(height: Int)

Sets the measured height of the zoom controls.