I have carried out a QueryTask on a map service that returns a polygon when I input a postcode. Within the same service there is an additional layer that allows the user to query a local authority name on. I would like to carry out a querytask on this layer at the same time so that the map returns a polygon relating to the postcode input and also tells me what local authority it is contained within. I will ultimately show the local authority in a separate widget.
Can anyone help please?
[GIS] ArcGIS Javascript API – carrying out multiple query tasks
arcgis-javascript-apiquery-task
Best Answer
Correct me if I'm wrong, but it sounds like the layer with the local authority data is separate from the layer with the post code.
You'll need a second QueryTask for the layer with the local authority data. When the first QueryTask returns the polygon boundary of the post code, pass that polygon geometry into a Query.geometry parameter, and use the new query parameters in the second QueryTask. I've provided a little sample code below.