AnsweredAssumed Answered

Track QueryTask request in callback function

Question asked by bforbhavin on Aug 26, 2014
Latest reply on Apr 3, 2015 by kenbuja

I need to perform buffer search for multiple layers in my project. Consider that user is selecting layer and entering radius/uom on the form.

 

I am doing it following way but due to multiple asynchronous requests, I am not sure how to track querytask request in the callback function. In the following example, I want to know which layer's request has been completed in executeEquipmentSearch. Can we identify that while sending multiple async requests? Is there any alternative in such scenarios?

 

for (var i = 1; i <= vBufferRows; i++) {

         //query task - constructing map service url for the layer

         vQueryTask = QueryTask(vMapServiceUrl + '/' + findLayerId(searchParams['bufflayer' + i]));

                   

         //gis query

         vQuery = new Query();

         vQuery.where = 'OBJECTID IN (' + searchParams['objectid'] + ')';

         vQuery.returnGeometry = true;

         vQuery.outFields = ['*'];

                   

         //execute query

         vQueryTask.execute(vQuery, executeEquipmentSearch);

}

 

function executeEquipmentSearch(response) {

       var vFeatures = response.features;

       for (var j = 0, len = vFeatures.length; j < len; j++) {

                   //Need to perform buffer search here based on the radius/uom entered on form along with the layer.    

        }

}

Outcomes