Skip To Content ArcGIS for Developers Sign In Dashboard

RouteTracker Class


Uses a location to provide status and progress updates as a route is traversed (by a moving vehicle, for example). More...

Header: #include <RouteTracker>
Since: Esri::ArcGISRuntime 100.6
Inherits: Object

Public Functions

RouteTracker(const RouteResult &routeResult, int routeIndex, QObject *parent = nullptr)
void cancelRerouting()
void disableRerouting() const
TaskWatcher enableRerouting(RouteTask *routeTask, const RouteParameters &routeParameters, ReroutingStrategy strategy, bool visitFirstStopOnStart)
VoiceGuidance *generateVoiceGuidance() const
bool isReroutingEnabled() const
void setVoiceGuidanceUnitSystem(UnitSystem distanceUnit)
TaskWatcher switchToNextDestination()
TaskWatcher trackLocation(const QGeoPositionInfo &gpsLocation)
TrackingStatus *trackingStatus() const
UnitSystem voiceGuidanceUnitSystem()
  • 31 public functions inherited from QObject


void enableReroutingCompleted(QUuid taskId)
void newVoiceGuidance(Esri::ArcGISRuntime::VoiceGuidance *voiceGuidance)
void rerouteCompleted(Esri::ArcGISRuntime::TrackingStatus *trackingStatus, const Esri::ArcGISRuntime::Error &error)
void rerouteStarted()
void switchToNextDestinationCompleted(QUuid taskId)
void trackLocationCompleted(QUuid taskId)
void trackingStatusChanged(Esri::ArcGISRuntime::TrackingStatus *trackingStatus)

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 10 static public members inherited from QObject
  • 9 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

Uses a location to provide status and progress updates as a route is traversed (by a moving vehicle, for example).

RouteTracker can give the time or distance to the next maneuver, notify if the location is off-route, and regenerate a new route if necessary. Basic workflow:

Member Function Documentation

RouteTracker::RouteTracker(const RouteResult &routeResult, int routeIndex, QObject *parent = nullptr)

Constructor that takes a RouteResult and a route index.

The RouteResult must contain at least one Route.



void RouteTracker::cancelRerouting()

Cancels a running reroute task.

If rerouting is in progress, this method will interrupt the background route task process.

void RouteTracker::disableRerouting() const

Disables automatic rerouting.

When disabled, the RouteTracker will not automatically recalculate a route when TrackingStatus::isOnRoute is false.

TaskWatcher RouteTracker::enableRerouting(RouteTask *routeTask, const RouteParameters &routeParameters, ReroutingStrategy strategy, bool visitFirstStopOnStart)

Enables rerouting functionality of route tracker.

Rerouting is initiated automatically when the tracking status is off-route. In order to be considered off-route, the location must be on the transportation network as well as off the current route. If a tracked location is in a parking lot, for example, it is not considered off-route and rerouting will not occur. If the next location is on the network but not on the route, automatic rerouting will begin.

The enableReroutingCompleted signal will emit once the operation is complete.

[signal] void RouteTracker::enableReroutingCompleted(QUuid taskId)

Emitted when the enableRerouting asynchronous operation completes.

VoiceGuidance *RouteTracker::generateVoiceGuidance() const

Returns voice guidance.

The most recent voice guidance based on the last trackLocation. It can be used to repeat last/latest voice guidance.

bool RouteTracker::isReroutingEnabled() const

Returns whether routes are automatically regenerated when tracking status is off-route.

[signal] void RouteTracker::newVoiceGuidance(Esri::ArcGISRuntime::VoiceGuidance *voiceGuidance)

Emitted when there is new voice guidance.

  • voiceGuidance - new voice guidance.

[signal] void RouteTracker::rerouteCompleted(Esri::ArcGISRuntime::TrackingStatus *trackingStatus, const Esri::ArcGISRuntime::Error &error)

Emitted when background rerouting is finished.

  • trackingStatus - current TrackingStatus with recalculated RouteResult.
  • error - populated if error occurs during rerouting, otherwise NULL.

[signal] void RouteTracker::rerouteStarted()

Emitted when background rerouting starts.

void RouteTracker::setVoiceGuidanceUnitSystem(UnitSystem distanceUnit)

Sets the unit system used for generating route guidance to distanceUnit.

Default value is UnitSystem::Metric.

See also voiceGuidanceUnitSystem().

TaskWatcher RouteTracker::switchToNextDestination()

Starts tracking progress to the next destination in the Route.

Use switchToNextDestination when the tracker reports a DestinationStatus::Reached status. Before calling switchToNextDestination make sure that TrackingStatus::remainingDestinationCount > 1. A value of 1 means navigation is proceeding to last destination. This method can also be called after DestinationStatus::Approaching in cases where the location cannot get near enough to the destination point for DestinationStatus::Reached (such as the center of a park or shopping center, for example).

The switchToNextDestinationCompleted signal will emit once the operation is complete.

[signal] void RouteTracker::switchToNextDestinationCompleted(QUuid taskId)

Emitted when the switchToNextDestination asynchronous operation completes.

TaskWatcher RouteTracker::trackLocation(const QGeoPositionInfo &gpsLocation)

Provides route tracking status relative to the provided gpsLocation.

The location generally comes from a GPS but may also be a simulated or manually entered location. It must have valid values for X and Y coordinates, speed (in meters per second), course (in degrees), and a timestamp. Events fired for RouteTracker and TrackingStatus returned when completed.

Method should be called each time a new position is received from the location source (usually once per second).

The trackLocationCompleted signal emits when the operation completes.

[signal] void RouteTracker::trackLocationCompleted(QUuid taskId)

Emitted when the trackLocation asynchronous operation completes.

TrackingStatus *RouteTracker::trackingStatus() const

Returns tracker status for the current location on the route.

[signal] void RouteTracker::trackingStatusChanged(Esri::ArcGISRuntime::TrackingStatus *trackingStatus)

Emitted when trackingStatus changes.

UnitSystem RouteTracker::voiceGuidanceUnitSystem()

Returns the unit system that will be used for generating route guidance, expressed as an enumeration.

See also setVoiceGuidanceUnitSystem.

Feedback on this topic?