Route and directions

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

Your ArcGIS Runtime routing app can do things like:

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

What is routing?

Routing is the process of finding the best path between two or more in a street network. A common use case is to find a between two stops, from an to a . Routing takes into consideration many different 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, ArcGIS Runtime provides additional functionality for analyses with a streets network. This includes the ability to do things like create (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 in the results. Directions provide specific instructions for traveling the route. These are often referred to as "driving directions", but depending on the , could describe walking or cycling to the . Depending on the 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 . A direction maneuver is further broken down into maneuver messages that give details about a specific maneuver.

If supported by the , 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 that spans multiple floors.

The navigation API allows you to further enhance the routing experience using the current device to track progress and provide navigation instructions (maneuvers) as the user travels the . 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 and an appropriate result:

  • Progress information relative to the next , 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 if the device goes off route

How routing works

Online and local routing both rely on a transportation network to model travel. These networks are created from (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 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 , see Publish routing services.

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

If you'd like a ready-to-use and regularly updated network dataset (and ) 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 . It returns results with details about a that visits two or more () within a transportation network. This operation is sometimes referred to as solving a .

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

Route parameters

Route task parameters specify how a should be found. There are many parameters that let you customize how the route is determined. Parameters include and . Other parameters include , whether stops map be reordered to find an , 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.createDefaultParametersAsync() 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.

Route results

The results returned from finding a contain a collection of routes. Each route is represented by a 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 , , and driving directions. Typically, the , stops, and barriers are displayed as in the . Directions can be shown in a list or other UI element in the app.

Examples

Find a route and directions

Use the to find a between a set of . 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 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 to visit, the route segments, and turn-by-turn text directions.

Expand
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
    private fun solveRouteTask() {
        val stops: List<Stop> = graphicsOverlay.graphics
            .filter { graphic: Graphic -> graphic.geometry != null }
            .map { graphic: Graphic -> Stop(graphic.geometry as Point) }

        val routeTask = RouteTask(this, "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World")

        val routeParametersFuture = routeTask.createDefaultParametersAsync()
        routeParametersFuture.addDoneListener {
            try {
                val routeParameters = routeParametersFuture.get()
                routeParameters.apply {
                    setStops(stops)
                    isReturnDirections = true
                    directionsLanguage = "es"
                }

                val routeResultFuture = routeTask.solveRouteAsync(routeParameters)
                routeResultFuture.addDoneListener {
                    try {
                        val routeResult = routeResultFuture.get()
                        val route = routeResult.routes[0]
                        routeGraphic.geometry = route.routeGeometry

                        route.directionManeuvers.forEach { step -> Log.i("Route Directions", step.directionText)}
                    } catch (exception: Exception) {
                        Log.e(MainActivity::class.simpleName, exception.message)
                    }
                }
                } catch (exception: Exception) {
                    Log.e(MainActivity::class.simpleName, exception.message)
                }
            }
    }
Expand

Use API key access tokens

An , provided by an , can be used to authorize access to services and resources from your app, as well as to monitor access to those services. You can use a single for all requests made by your app, or assign individual for any classes that implements

Learn more about API key authentication

Tutorials

Samples

Find route

Offline routing

Route around barriers

Display device location with autopan modes

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.

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close