Using the routing service
Your routing app can do things like:
- Calculate point-to-point and multi-stop
A stop is a single point along a route: it can be the origin, an intermediate stop, or destination. routesA route is a polyline that defines the best path between two or more points in a street network. - Optimize the results to find the shortest or the fastest route
- Find the best sequence between stops
A stop is a single point along a route: it can be the origin, an intermediate stop, or destination. - Create routes based on the travel mode
A travel mode is the means of transportation, such as walking or driving, that defines how you can travel in a street network. (driving, cycling, walking, and so on) - Avoid restricted areas and maneuvers
- Specify time windows of arrival and departure for each stop
A stop is a single point along a route: it can be the origin, an intermediate stop, or destination. - Generate driving directions in multiple languages
What is routing?
Routing is the process of finding the best path between two or more stops
In addition to the routing described above, functionality is provided to analyze street networks. This includes the ability to create service areas
Directions
If requested, directions are returned for each route
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
If supported by the service
How routing works
Online and local routing both rely on a transportation network to model travel. These networks are created from features
Network Analyst services
You can create a transportation network using ArcGIS Pro.mmpk), a mobile scene package.mspk), or a mobile geodatabase
If you'd like a ready-to-use and regularly updated network dataset (and locator
Route task
A route task is a network analysis task that is executed asynchronously
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 route
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 route
Examples
Find a route and directions
Use the routing service
To find a route, you need to define at least two stops to visit. The default travel mode
The result contains a set of ordered stops
List<Stop> stops = graphicsOverlay.getGraphics()
.stream()
.filter(graphic -> graphic.getGeometry() != null)
.map(graphic -> new Stop((Point) graphic.getGeometry()))
.collect(Collectors.toList());
RouteTask routeTask =
new RouteTask("https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World");
ListenableFuture<RouteParameters> routeParametersFuture = routeTask.createDefaultParametersAsync();
routeParametersFuture.addDoneListener(() -> {
try {
RouteParameters routeParameters = routeParametersFuture.get();
routeParameters.setStops(stops);
routeParameters.setReturnDirections(true);
routeParameters.setDirectionsLanguage("es");
ListenableFuture<RouteResult> routeResultFuture = routeTask.solveRouteAsync(routeParameters);
routeResultFuture.addDoneListener(() -> {
try {
RouteResult routeResult = routeResultFuture.get();
Route route = routeResult.getRoutes().getFirst();
routeGraphic.setGeometry(route.getRouteGeometry());
route.getDirectionManeuvers().forEach(step -> System.out.println(step.getDirectionText()));
} catch (Exception e) {
e.printStackTrace();
}
});
} catch (Exception e) {
e.printStackTrace();
}
});
Use API key access tokens
An API key access tokenApiKeyResource.
Tutorials
Samples

Find route

Offline routing

Route around barriers

Display device location with autopan modes

