imihiro

why does routTask.solve(routePara,function(resultRoutes){}) only returns 1 route?

Discussion created by imihiro on May 13, 2013
Subway map published to network analysis service.
     select A as start station, B as destination station. then routeTask.solve(paras,function(resultRoutes){});
     why only one route returned while obviously there are multiple routes?
     It has been recognized the routeTask.solve() return the route of shortest distance by default.
     However,in many subway-transfer-route cases, a shortest distance route may cost more time than the second shortest distance route.
     How to get the second shortest distance route using the ArcGIS Javascript API 3.4?
     How to get the second shortest distance route using ArcGIS SDK?
     Any Help would be appreciated.

Here is my code snippets
   
var routeTask = new esri.tasks.RouteTask(networkService);
var routeParas = new esri.tasks.RouteParameters();
routeParas.outSpatialReference = map.spatialReference; //outspatialReference of rp
routeParas.returnRoutes = true;
routeParas.stops = new esri.tasks.FeatureSet(); //stops of rp, each stop is a esri.Grahic
routeParas.stops.features.push(tempGra1); //start station
routeParas.stops.features.push(tempGra2);//end station

var routeSymbol = new esri.symbol.SimpleLineSymbol().setColor(new dojo.Color([0, 0, 255, 0.5])).setWidth(5);
routeTask.solve(routeParas, function (solveResults) {
alert(solveResults.routeResults.length);//always one route,why?
........
}

Outcomes