How to build a routing app

1. Choose a type of routing

The first step is to select the correct service endpoint and the operation you need to use. Each routing operation has a direct and job request endpoint. Use a direct request for shorter transactions with less than 150 stops. For longer transactions, use a job request. To learn more about direct and job requests, go to the topic page for each operation below.

Direct request

Use dark colors for code blocksCopy
1
https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve?<parameters>
Job request
Use dark colors for code blocksCopy
1
https://logistics.arcgis.com/arcgis/rest/services/World/Route/GPServer/FindRoutes/submitJob?<parameters>

OperationUse case
Simple routingFind the best path from an origin to a destination for a single individual or vehicle.
Optimized routingFind the best path to travel for a single vehicle when you need to stop at multiple destinations.
Fleet routingDetermine the most effective routes for a set of vehicles that need to visit a set of locations, while also minimizing transportation costs.
Closest facility routingFind one or more nearby facilities from incidents based on travel time or travel distance.
Service areasCreate an isochrone that represents the distance that can be reached when driving or walking on a street network.
Travel cost matrixCreate a table or a matrix containing the cost, such as the travel time or travel distance, from multiple origins to multiple destinations
Location-allocationAllocate demand to existing locations and find one or more new locations to maximize the number of customers that walk to a location.

2. Define input parameters

The next step is to provide the required input parameters for the operation. Most operations require stops, facilities, or orders to define the locations to visit to along a route. Depending on the operation, other parameters may be required. The tables below show the typical input parameters for direct requests.

NameDescriptionExamples
stopsThe two or more locations that need to be visited in the route.stops=-117,34; -117.5,34.5
travelModeThe mode of transportation such as driving a car or a truck or walking.travelMode=JSON Object
startTimeThe time at which travel begins from the input stops. You can also specify a value of now, to set the depart time to the current time.startTime=now
returnDirectionsGenerate driving directions for each route.returnDirections=true
directionsLanguageThe language to be used when generating driving directions.directionsLanguage=es

3. Make a request

The final step is to make a request to the routing service using an ArcGIS Maps SDK, scripting API, or open source library. In general, you:

  1. Reference the service or import the relevant packages or modules.
  2. Set the parameters for the operation.
  3. Set the access token.

APIs

ArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for .NETArcGIS Maps SDK for SwiftArcGIS Maps SDK for KotlinArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)ArcGIS Maps SDK for Qt (QML)ArcGIS API for PythonArcGIS REST JSEsri LeafletMapLibre GL JSOpenLayersCesiumJS
Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
      function getRoute() {

        const routeUrl = "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World";

        const routeParams = new RouteParameters({
          stops: new FeatureSet({
            features: view.graphics.toArray()
          }),
          returnDirections: true,
          directionsLanguage: "es"
        });

        route.solve(routeUrl, routeParams)
          .then((data)=> {
            if (data.routeResults.length > 0) {
              showRoute(data.routeResults[0].route);
              showDirections(data.routeResults[0].directions.features);
            }
          })
          .catch((error)=>{
            console.log(error);
          })
      }

REST API

cURLcURLHTTP
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
curl https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve? \
-d "f=json"
-d "token=<ACCESS_TOKEN>"
-d "stops=-122.68782,45.51238;-122.690176,45.522054;-122.614995,45.526201"
-d "startTime=now"
-d "returnDirections=true"
-d "directionsLanguage=es"

Additional resources

Tutorials

Find a route and directions

Find a route and directions with the routing service.


Find service areas

Create an isochrone with driving distance with the routing service.


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