directions = new Directions({ map: map, stops: ["Knoxville ", "Chattanouga"], },"directionsDiv"); directions.startup(); directions.getDirections();
var directions = new Directions({ map: map }, "dir"); directions.on("load", function(){ directions._updateStops(["Knoxville ", "Chattanouga"]).then(function(stops){ console.log("stops object: ", stops); directions.getDirections(); }); });
Hi and welcome to the forums!Are you waiting for both the DOM and the map to load before calling getDirections()?
on(map, "load", function(){ // the map has been loaded, do the following directions.getDirections(); });
map.on("load", function(){ // the map has been loaded, do the following directions.getDirections(); });
You can use DOJO's AMD style event listener, on, and listen for the 'load' event that the map emits.http://dojotoolkit.org/reference-guide/1.9/dojo/on.html#dojo-onBlog:http://dojotoolkit.org/documentation/tutorials/1.9/events/ on(map, "load", function(){ // the map has been loaded, do the following directions.getDirections(); }); edit*This should also work (same thing written differently). map.on("load", function(){ // the map has been loaded, do the following directions.getDirections(); });
console.log(map.loaded); directions.getDirections();
Hey James,It looks like this is an unintended bug. It will be fixed in the next version.In the meantime, here is a work-around using one of the internal ("private") functions. var directions = new Directions({ map: map }, "dir"); directions.on("load", function(){ directions._updateStops(["Knoxville ", "Chattanouga"]).then(function(stops){ console.log("stops object: ", stops); directions.getDirections(); }); }); Note: For this work-around, don't set the 'stops' parameter in the Direction widget constructor. We are using the deferred returned by _updateStops() to confirm that the stops have been properly loaded.
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.