closestFacilityTask.solve(params,function(solveResult){ var vente = new esri.Graphic(solveResult.facilities[0]); venteGraphicsLayer.add(vente); });
My apologies for the necro-bump, but I'm currently attempting to do this same thing. Is there any way to return either the lat/long or the address of the point so that I can feed it back into the directions widget?
Got it, for future google reference, I reached into the output and extracted it by the id like so:
closestFacilityTask.solve(paramsCF, function(solveResult){
array.forEach(solveResult.routes, function(route, index){
var attr = array.map(solveResult.directions[index].features, function(feature){
return feature.attributes.text;
});
route.setAttributes(attr);
destination = route.attributes[route.attributes.length - 1];
destinationArray = destination.split(" ");
destinationId = destinationArray[3];
stopId = +destinationId;
console.log("stopId: ", stopId);
stopPointX = paramsCF.facilities.features[stopId-1].geometry.x;
stopPointY = paramsCF.facilities.features[stopId-1].geometry.y;
stopPoint = new Point(stopPointX, stopPointY);
console.log("stopPoint inside function: ", stopPoint);
// start the directions widget
startDirections();
});
});