edavidson33

Closest Facility Blues: Total Drive Times

Discussion created by edavidson33 on Apr 9, 2014
Hi, I have a web mapping project that I have a problem with. I am using REST services to run a network analyst closest facility. All is well with one exception, I cant seem to get the accumulated minutes into a variable.

My goal is to show the accumulated minutes for expected time of arrival.

I feel like I have looked at everything but nothing seems to work. Any help on this would be appreciated.

Thanks

Here is the solve portion:

//solve, I am trying to pull the time attribute here for drive time: stuck
    closestFacilityTask.solve(params,function(solveResult){
      
        var directions = solveResult.directions;
   var time = directions.totalDriveTime;
  
    var totalLength = time;
   var driveTime = document.getElementById("driveT");
   driveTime.value = totalLength;
 
  
    dojo.forEach(solveResult.routes, function(route, index){
//build an array of route info
          var attr = dojo.map(solveResult.directions[index].features,function(feature){
            return feature.attributes.text + "<br>"+(feature.attributes.length.toFixed(2))+" "+"Miles<br>"+" "+(feature.attributes.time.toFixed(2))+" "+"Minutes<br>";
   });

          var infoTemplate = new esri.InfoTemplate("Attributes", "${*}");
  
//Set up info template for routes and assign attributes
          route.setInfoTemplate(infoTemplate);
          route.setAttributes(attr);
//Add the route graphic to the map and prescribed inner html for directionsDiv
          routeGraphicLayer.add(route);
          dojo.byId("directionsDiv").innerHTML = "Hover over the route to view directions";
        });
     
//display any messages: Scans for solve result messages and handles errors
        if(solveResult.messages.length < 0){
          dojo.byId("directionsDiv").innerHTML = "<b>Error:</b> " + solveResult.messages[0];
        }
      });
    }

Outcomes