Fleet routing

Turn-by-turn directions and routes created for two trucks making six deliveries using the routing service

What is fleet routing?

Fleet routing, also know as a vehicle routing problem (VRP), is the process of minimizing the overall transportation cost while servicing a set of orders using a fleet of vehicles.

You can use fleet routing to build applications such as:

  • A large furniture store might deliver goods from a central warehouse location.
  • A specialized grease recycling company might route trucks from a facility to pick up used grease from restaurants.
  • A health department might schedule daily inspection visits for each of its health inspectors.
  • A health care provider might want to find best routes to transport people from their homes to different hospitals for medical appointments.

The goal of the fleet routing service is to find what orders should be serviced by each vehicle and in what sequence the orders should be visited. The service can take into account many additional business constraints such as:

  • Matching vehicle capacities with order quantities.
  • Providing a high level of customer service by honoring any time windows on orders.
  • Pairing orders so they are serviced by the same route.
  • Giving breaks to drivers.

How fleet routing works

The typical workflow for determining fleet routes is to:

  1. Define the locations to visit (orders).
  2. Define the start and end location for vehicles (depots).
  3. Define the travel mode (driving a car or truck).
  4. Use the service to find the best routes and directions for all vehicles.

URL requests

You can perform fleet routing by making an HTTPS request to the Fleet Routing service execute operation or by using client APIs. Specify the orders, depots, routes, and optionally, additional parameters such as the travel mode used when finding routes or if you need to generate driving directions.

Direct and job

The service supports both direct and job requests. Both Direct and Job request types support all of the capabilities of the service, however, Direct is better suited for shorter requests, and Job is better suited for longer, more complex requests.

The request you choose depends on the complexity of the problem you are trying solve and limits of the request.

Request limits

LimitDirectJob
Maximum number of orders:1002,000
Maximum number of routes:2100
Maximum number of orders per route:100200
Maximum transaction time:5 minutes4 hours
Maximum number of point barriers:250250
Maximum number of street features intersected by polyline barriers:500500
Maximum number of street features intersected by polygon barriers:2,0002,000
Maximum straight-line distance for the walking travel mode: (If the straight-line distance between any orders or depots is greater than this limit, the analysis will fail when the walking restriction is used.)27 miles (43.45 kilometers)27 miles (43.45 kilometers)
Force hierarchy beyond a straight-line distance of: (If the straight-line distance between any orders or depots is greater than the limit shown here, the analysis uses hierarchy, even if the travel_mode defines not to use hierarchy.)50 miles (80.46 kilometers)50 miles (80.46 kilometers)
Maximum snap tolerance: (If the distance between an input point and its nearest traversable street is greater than the distance specified here, the point is excluded from the analysis.)12.42 miles (20 kilometers)12.42 miles (20 kilometers)
Maximum number of directions features that can be returned:10,000200,000
Direct requestJob request

URL

 
1
https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblemSync/GPServer/EditVehicleRoutingProblem/execute?<parameters>

Use for shorter transactions that complete in less than 5 minutes and optimize up to 2 routes and 100 orders.

Key parameters

Name (Direct)Description
orders

A list of locations to visit with attributes such as the order name or the time required to complete the delivery at each order.

depots

The start and the return location for the vehicles.

routes

The characteristics and constraints for each vehicle. For example, the start and the return depot name, the maximum number of orders a vehicle is allowed to visit, and the total time the vehicle is allowed to operate.

travel_mode

The mode of transportation such as driving a car or a truck.

default_date

The date on which all of your routes start.

populate_directions

Generate driving directions for the routes.

Additional parameters:

Solve complex fleet routing scenarios by specifying additional inputs such as route_renewals, order_pairs, breaks, route_zones or setting additional constraints when finding routes using time_window_factor, excess_transit_factor, spatially_cluster_routes.

URL

 
1
https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/submitJob?<parameters>

Use for longer transactions that can take up to 4 hours and optimize up to 100 routes and 2,000 orders.

Key parameters

Name (Job)Description
orders

A list of locations to visit with attributes such as the order name or the time required to complete the delivery at each order.

depots

The start and the return location for the vehicles.

routes

The characteristics and constraints for each vehicle. For example, the start and the return depot name, the maximum number of orders a vehicle is allowed to visit, and the total time the vehicle is allowed to operate.

travel_mode

The mode of transportation such as driving a car or a truck.

default_date

The date on which all of your routes start.

populate_directions

Generate driving directions for the routes.

Additional parameters:

Solve complex fleet routing scenarios by specifying additional inputs such as route_renewals, order_pairs, breaks, route_zones or setting additional constraints when finding routes using time_window_factor, excess_transit_factor, spatially_cluster_routes.

Examples

Direct: Find optimized routes and directions

In this example, use the fleet routing service to find optimized routes and directions for an appliance delivery company using two vehicles which start from a warehouse and return to the same location at the end of the working day.

In this scenario, two vehicles will depart from a warehouse located in Santa Monica, California. Each vehicle has a capacity of four appliances. There are a total of six restaurants to visit and it takes ten minutes at complete the delivery at each restaurant. Each vehicle needs to return in one hour and can only visit a maximum of three restaurants in total.

The response contains a list of results describing various outputs such as:

  • Set of stops that shows the route assignment.
  • Set of routes that shows the overall time and distance.
  • Set of directions for each route (if you requested to populate directions).

APIs

