View on GitHub
import InlineCode from "@esri-dx/starship-doc-components/components/InlineCode.astro";

Use a routing service to navigate between two points.

Image of navigate route

Use case

Navigation is often used by field workers while traveling between two points to get live directions based on their location.

How to use the sample

Tap “Navigate” to simulate traveling and to receive directions from a preset starting point to a preset destination. Tap “Reset” to start the simulation from the beginning.

How it works

  1. Create an
    using a URL to an online route service.
  2. Generate default
    using
    .
  3. Set
    ,
    , and
    on the parameters to
    .
  4. Assign all
    objects to the route parameters using
    .
  5. Solve the route using
    to get a
    .
  6. Create an
    using the route result, and the index of the desired route to take.
  7. Create a
    with the route tracker and a
    object to snap the location display to the route.
  8. Use
    to be notified of
    changes, and use them to display updated route information.
    includes a variety of information on the route progress, such as the remaining distance, remaining geometry or traversed geometry (represented by an
    ), or the remaining time (
    ), amongst others.
  9. Use
    to be notified of new voice guidances. From the voice guidance, get the
    representing the directions and use a text-to-speech engine to output the maneuver directions.
  10. You can also query the tracking status for the current
    index, retrieve that maneuver from the
    , and get its direction text to display in the GUI.
  11. To establish whether the destination has been reached, get the
    from the tracking status. If the destination status is
    and the
    is 1, you have arrived at the destination and can stop routing. If there are several destinations on your route and the remaining destination count is greater than 1, switch the route tracker to the next destination.

Relevant API

  • DestinationStatus
  • DirectionManeuver
  • Location
  • LocationDataSource
  • Route
  • RouteParameters
  • RouteTask
  • RouteTracker
  • RouteTrackerLocationDataSource
  • SimulatedLocationDataSource
  • Stop
  • VoiceGuidance

About the data

The route taken in this sample goes from the San Diego Convention Center, site of the annual Esri User Conference, to the Fleet Science Center, San Diego.

Tags

directions, maneuver, navigation, route, turn-by-turn, voice