Routing

Routing is the process of finding the best path from an origin to a destination in a street network. Routing takes into consideration many different data parameters in the street network such as speed limit, number of lanes, and time of day. Routing can also take into consideration other real-time data such as road conditions, accidents, and other barriers.

You can use the routing package from ArcGIS REST JS to access the routing service to build applications that:

  • Find the shortest path from an origin to a destination.
  • Find the quickest path to multiple destinations.
  • Determine the best sequence to visit multiple destinations.
  • Generate driving directions in multiple languages.

To learn more, visit the Routing chapter in the Mapping APIs and location services guide.

How to access the routing service

To access the service with ArcGIS REST JS, you typically perform the following steps:

  1. Reference the appropriate package.
  2. Set the API key to authenticate the request.
  3. Define parameters to pass to the service.
  4. Call the service and handle the results.

Example

In this example, you use the solveRoute operation to determine how to get from one location to another.

Use dark colors for code blocksCopy
          
1
2
3
4
5
6
7
8
9
10
import { ApiKeyManager } from "@esri/arcgis-rest-request";
import { solveRoute } from "@esri/arcgis-rest-routing";

solveRoute({
  stops: [
    [-117.195677, 34.056383],
    [-117.918976, 33.812092]
  ],
  authentication: ApiKeyManager.fromKey("YOUR_API_KEY")
});

To learn more, go to the Find a route and directions tutorial.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.