ArcGIS JS APIEsri LeafletMapbox GL JSOpenLayersArcGIS REST JSArcGIS Python API
                                                                                                                                                                                                                                                          
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>ArcGIS Developer Guide: Fleet routing</title>
  <style>
    html, body, #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
  </style>

  <link rel="stylesheet" href="https://js.arcgis.com/4.20/esri/themes/light/main.css">
  <script src="https://js.arcgis.com/4.20/"></script>

  <script>
   require([
    "esri/config",
    "esri/Map",
    "esri/views/MapView",
    "esri/Graphic",
    "esri/layers/GraphicsLayer",
    "esri/widgets/ScaleBar",
    "esri/rest/geoprocessor",
    "esri/rest/support/FeatureSet"
  ],(
    Map,
  )=> {
    esriConfig.apiKey = "YOUR_API_KEY";
    const depotLocation = {
      type: "point",
      latitude: 34.037555,
      longitude: -118.46963,
    const depotLayer = new GraphicsLayer();
    const routeLayer = new GraphicsLayer();
    const deliveryLayer = new GraphicsLayer();
    const map = new Map({
      basemap: "arcgis-navigation",
      layers: [routeLayer, deliveryLayer, depotLayer],
    const view = new MapView({
      container: "viewDiv",
      center: [-118.496, 34.026],
      scale: 45000,
      constraints: {
        snapToZoom: false
      snapToZoom: false
    view.ui.add(new ScaleBar({ view }), "bottom-right");
    view.when(() => {
    function showDepot(point) {
      const longitude = point.longitude.toFixed(5);
      const latitude = point.latitude.toFixed(5);
        new Graphic({
          attributes: {
            Trucks: 2,
            Deliveries: 6
          geometry: point,
          symbol: {
            type: "web-style",
            name: "bus-station",
            styleName: "Esri2DPointSymbolsStyle"
          popupTemplate: {
            title: "Depot",
            content: `Trucks: 2<br>Deliveries: 6<br>Longitude: ${longitude}°<br>Latitude: ${latitude}°`
    async function getfleetRoutes() {
      const orders = new FeatureSet({
        features: [
            attributes: { Name: "Father's Office", ServiceTime: 10 },
            geometry: { type: "point", x: -118.498406, y: 34.029445 }
            attributes: { Name: "R+D Kitchen", ServiceTime: 10 },
            geometry: { type: "point", x: -118.495788, y: 34.032339 }
            attributes: { Name: "Pono Burger", ServiceTime: 10 },
            geometry: { type: "point", x: -118.489469, y: 34.019 }
            attributes: { Name: "Il Ristorante di Giorgio Baldi", ServiceTime: 10 },
            geometry: { type: "point", x: -118.518787, y: 34.028508 }
            attributes: { Name: "Milo + Olive", ServiceTime: 10 },
            geometry: { type: "point", x: -118.476026, y: 34.037572 }
            attributes: { Name: "Dialogue", ServiceTime: 10 },
            geometry: { type: "point", x: -118.495814, y: 34.017042 }
      const depots = new FeatureSet({
        features: [
            attributes: { Name: "Bay Cities Kitchens and Appliances" },
            geometry: { type: "point", x: -118.46963, y: 34.037555 }
      const routes = new FeatureSet({
        features: [
            attributes: {
              Name: "Route 1",
              Description: "vehicle 1",
              StartDepotName: "Bay Cities Kitchens and Appliances",
              EndDepotName: "Bay Cities Kitchens and Appliances",
              Capacities: "4",
              MaxOrderCount: 3,
              MaxTotalTime: 60
            attributes: {
              Name: "Route 2",
              Description: "vehicle 2",
              StartDepotName: "Bay Cities Kitchens and Appliances",
              EndDepotName: "Bay Cities Kitchens and Appliances",
              Capacities: "4",
              MaxOrderCount: 3,
              MaxTotalTime: 60

      const geoprocessorUrl = "https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblemSync/GPServer/EditVehicleRoutingProblem"

      const params = {
        orders,                    // Feature Set
        depots,                    // Feature Set
        routes,                    // Feature Set
        populate_directions: true  // "Generate driving directions for the routes"
      };

      const { results } = await geoprocessor.execute(geoprocessorUrl, params);

      const outStops = results[1].value.features;  // Graphics[]
      const outRoutes = results[2].value.features; // Graphics[]

      showStops(outStops);
      showRoutes(outRoutes);
    }
    function showStops(stops) {
      for (let stop of stops) {
        const { SnapY, SnapX, RouteName, Sequence} = stop.attributes;
          geometry: {
            type: "point",
            latitude: SnapY,
            longitude: SnapX
          symbol: {
            type: "simple-marker",
            color: [255, 255, 255],
            outline: {
              color: [0, 0, 0],
              width: 1
            size: "18px"
          popupTemplate: {
            title: "{Name}",
            content: `${RouteName}<br>Stop: ${parseInt(Sequence) - 1}<br>Delivery Items: 1`
      const labels = stops.map((stop) => stop.clone());
      for (let label of labels) {
          symbol: {
            type: "text",
            text: label.attributes.Sequence - 1,
            font: { size: 11, weight: "bold" },
            yoffset: -4,
            color: [50, 50, 50]
          popupTemplate: null
    function showRoutes(routes) {
      for (let route of routes) {
          type: "simple-line",
          color:
            route.attributes.Name === "Route 1"
              ? [50, 150, 255, 0.75]
              : [180, 69, 255, 0.75],
          width: "4px"
  </script>
</head>
<body>
  <div id="viewDiv"></div>
</body>
</html>

REST API

RequestResponse
cURLHTTP
       
1
2
3
4
5
6
7
curl https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblemSync/GPServer/EditVehicleRoutingProblem/execute? \
-d "f=json" \
-d "token=<ACCESS_TOKEN>" \
-d "orders={'type':'features','features':[{'attributes':{'Name':'Father\'s Office','ServiceTime':10},'geometry':{'x':-118.498406,'y':34.029445}},{'attributes':{'Name':'R+D Kitchen','ServiceTime':10},'geometry':{'x':-118.495788,'y':34.032339}},{'attributes':{'Name':'Pono Burger','ServiceTime':10},'geometry':{'x':-118.489469,'y':34.019000}},{'attributes':{'Name':'Il Ristorante di Giorgio Baldi','ServiceTime':10},'geometry':{'x':-118.518787,'y':34.028508}},{'attributes':{'Name':'Milo + Olive','ServiceTime':10},'geometry':{'x':-118.476026,'y':34.037572}},{'attributes':{'Name':'Dialogue','ServiceTime':10},'geometry':{'x':-118.495814,'y':34.017042}}]}" \
-d "depots={'type':'features','features':[{'attributes':{'Name':'Bay Cities Kitchens and Appliances'},'geometry':{'x':-118.469630,'y':34.037555}}]}" \
-d "routes={'features':[{'attributes':{'Name':'Route 1','Description':'vehicle 1','StartDepotName':'Bay Cities Kitchens and Appliances','EndDepotName':'Bay Cities Kitchens and Appliances','Capacities':'4','MaxOrderCount':3,'MaxTotalTime':60,}},{'attributes':{'Name':'Route 2','Description':'vehicle 2','StartDepotName':'Bay Cities Kitchens and Appliances','EndDepotName':'Bay Cities Kitchens and Appliances','Capacities':'4','MaxOrderCount':3,'MaxTotalTime':60,}}]}" \
-d "populate_directions=true"

For this example scenario, the important information from the response includes:

  • In the out_stops result, the RouteName field shows the route to which an order is assigned to.
  • In the out_routes result,
    • The OrderCount field shows the total number of orders assigned to a route.
    • The TotalTime field shows the overall route time (travel time + time to make the delivery) in Minutes.
    • The TotalOrderServiceTime field shows the time spent making the delivery in Minutes.
    • The TotalTravelTime field shows the travel time (minus the delivery time) in Minutes.
    • The TotalDistance field that shows the travel distance in Miles for each route.
  • In the out_directions result, the Text field contains the driving instruction for each route.
                                                                                                                                                            
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
{
    "results": [
      {
        "paramName": "out_stops",
        "value": {
          "fields": [
            // One or more field definitions
          ],
          "features": [
            {
              "attributes": {
                "Name": "Father's Office",
                "RouteName": "Route 1"
                // more field values
              }
            },
            // additional stops assigned to Route 1
            {
              "attributes": {
                "Name": "Pono Burger",
                "RouteName": "Route 2"
                // more field values
              }
            }
            // additional stops assigned to Route 2
          ],
          "exceededTransferLimit": false
        }
      },
      {
        "paramName": "out_routes",
        "value": {
          "geometryType": "esriGeometryPolyline",
          "spatialReference": {
            "wkid": 4326,
            "latestWkid": 4326
          },
          "fields": [
            // One or more field definitions
          ],
          "features": [
            {
              "attributes": {
                "Name": "Route 1",
                "OrderCount": 3,
                "TotalTime": 44.35174229927361,
                "TotalOrderServiceTime": 30,
                "TotalTravelTime": 14.35174229927361,
                "TotalDistance": 4.7165690223626644
                // more field values

              },
              "geometry": {
                "paths": [
                  [
                    [
                      -118.46985210799994,
                      34.037297225000032
                    ]
                    // additional points that make up the path geometry

                  ],
                  [
                    [
                      -118.49848681399999,
                      34.029544464000026
                    ]
                    // additional points that make up the path geometry
                  ]
                  // additional path that make up the route
                ]
              }
            },
            {
              "attributes": {
                "Name": "Route 2",
                "OrderCount": 3,
                "TotalTime": 53.712840937077999,
                "TotalOrderServiceTime": 30,
                "TotalTravelTime": 23.712840937077999,
                "TotalDistance": 8.9522377804877333
                // more field values
              },
              "geometry": {
                "paths": [
                  // one or more paths that make up the route
                ]
              }
            }
          ],
          "exceededTransferLimit": false
        }
      },
      {
        "paramName": "out_directions",
        "value": {
          "geometryType": "esriGeometryPolyline",
          "spatialReference": {
            "wkid": 4326,
            "latestWkid": 4326
          },
          "fields": [
            // One or more field definitions
          ],
          "features": [
            {
              "attributes": {
                "RouteName": "Route 1",
                "ArriveTime": 1606291199999,
                "Text": "Start at Bay Cities Kitchens & Appliances",
                "ElapsedTime": 0,
                "DriveDistance": 0
                // more field values
              }
            },
            {
              "attributes": {
                "RouteName": "Route 1",
                "ArriveTime": 1606291199999,
                "Text": "Go northwest on Berkeley St toward Arizona Ave",
                "ElapsedTime": 1.020147442817688,
                "DriveDistance": 0.23870387673377991
                // more field values
              },
              "geometry": {
                "paths": [
                  // one or more path that make up the direction geometry

                ]
              }
            },
            // additional driving directions for Route 1
            {
              "attributes": {
                "RouteName": "Route 1",
                "ArriveTime": 1606293904131,
                "Text": "Finish at Bay Cities Kitchens & Appliances, on the left",
                "ElapsedTime": 0,
                "DriveDistance": 0
                 // more field values
              }
            }
            // additional driving directions for Route 2
          ],
          "exceededTransferLimit": false
        }
      }
      // additional output parameters
    ],
    "messages": [
      {
        "type": "esriJobMessageTypeWarning",
        "description": "Network elements with avoid-restrictions are traversed in the output (restriction attribute names: \"Through Traffic Prohibited\")."
      }
    ]
  }

Job: Goods delivery

In this example, you will find the best routes for a fleet of three vehicles, operated by a distribution company, to deliver goods from a distribution center to a set of nine grocery stores. Each store has a specific quantity of demand for the goods, and each truck has a limited capacity for carrying the goods. The main objective is to assign trucks in the fleet a subset of the stores to service and to sequence the deliveries in a way that minimizes the overall transportation costs.

In this scenario, specify the stores as orders, the distribution center as depots, and the three trucks as routes.

  • For the orders parameter, specify the following attributes:

    • The store name as the Name attribute.
    • The service time as the ServiceTime attribute.
    • The total weight of goods to be delivered as the DeliveryQuantities attribute.
    • The time range in which the store accepts deliveries as the TimeWindowStart1 and TimeWindowEnd1 attributes.
    • Since the time windows should not be violated, specify 0 as the value for the MaxViolationTime1 attribute.
  • For the depots parameter, specify the following attributes:

    • The depot name as the Name attribute.
    • The depot operating time as the TimeWindowStart1 and TimeWindowEnd1 attributes.
  • For the routes parameter, specify the following attributes:

    • The name for each truck as the Name attribute.

    • The depot name from where the trucks operate as the StartDepotName and EndDepotName attributes.

    • The time required to fully load the truck with goods as StartDepotServiceTime attribute.

    • The trucks can start operating as soon as the depot opens, so you specify the EarliestStartTime and LatestStartTime attributes to have the same values as the TimeWindowStart1 attribute for the depots parameter.

    • The maximum carrying capacity of each truck as the Capacities attribute.

    • The wage of the truck driver as the CostPerUnitTime attribute.

    • The average dollar amount spent per mile on fuel consumption, truck depreciation, and maintenance as the CostPerUnitDistance parameter.

    • The maximum number of stores that can be serviced by a truck as the MaxOrderCount attribute.

    • The maximum duration of the work shift for the drivers according to the workday constraints as the MaxTotalTime attribute.

    • The maximum time a truck can spend driving on the streets as the MaxTravelTime attribute. This considers the need to satisfy the workday constraints and still be able to serve a reasonable number of stores while taking into account the service time needed at a store.

    • The maximum distance a truck can travel that balances the daily fuel and maintenance costs among the fleet as the MaxTotalDistance attribute.

  • Since your time-based attribute values, such as ServiceTime, CostPerUnitTime, and MaxTotalTime are in minutes, you can use the default value (which is minutes) for the time_units parameter. Similarly, your distance-based attributes values, such as CostPerUnitDistance and MaxTotalDistance, are in miles, you can use the default value (which is miles) for the distance_units parameter.

  • Since we are finding routes for delivery trucks, we need to make sure we follow the rules that pertain to driving trucks. These include, not driving on streets that are restricted for trucks and do not require making any U-turns since it is difficult for these delivery trucks to make them. So we specify the travel_mode parameter to a value that defines a trucking time travel mode.

  • You need to generate driving directions in English for each route, so set the populate_directions parameter to true and the directions_language parameter to en.

  • Since we are generating driving directions, the shape of the output routes can be obtained from the directions output. So as a performance improvement and to reduce the size of the response we need to fetch, we will not populate any shape for the output routes by setting populate_route_lines to false.

  • Since you have time windows on orders and depots, you need to specify the default_date parameter.

The default values for all the remaining parameters are valid for this problem, and therefore you will not pass those parameters in your request.

APIs

ArcGIS JS APIArcGIS Python API
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
<html>

  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>ArcGIS Developer Guide: Fleet routing</title>
    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
    </style>

  <link rel="stylesheet" href="https://js.arcgis.com/4.20/esri/themes/light/main.css">
  <script src="https://js.arcgis.com/4.20/"></script>

    <script>
      require([
        "esri/config",
        "esri/Map",
        "esri/views/MapView",
        "esri/Graphic",
        "esri/layers/GraphicsLayer",
        "esri/widgets/ScaleBar",
        "esri/rest/geoprocessor",
        "esri/rest/support/FeatureSet",
        "esri/rest/support/JobInfo"
      ], function (
        Map,
      ) {
        esriConfig.apiKey = "YOUR_API_KEY";
        const depot = {
          type: "point",
          x: -122.3943,
          y: 37.7967
        const map = new Map({
          basemap: "arcgis-navigation"
        const view = new MapView({
          container: "viewDiv",
          center: [-122.440545, 37.7625332], // Central San Francisco
          scale: 50000,
          constraints: {
            snapToZoom: false
        view.ui.add(new ScaleBar({ view }), "bottom-right");
        Promise.all([view.when(), getfleetRoutes()]).then(([_view, { directions, routes, stops }]) => {
        async function getfleetRoutes() {
          const orders = new FeatureSet({
            features: [
              new Graphic({
                geometry: {
                  type: "point",
                  x: -122.51,
                  y: 37.7724
                attributes: {
                  DeliveryQuantities: 1706,
                  Name: "Store 1",
                  ServiceTime: 25,
                  TimeWindowStart1: 1608051600000,
                  TimeWindowEnd1: 1608080400000,
                  MaxViolationTime1: 0
              new Graphic({
                geometry: {
                  type: "point",
                  x: -122.4889,
                  y: 37.7538
                attributes: {
                  DeliveryQuantities: 1533,
                  Name: "Store 2",
                  ServiceTime: 23,
                  TimeWindowStart1: 1608051600000,
                  TimeWindowEnd1: 1608080400000,
                  MaxViolationTime1: 0
              new Graphic({
                geometry: {
                  type: "point",
                  x: -122.4649,
                  y: 37.7747
                attributes: {
                  DeliveryQuantities: 1580,
                  Name: "Store 3",
                  ServiceTime: 24,
                  TimeWindowStart1: 1608051600000,
                  TimeWindowEnd1: 1608080400000,
                  MaxViolationTime1: 0
              new Graphic({
                geometry: {
                  type: "point",
                  x: -122.4739,
                  y: 37.7432
                attributes: {
                  DeliveryQuantities: 1289,
                  Name: "Store 4",
                  ServiceTime: 20,
                  TimeWindowStart1: 1608051600000,
                  TimeWindowEnd1: 1608080400000,
                  MaxViolationTime1: 0
              new Graphic({
                geometry: {
                  type: "point",
                  x: -122.4493,
                  y: 37.7315
                attributes: {
                  DeliveryQuantities: 1302,
                  Name: "Store 5",
                  ServiceTime: 21,
                  TimeWindowStart1: 1608051600000,
                  TimeWindowEnd1: 1608080400000,
                  MaxViolationTime1: 0
              new Graphic({
                geometry: {
                  type: "point",
                  x: -122.4917,
                  y: 37.6493
                attributes: {
                  DeliveryQuantities: 1775,
                  Name: "Store 6",
                  ServiceTime: 26,
                  TimeWindowStart1: 1608051600000,
                  TimeWindowEnd1: 1608080400000,
                  MaxViolationTime1: 0
              new Graphic({
                geometry: {
                  type: "point",
                  x: -122.4832,
                  y: 37.7012
                attributes: {
                  DeliveryQuantities: 1014,
                  Name: "Store 7",
                  ServiceTime: 17,
                  TimeWindowStart1: 1608051600000,
                  TimeWindowEnd1: 1608080400000,
                  MaxViolationTime1: 0
              new Graphic({
                geometry: {
                  type: "point",
                  x: -122.5301,
                  y: 37.8935
                attributes: {
                  DeliveryQuantities: 1761,
                  Name: "Store 8",
                  ServiceTime: 26,
                  TimeWindowStart1: 1608051600000,
                  TimeWindowEnd1: 1608080400000,
                  MaxViolationTime1: 0
              new Graphic({
                geometry: {
                  type: "point",
                  x: -122.2875,
                  y: 37.8909
                attributes: {
                  DeliveryQuantities: 1815,
                  Name: "Store 9",
                  ServiceTime: 27,
                  TimeWindowStart1: 1608051600000,
                  TimeWindowEnd1: 1608080400000,
                  MaxViolationTime1: 0
          const depots = new FeatureSet({
            features: [
              new Graphic({
                geometry: depot,
                attributes: {
                  Name: "San Francisco",
                  TimeWindowStart1: 1608048000000,
                  TimeWindowEnd1: 1608080400000
          const routes = new FeatureSet({
            features: [
              new Graphic({
                attributes: {
                  Name: "Truck 1",
                  StartDepotName: "San Francisco",
                  EndDepotName: "San Francisco",
                  StartDepotServiceTime: 60,
                  EarliestStartTime: 1608048000000,
                  LatestStartTime: 1608048000000,
                  Capacities: 15000,
                  CostPerUnitTime: 0.2,
                  CostPerUnitDistance: 1.5,
                  MaxOrderCount: 3,
                  MaxTotalTime: 360,
                  MaxTotalTravelTime: 180,
                  MaxTotalDistance: 100
              new Graphic({
                attributes: {
                  Name: "Truck 2",
                  StartDepotName: "San Francisco",
                  EndDepotName: "San Francisco",
                  StartDepotServiceTime: 60,
                  EarliestStartTime: 1608048000000,
                  LatestStartTime: 1608048000000,
                  Capacities: 15000,
                  CostPerUnitTime: 0.2,
                  CostPerUnitDistance: 1.5,
                  MaxOrderCount: 3,
                  MaxTotalTime: 360,
                  MaxTotalTravelTime: 180,
                  MaxTotalDistance: 100
              new Graphic({
                attributes: {
                  Name: "Truck 3",
                  StartDepotName: "San Francisco",
                  EndDepotName: "San Francisco",
                  StartDepotServiceTime: 60,
                  EarliestStartTime: 1608048000000,
                  LatestStartTime: 1608048000000,
                  Capacities: 15000,
                  CostPerUnitTime: 0.2,
                  CostPerUnitDistance: 1.5,
                  MaxOrderCount: 3,
                  MaxTotalTime: 360,
                  MaxTotalTravelTime: 180,
                  MaxTotalDistance: 100
          const travel_mode = {
            attributeParameterValues: [
                attributeName: "Use Preferred Truck Routes",
                parameterName: "Restriction Usage",
                value: "PREFER_HIGH"
                attributeName: "Avoid Unpaved Roads",
                parameterName: "Restriction Usage",
                value: "AVOID_HIGH"
                attributeName: "Avoid Private Roads",
                parameterName: "Restriction Usage",
                value: "AVOID_MEDIUM"
                attributeName: "Driving a Truck",
                parameterName: "Restriction Usage",
                value: "PROHIBITED"
                attributeName: "Roads Under Construction Prohibited",
                parameterName: "Restriction Usage",
                value: "PROHIBITED"
                attributeName: "Avoid Gates",
                parameterName: "Restriction Usage",
                value: "AVOID_MEDIUM"
                attributeName: "Avoid Express Lanes",
                parameterName: "Restriction Usage",
                value: "PROHIBITED"
                attributeName: "Avoid Carpool Roads",
                parameterName: "Restriction Usage",
                value: "PROHIBITED"
                attributeName: "Avoid Truck Restricted Roads",
                parameterName: "Restriction Usage",
                value: "AVOID_HIGH"
                attributeName: "TruckTravelTime",
                parameterName: "Vehicle Maximum Speed (km/h)",
                value: 0
            description: "Models basic truck travel by preferring designated truck routes, and finds solutions that optimize travel time. Routes must obey one-way roads, avoid illegal turns, and so on. When you specify a start time, dynamic travel speeds based on traffic are used where it is available, up to the legal truck speed limit.",
            distanceAttributeName: "Kilometers",
            id: "ZzzRtYcPLjXFBKwr",
            impedanceAttributeName: "TruckTravelTime",
            name: "Trucking Time",
            restrictionAttributeNames: [
              "Avoid Carpool Roads",
              "Avoid Express Lanes",
              "Avoid Gates",
              "Avoid Private Roads",
              "Avoid Truck Restricted Roads",
              "Avoid Unpaved Roads",
              "Driving a Truck",
              "Roads Under Construction Prohibited",
              "Use Preferred Truck Routes"
            simplificationTolerance: 10,
            simplificationToleranceUnits: "esriMeters",
            timeAttributeName: "TruckTravelTime",
            type: "TRUCK",
            useHierarchy: true,
            uturnAtJunctions: "esriNFSBNoBacktrack"
          const params = {
            depots,                      // The start and the return location for the vehicles.
            orders,                      // A list of locations to visit with attributes such as the order name or the time required to complete the delivery at each order.
            routes,                      // The characteristics and constraints for each vehicle.
            default_date: 1608051600000, // The date on which all of your routes start.
            directions_language: "en",
            distance_units: "Miles",
            populate_directions: true,  // "Generate driving directions for the routes"
            populate_route_lines: false,
            time_units: "Minutes",
          const url = "https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem";

          const geoprocessingOptions = {
            outSpatialReference: view.spatialReference
          };

          const jobInfo = await geoprocessor.submitJob(url, params, geoprocessingOptions);

          const options = {
            statusCallback: (jobInfo) => {
              const timestamp = new Date().toLocaleTimeString();
              const message = jobInfo.messages[jobInfo.messages.length - 1];
              console.log(`${timestamp}: ${message.description}`);
            }
          };
          await jobInfo.waitForJobCompletion(options);

          const [directionsResult, routesResult, stopsResult] = await Promise.all([
            jobInfo.fetchResultData("out_directions"),
            jobInfo.fetchResultData("out_routes"),
            jobInfo.fetchResultData("out_stops")
          ]);

          return {
            directions: directionsResult.value.features,
            routes: routesResult.value.features,
            stops: stopsResult.value.features
          };
        }
        function zoomToResults(graphics) {
          const geometries = graphics
            .map((direction) => direction.geometry)
            .filter((geometry) => geometry)
        function printRouteSummary(routes){
          const formatNumber = new Intl.NumberFormat("en-US", {
            minimumFractionDigits: 0,
            maximumFractionDigits: 0
          for (const route of routes) {
            const { Name, TotalDistance, TotalTime } = route.attributes;
            console.log(`
              Route:           ${Name}
              Travel Distance: ${formatNumber.format(TotalDistance)} miles
              Drive Time:      ${formatNumber.format(TotalTime)} minutes
            `);
        function getTruckColor(name) {
            switch (name) {
              case "Truck 1":
                return [50, 150, 50, 0.75];
              case "Truck 2":
                return [50, 150, 255, 0.75];
              case "Truck 3":
                return [180, 69, 255, 0.75];
        function showDirections(directions) {
          const graphics = directions
            .filter((direction) => direction.geometry)
            .map((direction) => {
              const { attributes, geometry } = direction;
              const { ArriveTime, RouteName, Text } = attributes;
              const time = new Date(ArriveTime).toLocaleTimeString();
              const color = getTruckColor(RouteName);
              return new Graphic({
                symbol: {
                  type: "simple-line",
                  width: "5px"
                popupTemplate: {
                  title: `${RouteName}`,
                  content: `<b>${Text}</b><br>Arrive at: ${time}`
          map.add(new GraphicsLayer({ graphics }));
        function showStops(stops) {
          for (const stop of stops) {
            const { SnapY, SnapX, RouteName, Sequence } = stop.attributes;
              geometry: {
                type: "point",
                latitude: SnapY,
                longitude: SnapX
              symbol: {
                type: "simple-marker",
                color: "white",
                outline: {
                  color: getTruckColor(RouteName),
                  width: 1.5
                size: "18px"
              popupTemplate: {
                title: "{Name}",
                content: `${RouteName}<br>Stop: ${parseInt(Sequence) - 1}<br>Delivery Items: 1`
          const labels = stops.map((stop) => stop.clone());
          for (const label of labels) {
            const { RouteName, Sequence } = label.attributes;
              symbol: {
                type: "text",
                text: Sequence - 1,
                font: { size: 9, weight: "normal" },
                yoffset: -3,
                color: "black" //getTruckColor(RouteName)
              popupTemplate: null
          const graphics = stops.concat(labels);
          map.add(new GraphicsLayer({ graphics }));
        function showDepot() {
          const graphics = [
            new Graphic({
              geometry: depot,
              symbol: {
                type: "simple-marker",
                style: "square",
                color: "white",
                outline: {
                  color: "black",
                  width: 1.5
                size: "20px",
            new Graphic({
              geometry: depot,
              symbol: {
                type: "text",
                text: "D",
                font: { size: 10, weight: "normal" },
                yoffset: -4,
                color: "black"
          map.add(new GraphicsLayer({ graphics }));
    </script>
  </head>

  <body>
    <div id="viewDiv"></div>
  </body>

  </html>

REST API

Unlike Direct request type which allows you to make a request and get back all the results in the response, when working with a Job request type, you need to follow a three step workflow:

  1. Make the submitJob request with the appropriate request parameters to get a job id.
  2. Using the job id, check the job status to see if the job completed successfully.
  3. Use the job id to get one or more results.
1. Submit job2. Check job status3. Get results (out_routes)3. Get results (out_directions)
Request
cURLHTTP
             
1
2
3
4
5
6
7
8
9
10
11
12
13
curl https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/submitJob? \
-d "f=json" \
-d "token=<ACCESS_TOKEN>" \
-d "orders={'features':[{'geometry':{'x':-122.51,'y':37.7724},'attributes':{'DeliveryQuantities':1706,'Name':'Store_1','ServiceTime':25,'TimeWindowStart1':1608051600000,'TimeWindowEnd1':1608080400000,'MaxViolationTime1':0}},{'geometry':{'x':-122.4889,'y':37.7538},'attributes':{'DeliveryQuantities':1533,'Name':'Store_2','ServiceTime':23,'TimeWindowStart1':1608051600000,'TimeWindowEnd1':1608080400000,'MaxViolationTime1':0}},{'geometry':{'x':-122.4649,'y':37.7747},'attributes':{'DeliveryQuantities':1580,'Name':'Store_3','ServiceTime':24,'TimeWindowStart1':1608051600000,'TimeWindowEnd1':1608080400000,'MaxViolationTime1':0}},{'geometry':{'x':-122.4739,'y':37.7432},'attributes':{'DeliveryQuantities':1289,'Name':'Store_4','ServiceTime':20,'TimeWindowStart1':1608051600000,'TimeWindowEnd1':1608080400000,'MaxViolationTime1':0}},{'geometry':{'x':-122.4493,'y':37.7315},'attributes':{'DeliveryQuantities':1302,'Name':'Store_5','ServiceTime':21,'TimeWindowStart1':1608051600000,'TimeWindowEnd1':1608080400000,'MaxViolationTime1':0}},{'geometry':{'x':-122.4917,'y':37.6493},'attributes':{'DeliveryQuantities':1775,'Name':'Store_6','ServiceTime':26,'TimeWindowStart1':1608051600000,'TimeWindowEnd1':1608080400000,'MaxViolationTime1':0}},{'geometry':{'x':-122.4832,'y':37.7012},'attributes':{'DeliveryQuantities':1014,'Name':'Store_7','ServiceTime':17,'TimeWindowStart1':1608051600000,'TimeWindowEnd1':1608080400000,'MaxViolationTime1':0}},{'geometry':{'x':-122.5301,'y':37.8935},'attributes':{'DeliveryQuantities':1761,'Name':'Store_8','ServiceTime':26,'TimeWindowStart1':1608051600000,'TimeWindowEnd1':1608080400000,'MaxViolationTime1':0}},{'geometry':{'x':-122.2875,'y':37.8909},'attributes':{'DeliveryQuantities':1815,'Name':'Store_9','ServiceTime':27,'TimeWindowStart1':1608051600000,'TimeWindowEnd1':1608080400000,'MaxViolationTime1':0}}]}" \
-d "depots={'features':[{'geometry':{'x':-122.3943,'y':37.7967},'attributes':{'Name':'San Francisco','TimeWindowStart1':1608048000000,'TimeWindowEnd1':1608080400000}}]}" \
-d "routes={'features':[{'attributes':{'Name':'Truck_1','StartDepotName':'San Francisco','EndDepotName':'San Francisco','StartDepotServiceTime':60,'EarliestStartTime':1608048000000,'LatestStartTime':1608048000000,'Capacities':'15000','CostPerUnitTime':0.2,'CostPerUnitDistance':1.5,'MaxOrderCount':3,'MaxTotalTime':360,'MaxTotalTravelTime':180,'MaxTotalDistance':100}},{'attributes':{'Name':'Truck_2','StartDepotName':'San Francisco','EndDepotName':'San Francisco','StartDepotServiceTime':60,'EarliestStartTime':1608048000000,'LatestStartTime':1608048000000,'Capacities':'15000','CostPerUnitTime':0.2,'CostPerUnitDistance':1.5,'MaxOrderCount':3,'MaxTotalTime':360,'MaxTotalTravelTime':180,'MaxTotalDistance':100}},{'attributes':{'Name':'Truck_3','StartDepotName':'San Francisco','EndDepotName':'San Francisco','StartDepotServiceTime':60,'EarliestStartTime':1608048000000,'LatestStartTime':1608048000000,'Capacities':'15000','CostPerUnitTime':0.2,'CostPerUnitDistance':1.5,'MaxOrderCount':3,'MaxTotalTime':360,'MaxTotalTravelTime':180,'MaxTotalDistance':100}}]}" \
-d "time_units=Minutes" \
-d "distance_units=Miles" \
-d "travel_mode={'attributeParameterValues':[{'attributeName':'Use Preferred Truck Routes','parameterName':'Restriction Usage','value':'PREFER_HIGH'},{'attributeName':'Avoid Unpaved Roads','parameterName':'Restriction Usage','value':'AVOID_HIGH'},{'attributeName':'Avoid Private Roads','parameterName':'Restriction Usage','value':'AVOID_MEDIUM'},{'attributeName':'Driving a Truck','parameterName':'Restriction Usage','value':'PROHIBITED'},{'attributeName':'Roads Under Construction Prohibited','parameterName':'Restriction Usage','value':'PROHIBITED'},{'attributeName':'Avoid Gates','parameterName':'Restriction Usage','value':'AVOID_MEDIUM'},{'attributeName':'Avoid Express Lanes','parameterName':'Restriction Usage','value':'PROHIBITED'},{'attributeName':'Avoid Carpool Roads','parameterName':'Restriction Usage','value':'PROHIBITED'},{'attributeName':'Avoid Truck Restricted Roads','parameterName':'Restriction Usage','value':'AVOID_HIGH'},{'attributeName':'TruckTravelTime','parameterName':'Vehicle Maximum Speed (km/h)','value':0}],'description':'Models basic truck travel by preferring designated truck routes, and finds solutions that optimize travel time. Routes must obey one-way roads, avoid illegal turns, and so on. When you specify a start time, dynamic travel speeds based on traffic are used where it is available, up to the legal truck speed limit.','distanceAttributeName':'Kilometers','id':'ZzzRtYcPLjXFBKwr','impedanceAttributeName':'TruckTravelTime','name':'Trucking Time','restrictionAttributeNames':['Avoid Carpool Roads','Avoid Express Lanes','Avoid Gates','Avoid Private Roads','Avoid Truck Restricted Roads','Avoid Unpaved Roads','Driving a Truck','Roads Under Construction Prohibited','Use Preferred Truck Routes'],'simplificationTolerance':10,'simplificationToleranceUnits':'esriMeters','timeAttributeName':'TruckTravelTime','type':'TRUCK','useHierarchy':true,'uturnAtJunctions':'esriNFSBNoBacktrack'}" \
-d "populate_directions=true" \
-d "directions_language=en" \
-d "populate_route_lines=false" \
-d "default_date=1608051600000"
Response (JSON)
    
1
2
3
4
{
  "jobId": "jfd7f78c3a9174d0ba0933c022b38a37e",
  "jobStatus": "esriJobSubmitted"
}
Request
cURLHTTP
   
1
2
3
curl https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/jfd7f78c3a9174d0ba0933c022b38a37e? \
-d "f=json" \
-d "token=<ACCESS_TOKEN>"
Response (JSON)
                                                               
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
{
  "jobId": "jfd7f78c3a9174d0ba0933c022b38a37e",
  "jobStatus": "esriJobSucceeded",
  "results": {
    "out_unassigned_stops": {
      "paramUrl": "results/out_unassigned_stops"
    },
    "out_stops": {
      "paramUrl": "results/out_stops"
    },
    "out_routes": {
      "paramUrl": "results/out_routes"
    },
    "out_directions": {
      "paramUrl": "results/out_directions"
    },
    "solve_succeeded": {
      "paramUrl": "results/solve_succeeded"
    },
    "out_network_analysis_layer": {
      "paramUrl": "results/out_network_analysis_layer"
    },
    "out_route_data": {
      "paramUrl": "results/out_route_data"
    },
    "out_result_file": {
      "paramUrl": "results/out_result_file"
    }
  },
  "inputs": {
    "orders": {
      "paramUrl": "inputs/orders"
    },
    "depots": {
      "paramUrl": "inputs/depots"
    },
    "routes": {
      "paramUrl": "inputs/routes"
    },
    "time_units": {
      "paramUrl": "inputs/time_units"
    },
    "distance_units": {
      "paramUrl": "inputs/distance_units"
    },
    "default_date": {
      "paramUrl": "inputs/default_date"
    },
    "populate_route_lines": {
      "paramUrl": "inputs/populate_route_lines"
    },
    "populate_directions": {
      "paramUrl": "inputs/populate_directions"
    },
    "directions_language": {
      "paramUrl": "inputs/directions_language"
    },
    "travel_mode": {
      "paramUrl": "inputs/travel_mode"
    }
  },
  "messages": []
}
Request
cURLHTTP
   
1
2
3
curl https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/jfd7f78c3a9174d0ba0933c022b38a37e/results/out_routes? \
-d "f=json" \
-d "token=<ACCESS_TOKEN>"
Response (JSON)
                                                                                                                                                                                                                                                  
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
{
  "paramName": "out_routes",
  "dataType": "GPFeatureRecordSetLayer",
  "value": {
    "displayFieldName": "",
    "geometryType": "esriGeometryPolyline",
    "spatialReference": {
      "wkid": 4326,
      "latestWkid": 4326
    },
    "fields": [
      {
        "name": "ObjectID",
        "type": "esriFieldTypeOID",
        "alias": "ObjectID"
      },
      {
        "name": "Name",
        "type": "esriFieldTypeString",
        "alias": "Name",
        "length": 1024
      },
      {
        "name": "ViolatedConstraints",
        "type": "esriFieldTypeInteger",
        "alias": "ViolatedConstraints"
      },
      {
        "name": "ViolatedConstraint_1",
        "type": "esriFieldTypeInteger",
        "alias": "ViolatedConstraint_1"
      },
      {
        "name": "ViolatedConstraint_2",
        "type": "esriFieldTypeInteger",
        "alias": "ViolatedConstraint_2"
      },
      {
        "name": "ViolatedConstraint_3",
        "type": "esriFieldTypeInteger",
        "alias": "ViolatedConstraint_3"
      },
      {
        "name": "ViolatedConstraint_4",
        "type": "esriFieldTypeInteger",
        "alias": "ViolatedConstraint_4"
      },
      {
        "name": "OrderCount",
        "type": "esriFieldTypeInteger",
        "alias": "OrderCount"
      },
      {
        "name": "TotalCost",
        "type": "esriFieldTypeDouble",
        "alias": "TotalCost"
      },
      {
        "name": "RegularTimeCost",
        "type": "esriFieldTypeDouble",
        "alias": "RegularTimeCost"
      },
      {
        "name": "OvertimeCost",
        "type": "esriFieldTypeDouble",
        "alias": "OvertimeCost"
      },
      {
        "name": "DistanceCost",
        "type": "esriFieldTypeDouble",
        "alias": "DistanceCost"
      },
      {
        "name": "TotalTime",
        "type": "esriFieldTypeDouble",
        "alias": "TotalTime"
      },
      {
        "name": "TotalOrderServiceTime",
        "type": "esriFieldTypeDouble",
        "alias": "TotalOrderServiceTime"
      },
      {
        "name": "TotalBreakServiceTime",
        "type": "esriFieldTypeDouble",
        "alias": "TotalBreakServiceTime"
      },
      {
        "name": "TotalTravelTime",
        "type": "esriFieldTypeDouble",
        "alias": "TotalTravelTime"
      },
      {
        "name": "TotalDistance",
        "type": "esriFieldTypeDouble",
        "alias": "TotalDistance"
      },
      {
        "name": "StartTime",
        "type": "esriFieldTypeDate",
        "alias": "StartTime",
        "length": 8
      },
      {
        "name": "EndTime",
        "type": "esriFieldTypeDate",
        "alias": "EndTime",
        "length": 8
      },
      {
        "name": "StartTimeUTC",
        "type": "esriFieldTypeDate",
        "alias": "StartTimeUTC",
        "length": 8
      },
      {
        "name": "EndTimeUTC",
        "type": "esriFieldTypeDate",
        "alias": "EndTimeUTC",
        "length": 8
      },
      {
        "name": "TotalWaitTime",
        "type": "esriFieldTypeDouble",
        "alias": "TotalWaitTime"
      },
      {
        "name": "TotalViolationTime",
        "type": "esriFieldTypeDouble",
        "alias": "TotalViolationTime"
      },
      {
        "name": "RenewalCount",
        "type": "esriFieldTypeInteger",
        "alias": "RenewalCount"
      },
      {
        "name": "TotalRenewalServiceTime",
        "type": "esriFieldTypeDouble",
        "alias": "TotalRenewalServiceTime"
      },
      {
        "name": "Shape_Length",
        "type": "esriFieldTypeDouble",
        "alias": "Shape_Length"
      }
    ],
    "features": [
      {
        "attributes": {
          "ObjectID": 1,
          "Name": "Truck_1",
          "ViolatedConstraints": 0,
          "ViolatedConstraint_1": null,
          "ViolatedConstraint_2": null,
          "ViolatedConstraint_3": null,
          "ViolatedConstraint_4": null,
          "OrderCount": 3,
          "TotalCost": 108.68551022871947,
          "RegularTimeCost": 43.219199541211132,
          "OvertimeCost": 0,
          "DistanceCost": 65.46631068750834,
          "TotalTime": 216.09599770605564,
          "TotalOrderServiceTime": 68,
          "TotalBreakServiceTime": 0,
          "TotalTravelTime": 88.095997706055641,
          "TotalDistance": 43.644207125005558,
          "StartTime": 1608048000000,
          "EndTime": 1608060965760,
          "StartTimeUTC": 1608076800000,
          "EndTimeUTC": 1608089765760,
          "TotalWaitTime": 0,
          "TotalViolationTime": 0,
          "RenewalCount": 0,
          "TotalRenewalServiceTime": 0,
          "Shape_Length": 0
        }
      },
      {
        "attributes": {
          "ObjectID": 2,
          "Name": "Truck_2",
          "ViolatedConstraints": 0,
          "ViolatedConstraint_1": null,
          "ViolatedConstraint_2": null,
          "ViolatedConstraint_3": null,
          "ViolatedConstraint_4": null,
          "OrderCount": 3,
          "TotalCost": 155.34544563191025,
          "RegularTimeCost": 53.693450063839556,
          "OvertimeCost": 0,
          "DistanceCost": 101.65199556807069,
          "TotalTime": 268.46725031919777,
          "TotalOrderServiceTime": 77,
          "TotalBreakServiceTime": 0,
          "TotalTravelTime": 131.46725031919777,
          "TotalDistance": 67.767997045380454,
          "StartTime": 1608048000000,
          "EndTime": 1608064108035,
          "StartTimeUTC": 1608076800000,
          "EndTimeUTC": 1608092908035,
          "TotalWaitTime": 0,
          "TotalViolationTime": 0,
          "RenewalCount": 0,
          "TotalRenewalServiceTime": 0,
          "Shape_Length": 0
        }
      },
      {
        "attributes": {
          "ObjectID": 3,
          "Name": "Truck_3",
          "ViolatedConstraints": 0,
          "ViolatedConstraint_1": null,
          "ViolatedConstraint_2": null,
          "ViolatedConstraint_3": null,
          "ViolatedConstraint_4": null,
          "OrderCount": 3,
          "TotalCost": 82.823917488603328,
          "RegularTimeCost": 37.880385499075054,
          "OvertimeCost": 0,
          "DistanceCost": 44.943531989528275,
          "TotalTime": 189.40192749537528,
          "TotalOrderServiceTime": 64,
          "TotalBreakServiceTime": 0,
          "TotalTravelTime": 65.401927495375276,
          "TotalDistance": 29.962354659685516,
          "StartTime": 1608048000000,
          "EndTime": 1608059364116,
          "StartTimeUTC": 1608076800000,
          "EndTimeUTC": 1608088164116,
          "TotalWaitTime": 0,
          "TotalViolationTime": 0,
          "RenewalCount": 0,
          "TotalRenewalServiceTime": 0,
          "Shape_Length": 0
        }
      }
    ],
    "exceededTransferLimit": false
  }
}
Request
cURLHTTP
   
1
2
3
curl https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/jfd7f78c3a9174d0ba0933c022b38a37e/results/out_directions? \
-d "f=json" \
-d "token=<ACCESS_TOKEN>"
Response (JSON)
                                                                                          
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
{
  "paramName": "out_directions",
  "value": {
    "geometryType": "esriGeometryPolyline",
    "spatialReference": {
      "wkid": 4326,
      "latestWkid": 4326
    },
    "fields": [
     // One or more field definitions
    ],
    "features": [
      {
        "attributes": {
          "RouteName": "Truck_1",
          "ArriveTime": 1608048000000,
          "Text": "Start at San Francisco",
          "ElapsedTime": 60,
          "DriveDistance": 0
          // more field values
        }
      },
      {
        "attributes": {
          "RouteName": "Truck_1",
          "ArriveTime": 1608048000000,
          "Text": "Time Window: 12/15/2020 4:00 PM - 12/16/2020 1:00 AM",
          "ElapsedTime": 60,
          "DriveDistance": 0
          // more field values
        }
      },
      {
        "attributes": {
          "RouteName": "Truck_1",
          "ArriveTime": 1608048000000,
          "Text": "Service Time: 1 hour",
          "ElapsedTime": 60,
          "DriveDistance": 0
          // more field values
        }
      },
      {
        "attributes": {
          "RouteName": "Truck_1",
          "ArriveTime": 1608051599999,
          "Text": "Go northwest on The Embarcadero (World Trade Ctr) toward Pier 1",
          "ElapsedTime": 0.25894445180892944,
          "DriveDistance": 0.046282608062028885
          // more field values
        },
        "geometry": {
          "paths": [
            [
              [
                -122.39477568799998,
                37.796252294000055
              ]
              // additional points that make up the path geometry
            ]
          ]
        }
      },
      // additional driving directions for route Truck_1
      {
        "attributes": {
          "RouteName": "Truck_2",
          "ArriveTime": 1608048000000,
          "Text": "Start at San Francisco",
          "ElapsedTime": 60,
          "DriveDistance": 0
          // more field values
        }
      },
      // additional driving directions for route Truck_2
      {
        "attributes": {
          "RouteName": "Truck_3",
          "ArriveTime": 1608048000000,
          "Text": "Start at San Francisco",
          "ElapsedTime": 60,
          "DriveDistance": 0
          // more field values
        }
      }
      // additional driving directions for route Truck_3
    ],
    "exceededTransferLimit": false
  }
}

Tutorials

Services

Routing service

Get turn-by-turn directions and solve advanced routing problems.

API support

RoutingFleet routingClosest facility routingService areasLocation-allocationTravel cost matrix
ArcGIS API for JavaScriptFully supportedAccess with geoprocessing taskFully supportedFully supportedAccess with geoprocessing taskAccess with geoprocessing task
ArcGIS Runtime API for AndroidFully supportedAccess with geoprocessing taskFully supportedFully supportedAccess with geoprocessing taskAccess with geoprocessing task
ArcGIS Runtime API for iOSFully supportedAccess with geoprocessing taskFully supportedFully supportedAccess with geoprocessing taskAccess with geoprocessing task
ArcGIS Runtime API for JavaFully supportedAccess with geoprocessing taskFully supportedFully supportedAccess with geoprocessing taskAccess with geoprocessing task
ArcGIS Runtime API for .NETFully supportedAccess with geoprocessing taskFully supportedFully supportedAccess with geoprocessing taskAccess with geoprocessing task
ArcGIS Runtime API for QtFully supportedAccess with geoprocessing taskFully supportedFully supportedAccess with geoprocessing taskAccess with geoprocessing task
ArcGIS API for PythonFully supportedFully supportedFully supportedFully supportedFully supportedFully supported
Esri LeafletAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JS
MapBox GL JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JS
OpenLayersAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JS
ArcGIS REST JSFully supportedFully supportedFully supportedFully supportedFully supportedFully supported
Full supportPartial support (see notes)Not supported

Tools

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