Practice time with routing
In this exercise, you will learn how to implement routing in your applications. You'll create an instance of RouteParameters
, add stops by allowing the user to click points on a map, and solve the route. The returned route will be displayed as a line symbol on the map:
- Open the JavaScript Sandbox at https://developers.arcgis.com/javascript/3/sandbox/sandbox.html.
- Remove all the JavaScript content from the
<script>
tag as shown in the following:
<script> var map; require(["esri/map", "dojo/domReady!"], function(Map) { map = new Map("map", { basemap: "topo", //For full list of ... center: [-122.45, 37.75], // longitude, latitude zoom: 13 }); }); </script>
- Create your
require()
function and import the following modules:
<script> require([ "esri/map", "esri/urlUtils", "esri/tasks/RouteParameters", "esri/tasks/RouteTask", "esri/tasks/FeatureSet", ...