AnsweredAssumed Answered

Get Driving Directions code advice

Question asked by averydc on Feb 12, 2014
Latest reply on Feb 14, 2014 by JGravois-esristaff
Hello,

I am working on the get driving directions sample code and am trying to execute a routing task when clicking "get directions," but I am unable to see anything working on my application.

I have entered the following code
//Execute a routing task when clicking "get direction".
    getDirections:function () {
     console.log("hello where are you");
     
      routeParams.stops.features = [];
      this.map.graphics.clear();

    //Get origin address.
      var optionsFrom = {
        address:{"SingleLine":dojo.byId("fromTxf").value},
        outFields:["*"]
      }
      var fromAddress = locator.addressToLocations(optionsFrom);
   
      //Get destination address.
      var optionsTo = {
        address:{"SingleLine":dojo.byId("toTxf").value},
        outFields:["*"],
      }
      var toAddress = locator.addressToLocations(optionsTo);

      //Create a deferred list with the dojo.deferred objects of fromAddress and toAddress, then find the route.
     /* all([fromAddress,toAddress]).always(function(results){
     });
    }*/
      var dList = new dojo.DeferredList([fromAddress,toAddress]);
      dList.then(configureRoute);
    }


However, I show that "Deferred" has been deprecated, so I was trying to use the "dojo/promise/all" but I am still not getting any results.
var  //Create a deferred list with the dojo.deferred objects of fromAddress and toAddress, then find the route.
      var all = new All([fromAddress,toAddress]);
      all.always(configureRoute);
    
    };
Should I just use deferred or switch to the new version promise/all?

I am stuck and looking for some help with any of you expertise. Please let me know what you think.. thanks..

Outcomes