AnsweredAssumed Answered

Calculate several routes' totalTime using 'solve' function in RouteTask

Question asked by LinQing on Feb 24, 2016
Latest reply on Feb 26, 2016 by LinQing

Hello everybody,

I am trying to get the travel time of several routes using the methods and functions in 'RouteTask' but I met a problem. Here are my codes.

function Judge(){
    var combination=get_Combination();  //get_Combination() is a function that can return the different combinations of stops
    for(var h=0;h<combination.length;h++){
          clearStops(); // clear the stops set
          add(combination[h]);  // add the stop combinations in array into the stops set
          solve_Route();
     }    
}

 

the solve_Route() function is,

function solve_Route() {
    routeTask.solve(routeParams).then(function(results){
        console.log(results.routeResults[0].directions.totalTime);
    });

 

My testing data has 3 stops and there are 4 combinations in total. Except the combination that only has one stop.

The problem is the order of travel time is different every time as follow. It seems like the order is random.

I don't know what the order depends on. That's to say I don't know each time corresponds to which route. And I need to know this cause I still need to use the time do some judgement. So any suggestions I will be so appreciated.

Outcomes