The Directions widget
Now that you have seen what goes on behind the scenes, let us introduce you to a really useful widget that takes some of the complexity away when adding routing capabilities to your application.
By default, the Directions widget accesses the http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World network service to provide routing functionality, but you can configure it to use another network service if you wish. It also accesses another service to provide up-to-date traffic information.
The widget analyzes the network service to determine what capabilities it has, and automatically builds the user interface for you. It deals with gathering the input parameters, executing the task, capturing the results and displaying it to the user. All you have to do is add the esri/dijit/Directions
module to your application, and instantiate it as follows:
var directions = new Directions({ map: map, showSaveButton: true },"dir"); directions.startup...