RouteTrackerLocationDataSource

A location data source that uses a route tracker and a generic location data source to output locations snapped to a route. Setting the RouteTrackerLocationDataSource is optional when desiring to have the location display symbol navigate along a route. Using this object provides the benefit of having the current location snapped to the route polyline during navigation. If the RouteTrackerLocationDataSource is not used, you may notice that the actual GPS location tends to wander off the route polyline due to the accuracy provided by the GPS unit.

No distance tolerance needs to be specified to enable the snapping effect of having the location display symbol follow along the route polyline. An internal algorithm is used by the RouteTrackerLocationDataSource to determine if location is 'on route' or 'off route'. If the location is seen as 'on route' then snapping will occur, otherwise the output location will be the original input GPS location. If it is determined that the tracking along the route is no longer needed the RouteTrackerLocationDataSource's stop method can be called or the LocationDisplay can be reset to a different data source.

To provide some insight on how the RouteTrackerLocationDataSource works, the data source will pass the locations from the LocationDataSource.locationChanged event to the RouteTracker.trackLocation(Location). The TrackingStatus.displayLocation will then be returned in this data source's locationChanged event.

To control the orientation of the location display symbol as it navigates along a route refer to the MapView.locationDisplay class.

Since

200.1.0

Constructors

Link copied to clipboard
constructor(routeTracker: RouteTracker, locationDataSource: LocationDataSource = SystemLocationDataSource())

Creates a RouteTrackerLocationDataSource object.

Inherited properties

Link copied to clipboard
val error: StateFlow<Throwable?>

An error that describes a problem encountered while starting or running the LocationDataSource. This property is used to notify the user about errors that occur in LocationDataSource. Such errors are critical for LocationDataSource and will cause it stop. If LocationDataSource cannot be started, or it stopped after a successful start, this property will store information related to what caused LocationDataSource to stop.

Link copied to clipboard
val headingChanged: SharedFlow<Double>

Set the heading changed callback function for the location data source.

Link copied to clipboard
open val locationChanged: SharedFlow<Location>

A SharedFlow that emits location changes.

Link copied to clipboard

The current status of the location data source. The status indicates if the location data source is starting, started, stopping, stopped, and has failed to start.

Inherited functions

Link copied to clipboard
suspend fun start(): Result<Unit>

Starts the location data source asynchronously and prepares to begin receiving location updates.

Link copied to clipboard
suspend fun stop(): Result<Unit>

Stop the location data source asynchronously.