DefaultRouteEditorViewModel

class DefaultRouteEditorViewModel(val routeEditor: RouteEditor, val allowedTransportTypes: EnumSet<TransportMode> = EnumSet.allOf(TransportMode::class.java), val briefRouteDurationProvider: BriefRouteDurationProvider? = null, val routeSearchOptionsProvider: RouteSearchOptionsProvider = DefaultRouteSearchOptionsProvider, val scheduleProvider: PublicTransportScheduleProvider? = null, val onStartNavigation: (TrafficRoute, RouteBuildOptions) -> Unit = { _, _ -> }, onChangeRoute: () -> Unit = { }) : RouteEditorViewModel, Closeable

Default implementation of RouteEditorViewModel that manages the route editor UI state.

Handles route building, transport mode switching, intermediate point management, and ETA fetching. Implements Closeable — must be closed when no longer needed to release the underlying coroutine scope.

Parameters

routeEditor

the RouteEditor instance used for route building.

allowedTransportTypes

set of transport modes available in the UI.

briefRouteDurationProvider

optional provider for ETAs of non-selected transport modes.

routeSearchOptionsProvider

provider for creating route search options per transport mode.

scheduleProvider

optional provider for public transport schedule info.

onStartNavigation

callback invoked when the user starts navigation on a route.

onChangeRoute

callback invoked when the route configuration changes.

Constructors

Link copied to clipboard
constructor(routeEditor: RouteEditor, allowedTransportTypes: EnumSet<TransportMode> = EnumSet.allOf(TransportMode::class.java), briefRouteDurationProvider: BriefRouteDurationProvider? = null, routeSearchOptionsProvider: RouteSearchOptionsProvider = DefaultRouteSearchOptionsProvider, scheduleProvider: PublicTransportScheduleProvider? = null, onStartNavigation: (TrafficRoute, RouteBuildOptions) -> Unit = { _, _ -> }, onChangeRoute: () -> Unit = { })

Properties

Link copied to clipboard

Optional provider for fetching ETAs for non-selected transport modes. When provided, enables displaying estimated times for all transport modes in the UI. Note: This will make additional API requests which may count towards your usage quota. The currently selected transport mode's ETA is always obtained from the full route.

Link copied to clipboard
val onStartNavigation: (TrafficRoute, RouteBuildOptions) -> Unit
Link copied to clipboard
val routeEditor: RouteEditor
Link copied to clipboard

Provider for creating route search options for different transport modes. Can be customized by implementing the interface and overriding specific methods for the transport modes that need custom routing behavior.

Link copied to clipboard

Optional provider for fetching public transport schedule information. When provided, enables async schedule loading for public transport route cards.

Link copied to clipboard
open override val uiState: State<RouteEditorUiState>

Current UI state containing route information, selected transport mode, point titles, and route options.

Functions

Link copied to clipboard
open override fun clearRoute()

Removes all waypoints from the current route.

Link copied to clipboard
open override fun close()
Link copied to clipboard

Updates the order of intermediate points and recalculates the route.

Link copied to clipboard
open override fun onStartNavigation()

Initiates navigation with the currently selected route.

Link copied to clipboard
open override fun recalculateRoutes()

Recomputes route paths using current route points and settings.

Link copied to clipboard
open override fun selectRoute(index: Int)

Selects a route from the list of calculated route options.

Link copied to clipboard
open override fun selectTransportMode(mode: TransportMode)

Changes the transport mode and recalculates the route.

Link copied to clipboard
open override fun setPoints(startPoint: RouteUiPoint, finishPoint: RouteUiPoint, intermediatePoints: List<RouteUiPoint>, mode: TransportMode?)

Sets the route points and optionally the transport mode.

Link copied to clipboard
open override fun swapStartAndDestinationPoints()

Swaps the start and destination points and recalculates the route.