Thursday 20 September 2018

arcgis javascript api - How to synchronously execute a queryTask


How can a queryTask be executed synchronously? I'd like a feature set to be returned instead of deferred object.



Answer



In instances like this, the API returns deferred objects in case you're interested in identifying when more than one request to a server has resolved, but its not something your application logic has to worry about if you're just dealing with one task at a time.


for example, when you call QueryTask.execute() and leverage the in-built callback, you can get a reference to the featureset output you want:



queryTask.execute(query, myCallback, myErrorBack);
...
myCallback(results) {
//do something
}

To work with QueryTask deferreds, you have an additional option to do something like this:


var myDeferred = queryTask.execute(query);
myDeferred.then(...

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...