I want to query a REST Service for the underlying Points/Polylines/Polygons.
ie. ../FeatureServer/0/query, ../FeatureServer/1/query and ../FeatureServer/2/query
Instead of nesting all the callbacks into each other I am trying to find a way to execute each query synchronously so that I can group the results in one array.
I also noticed there is a ../FeatureServer/query service that enables to query all the 3 underlying layers together but can this be achieved through the Javascript API Objects? A jquery synchronous ajax call would suffice but I would like to achieve this the proper way through the API.
Thanks
Brian
Solved! Go to Solution.
If you are just using the REST API directly then a FeatureServer/query is the way to go to query multiple layers in a single request - note that this is still an asynchronous request.
If you are using the JavaScript API then you can group multiple QueryTasks into a DefferedList and process the results when all queries are completed. From your code it appears as though you are responding to a single request even though multiple server requests are sent.
You should look into Dojo DefferedLists as a way to combine the results of multiple query tasks. More information on them is available on this page - http://davidwalsh.name/deferredlist
If you are just using the REST API directly then a FeatureServer/query is the way to go to query multiple layers in a single request - note that this is still an asynchronous request.
If you are using the JavaScript API then you can group multiple QueryTasks into a DefferedList and process the results when all queries are completed. From your code it appears as though you are responding to a single request even though multiple server requests are sent.
You should look into Dojo DefferedLists as a way to combine the results of multiple query tasks. More information on them is available on this page - http://davidwalsh.name/deferredlist
Thanks for the help, i ll definitely look into the DefferedList.
Also, check out this post that uses the newer version of dojo promise lists: