Hello Group!
I've been playing around with the software for a day or so, I have run through a few of the tutorials and a good amount of the documentation, but I know there are things I am missing.
My goal is to create some Javascript that will allow me to route a few points.
The code below is the best I can gather from the documentation/examples, but it's not working and I don't know where to go from here.
Any help or suggestions would be greatly appreciated.
Thanks,
-Steve
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Directions Widget</title>
<style>
html, body, #map {
height:100%;
width:100%;
margin:0;
padding:0;
}
body {
background-color:#FFF;
overflow:hidden;
font-family:"Trebuchet MS";
}
</style>
<script>
var stop1 = new esri.Graphic(
new esri.geometry.Point(-117.21, 34.065), stopSymbol);
stop1.attributes = new Object();
stop1.attributes.Name = "A";
var stop2 = new esri.Graphic(
new esri.geometry.Point(-117.185, 34.05 ), stopSymbol);
stop2.attributes = new Object();
stop2.attributes.Name = "B";
var stop3 = new esri.Graphic(
new esri.geometry.Point(-117.19, 34.062), stopSymbol);
stop3.attributes = new Object();
stop3.attributes.Name = "C";
routeParams = new esri.tasks.RouteParameters();
routeParams.stops = new esri.tasks.FeatureSet();
routeParams.stops.features.push(stop1);
routeParams.stops.features.push(stop2);
routeParams.stops.features.push(stop3);
routeParams.findBestSequence=true;
routeParams.preserveFirstStop=false;
routeParams.preserveLastStop=false;
routeParams.returnStops = true;
dojo.connect(routeTask, "onSolveComplete", showRoute);
dojo.connect(routeTask, "onError", errorHandler);
function showRoute(routeResults, barriers, gpMessages) {
for (var i = 0; i < gpMessages.length; i++)
alert(gpMessages.type + ": " + gpMessages.description);
map.graphics.add(routeResults[0].route.setSymbol(routeSymbol));
}
function errorHandler(err) {
alert("An error occured\n" + err.message +
"\n" + err.details.join("\n"));
}
</script>
</head>
<body class="claro">
<div data-dojo-type="dijit/layout/BorderContainer"
data-dojo-props="design:'headline', gutters:false"
style="width:100%;height:100%;">
<div data-dojo-type="dijit/layout/ContentPane"
data-dojo-props="region:'right'"
style="width:250px;">
<button onclick="routeTask.solve(routeParams)">Click me</button>
</div>
</body>
</html>