Route and directions

Using the routing service, your own route services, or a route dataset stored on the device, you can find routes, directions, and perform advanced analyses on street networks. You can solve network problems such as finding the closest emergency vehicle or facility, identifying a service area around a location, or servicing a set of orders with a fleet of vehicles.

Your routing app can do things like:

  • Calculate point-to-point and multi-stop routes
  • Optimize the results to find the shortest or the fastest route
  • Find the best sequence between stops
  • Create routes based on the travel mode (driving, cycling, walking, and so on)
  • Avoid restricted areas and maneuvers
  • Specify time windows of arrival and departure for each stop
  • Generate driving directions in multiple languages

What is routing?

Routing is the process of finding the best path between two or more stops in a street network. A common use case is to find a route between two stops, from an origin to a destination. Routing takes into consideration many different attributes in the street network such as speed limit, number of lanes, and time of day. Routing can also incorporate real-time data such as road conditions, accidents, street closures, and other restrictions to travel.

In addition to the routing described above, functionality is provided to analyze street networks. This includes the ability to create service areas (to find customers within a certain drive time, for example) or locate a closest facility (nearest hospital to an accident, for example).

Directions

If requested, directions are returned for each route in the results. Directions provide specific instructions for traveling the route. These are often referred to as "driving directions", but depending on the travel mode, could describe walking or cycling to the destination. Depending on the services configuration, directions can be returned in more than one language. Supported languages for a service are available in the service metadata.

Directions are composed of maneuvers. Each maneuver contains properties such as the direction text, which contains instructions that describe travel through a section of a route. A direction maneuver is further broken down into maneuver messages that give details about a specific maneuver.

If supported by the service, direction maneuver’s can include from level and to level values to define things like floor levels inside a building. For example, a user may want to see just one level of a walking route that spans multiple floors.

The navigation API allows you to further enhance the routing experience using the current device location to track progress and provide navigation instructions (maneuvers) as the user travels the route. You can integrate driving directions with your device's text-to-speech capability and automatically recalculate a new route when the user leaves the current one.

The route tracker object provides the following functionality using the current device location and an appropriate route result:

  • Progress information relative to the next stop, to the next maneuver, or along the entire route
  • Guidance for navigation as it's needed (when approaching a maneuver, for example)
  • Automatic recalculation of a route if the device location goes off route

How routing works

Online and local routing both rely on a transportation network to model travel. These networks are created from features (lines and points) that represent roads, bridges, tunnels, bike paths, train tracks, and other entities in the network. The geometric intersections of features help to define connectivity between the network entities they represent. The connectivity of the transportation network, along with resistance to travel (speed limit, for example) and other network properties, is analyzed to solve routing problems.

Network Analyst services are hosted in ArcGIS or can be published on your own ArcGIS servers. These services provide a REST API for clients such as mobile and Web applications. For more information about publishing routing services with ArcGIS Enterprise, see Publish routing services.

You can create a transportation network using ArcGIS Pro and deploy it to your device using either a mobile map package file (.mmpk), a mobile scene package file (.mspk), or a mobile geodatabase file. The code to work with a local transportation network (stored directly on the device) is identical to the code for using a routing service.

If you'd like a ready-to-use and regularly updated network dataset (and locator) for your area of interest, you can license StreetMap Premium data (in mobile map package format). For details, see Add StreetMap Premium data.

Route task

A route task is a network analysis task that is executed asynchronously. It returns results with details about a route that visits two or more stops (locations) within a transportation network. This operation is sometimes referred to as solving a route.

The RouteTask refers to the local transportation network dataset or online service. It solves a Route using the configured RouteParameters and reports the RouteResult.

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
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
    // Creating a new route task via a URL.
    m_routeTask = new RouteTask(QUrl(
        "https://sampleserver7.arcgisonline.com/server/rest/services/NetworkAnalysis/SanDiego/NAServer/Route"), this);

Route parameters

Route task parameters specify how a route should be found. There are many parameters that let you customize how the route is determined. Parameters include stops and barriers. Other parameters include travel mode, whether stops map be reordered to find an optimized route, the units to be used in the turn-by-turn directions (miles or kilometers, for example), and so on.

