Skip to content

Routing is the process of finding the best path from an origin to a destination in a street network.

You can use the arcgis-rest-routing package to access the ArcGIS Routing service.

Steps
  1. Install and reference the arcgis-rest-routing and arcgis-rest-request packages.
  2. Set an access token to authenticate the request.
  3. Define parameters to pass to the service.
  4. Call the service and handle the results.

Routes and directions

Routing finds the best path between locations and considers factors such as speed limits, road conditions, stops, time of day, and traffic. It can also generate driving directions.

Find a route and directions

Learn how to get a route and directions using the solveRoute method.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

import { ApiKeyManager } from "@esri/arcgis-rest-request";
import { solveRoute } from "@esri/arcgis-rest-routing";

const accessToken = "YOUR_ACCESS_TOKEN";
const authentication = ApiKeyManager.fromKey(accessToken);

solveRoute({
  stops: [
    [-117.195677, 34.056383],
    [-117.918976, 33.812092]
  ],
  authentication
}).then((response) => {
  console.log(JSON.stringify(response, null, 2));
});
Go to tutorial

Service areas

Service areas show the distance you can travel on a road network from a location within a time or distance. The areas calculated consider factors such as travel time, distance, and traffic.

Find service areas

Learn how to get five, ten, and fifteen-minute drive time service areas of a location with the serviceArea method.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

import { ApiKeyManager } from "@esri/arcgis-rest-request";
import { serviceArea } from "@esri/arcgis-rest-routing";

const accessToken = "YOUR_ACCESS_TOKEN";
const authentication = ApiKeyManager.fromKey(accessToken);

serviceArea({
  facilities: [
    [-123.1171, 49.2818] // Vancouver
  ],
  authentication
}).then((response) => {
  console.log(JSON.stringify(response, null, 2));
});
Go to tutorial

More resources

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