DefaultNavigationControlsViewModel

class DefaultNavigationControlsViewModel(val map: Map, val navigationManager: NavigationManager, val mapControlsHideTimeoutMillis: Long = 20000) : NavigationControlsViewModel

Default implementation of NavigationControlsViewModel that manages the visibility and state of navigation UI controls. Coordinates the display of various navigation components including dashboard, route overview, better route prompt, traffic line, speed info, and map controls (zoom, compass, my location).

Handles complex visibility logic based on:

  • Navigation state (disabled, free roam, navigation, finished)

  • Route type (car, pedestrian, bicycle, etc.)

  • UI state (dashboard collapsed/expanded, route overview shown)

  • Screen orientation and available space

Important: Call onCleared when this ViewModel is no longer needed to properly release resources and close all connections to prevent memory leaks.

Constructors

Link copied to clipboard
constructor(map: Map, navigationManager: NavigationManager, mapControlsHideTimeoutMillis: Long = 20000)

Properties

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

Observable state indicating whether the better route prompt should be visible. Shown when a better route exists and dashboard is collapsed.

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

Observable state indicating whether the navigation dashboard should be visible. Hidden when navigation is finished, route overview is shown, or when collapsed with better route prompt visible.

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

Observable state indicating whether the finish route control should be visible. Only shown when navigation state is FINISHED.

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

Observable state indicating whether indoor navigation controls should be visible. Activated when navigation detects indoor environment.

Link copied to clipboard
open override val map: Map

The map instance used for displaying navigation.

Link copied to clipboard

Timeout in milliseconds after which map controls auto-hide. Set to 0 to disable auto-hiding. Default is 20000 (20 seconds).

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

Observable state indicating whether map controls (zoom, compass, etc.) should be visible. Automatically hides after mapControlsHideTimeoutMillis unless set to 0.

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

Observable state indicating whether the minimap should be visible. Shown during navigation (not in free roam, indoor, route overview, or finished states).

Link copied to clipboard
val navigationManager: NavigationManager

Manages the navigation state and route information.

Link copied to clipboard
open override val navigatorState: StateFlow<State>

Observable state of the current navigation state. Can be DISABLED, FREE_ROAM, NAVIGATION, or FINISHED.

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

Observable state indicating whether the route overview mode is active. When true, most other controls are hidden to show the full route.

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

Observable state indicating whether the speed info should be visible. Shown for car, public transport, bicycle, and scooter routes.

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

Observable state indicating whether the traffic button should be visible.

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

Observable state indicating whether the traffic line should be visible. Shown during navigation (not in free roam, indoor, route overview, or finished states).

Functions

Link copied to clipboard
open override fun onCleared()

Cleans up all resources and cancels active coroutines. Must be called when the ViewModel is no longer needed to prevent memory leaks. This includes canceling timers, closing navigation connections, and clearing references.

Link copied to clipboard
open override fun onMapControlsAreaTouched()

Called when the map controls area is touched. Shows map controls and starts a timer to hide them after the configured timeout. If mapControlsHideTimeoutMillis is 0, map controls will not auto-hide.

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

Updates the dashboard collapsed state. When collapsed with a better route available, the better route prompt is shown instead.

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

Updates whether a better route is available. Affects dashboard and better route prompt visibility.

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

Updates the free roam navigation state. In free roam mode, traffic line is hidden and specific map controls may appear.

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

Updates the minimap visibility state.

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

Updates whether route overview mode is active. In route overview, most controls are hidden to show the full route.