POST
|
Hi Owen, Thank you for the help. When I view the live sample, everything seems to work. Stops and barriers are able to be placed. Routes are shown. When I copy the same code to an html document of my own without modification, I am only able to place stops and barriers. The Routes do not show. I've added alert boxes so I see it making it through the SolveRoute() function, but they do not enter the ShowRoute() function. This makes me think the 'solve-complete' is never getting triggered. However the 'error' functionality is also not getting triggered. I'm not sure how to debug this. Are there any other depreciated commands in this documentation that could be throwing things off? Thanks, -Steve
... View more
07-29-2014
07:48 AM
|
0
|
2
|
602
|
POST
|
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> <link rel="stylesheet" href="http://js.arcgis.com/3.10/js/dojo/dijit/themes/claro/claro.css"> <link rel="stylesheet" href="http://js.arcgis.com/3.10/js/esri/css/esri.css"> <style> html, body, #map { height:100%; width:100%; margin:0; padding:0; } body { background-color:#FFF; overflow:hidden; font-family:"Trebuchet MS"; } </style> <script src="http://js.arcgis.com/3.10/"></script> <script> routeTask = new esri.tasks.RouteTask("http://myServer/ArcGIS/rest/services/MyMapDoc/NAServer/MyRoute"); 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>
... View more
07-28-2014
12:53 PM
|
0
|
5
|
4328
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|