DefaultMapControlsViewModel

class DefaultMapControlsViewModel(val map: Map, navigationManager: NavigationManager) : MapControlsViewModel

Default implementation of MapControlsViewModel.

This ViewModel manages the visibility of map controls based on available space and navigation state. For proper operation, the free roam state must be set via setIsFreeRoam method, which affects the visibility of certain controls like the add road event button.

Constructors

Link copied to clipboard
constructor(map: Map, navigationManager: NavigationManager)

Properties

Link copied to clipboard
open override val addRoadEventButtonVisibility: StateFlow<Boolean>

Observable state indicating whether the add road event button should be visible. Shown when all conditions are met:

Link copied to clipboard
open override val compassVisibility: StateFlow<Boolean>

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

Link copied to clipboard
open override 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
open override 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
open override val map: Map

The map instance used for map controls.

Link copied to clipboard
open override 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
open override 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
open override 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
open override fun onCleared()

Cleans up resources and closes all connections. Must be called when the ViewModel is no longer needed to prevent memory leaks.

Link copied to clipboard
open override fun setAddRoadEventButtonHeight(height: Int)

Sets the measured height of the add road event button. Used for calculating visibility based on available space.

Link copied to clipboard
open override fun setCompassHeight(height: Int)

Sets the measured height of the compass control. Used for calculating visibility based on available space.

Link copied to clipboard
open override fun setFollowHeight(height: Int)

Sets the measured height of the my location (follow) button. Used for calculating visibility based on available space.

Link copied to clipboard
open override fun setIsFreeRoam(value: Boolean)

Updates the free roam state which affects the visibility of certain controls. In free roam mode, the add road event button may be shown if space permits.

Link copied to clipboard
open override fun setMapControlsAreaHeight(height: Int)

Sets the total available height for map controls area. This triggers recalculation of which controls can fit in the available space.

Link copied to clipboard
open override fun setTrafficAndParkingHeight(height: Int)

Sets the measured height of the traffic and parking control. Used for calculating visibility based on available space.

Link copied to clipboard
open override fun setZoomHeight(height: Int)

Sets the measured height of the zoom controls. Used for calculating visibility based on available space.