Find the Shortest Path/Distance between destinations using ESRI API and Plugins
In this repository I discussed about to find the shortest path and direction between one location to another using ESRI
- Enter the Source and Destination address
- Options to add stops between address
- Options to select speed units
- KM
- MI
- Options to different type travel selection
- Driving Distance/Time
- Rural Driving Distance/Time
- Trucking Distance/Time
- Walking Distance/Time
- Options to select travel options now or later
- Leave now
- Depart at
- Time Unspecified
Select the address in option 1 and option 2 (Note: If you would like to add more destinations click ADD to add destination address)
Code description - (doji/javascript)
- Initialize map object using "esri/map" class and setup the base attributes based on the requirement.
var map = new Map("map", { basemap: "streets", center:[-98.56,39.82], zoom: 4 });
- Initialize direction object using "esri/dijit/Directions" class and add the routeTaskUrl
var directions = new Directions({ var directions = new Directions({ map: map, routeTaskUrl: "https://utility.arcgis.com/usrsvcs/appservices/srsKxBIxJZB0pTZ0/rest/services/World/Route/NAServer/Route_World" },"dir"); directions.startup(); });
- Initiate direction by
directions.startup();
Add the proxy handler to handle communications with the Routind and Direction Service
- I build this application using .Net Framework so used "proxy.ashx" refer the Service Proxy - https://developers.arcgis.com/documentation/core-concepts/security-and-authentication/working-with-proxies/