To initially create RouteParameters, call RouteTask::createDefaultParameters() to retrieve the default routing parameters defined for the service. You can then change individual route parameters as needed before executing the RouteTask. The service's default parameters typically support the most common use case anticipated for that service. Different services can have different defaults.

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
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
    // Call the create default route parameters method on the route task.
    m_routeTask->createDefaultParametersAsync().then(this, [this](const RouteParameters& routeParameters)
    {
        // Store the resulting route parameters.
        m_routeParameters = routeParameters;

        // Create a list of stops using points.
        const QList<Stop> stops =
            {Stop(Point(-122.690, 45.522, SpatialReference::wgs84())),  // start point
             Stop(Point(-122.615, 45.526, SpatialReference::wgs84())),  // intermediate point
             Stop(Point(-122.688, 45.512, SpatialReference::wgs84()))}; // end point

        // Add the stops to the route parameters.
        m_routeParameters.setStops(stops);

        // Return driving directions in Spanish.
        m_routeParameters.setReturnDirections(true);
        m_routeParameters.setDirectionsLanguage("es");
     });

Route results

The results returned from finding a route contain a collection of routes. Each route is represented by a polyline geometry and has information such as its total length and travel time. Depending on how you configured your route parameters, the results may also contain barriers, stops, and driving directions. Typically, the route, stops, and barriers are displayed as graphics in the map. Directions can be shown in a list or other UI element in the app.

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
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
    // Call the solve route method on the route task using route parameters.
    m_routeTask->solveRouteAsync(m_routeParameters).then(this,[this](const RouteResult& routeResult)
    {
        // If a result is returned, display the route.
        if (!routeResult.isEmpty())
        {
            // Add the route graphic once the solve completes.
            const Route generatedRoute = routeResult.routes().at(0);

            // Show the route as a graphic in the map view.
            m_routeGraphic->setGeometry(generatedRoute.routeGeometry());

            // Get the driving directions.
            m_directions = generatedRoute.directionManeuvers(this);

            // Notify QML controls of the change.
            emit routeChanged();
        }
    });

Examples

Find a route and directions

Use the routing service to find a route between a set of stops. The result will account for current traffic conditions and provide driving directions in Spanish.

To find a route, you need to define at least two stops to visit. The default travel mode is driving, but you can use walk or trucking travel modes as well. It is always good to provide the start time to get the best results (to consider the appropriate traffic conditions, for example). In this example, the start time is set with the current time which indicates to the service that the route should use the current traffic conditions. The directions language is set to "es" to generate driving directions in Spanish.

The result contains a set of ordered stops to visit, the route segments, and turn-by-turn text directions.

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
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
    // Test of the route task is loded and there are valid route parameters.
    if (m_routeTask->loadStatus() != LoadStatus::Loaded || m_routeParameters.isEmpty())
        return;

    // Return driving directions in Spanish.
    m_routeParameters.setReturnDirections(true);
    m_routeParameters.setDirectionsLanguage("es");

    // Clear previous stops from the parameters.
    m_routeParameters.clearStops();

    // Set the stops to the parameters.
    const Stop stop1(geometry_cast<Point>(m_startGraphic->geometry()));
    const Stop stop2(geometry_cast<Point>(m_stopGraphic->geometry()));
    const Stop stop3(geometry_cast<Point>(m_endGraphic->geometry()));

    m_routeParameters.setStops(QList<Stop> { stop1, stop2, stop3 });

    // Call the solve route on the router task using route parameters.
    QFuture<RouteResult> resultSolveRoute = m_routeTask->solveRouteAsync(m_routeParameters);

Use API keys

An API key can be used to authorize access to ArcGIS Online services and resources from your app, as well as to monitor access to those services. You can use a single API key for all requests made by your app, or assign individual keys for classes that expose an API key property.

Refer to API keys in the security and authentication topic for details.

Tutorials

Samples

Find route

Offline routing

Route around barriers

Display device location

Mobile map (search and route)

Find service area

Navigate route

Services

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