<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Asynchronous query calls in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/asynchronous-query-calls/m-p/635436#M59349</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi all, &lt;BR /&gt;&lt;BR /&gt;I'm still a newbie with the Javascript API, but my issue seems very similar to &lt;A href="http://forums.arcgis.com/threads/9676-Get-layer-ID-from-FeatureSet" rel="nofollow noopener noreferrer" target="_blank"&gt;one solved on the Flex API forum&lt;/A&gt;. I am running multiple queries, and I need to know which layerId the resulting featuresets come from. As the results are asynchronous, I'm not sure which featureset comes from which layer. &lt;BR /&gt;&lt;BR /&gt;The solution on the Flex forum was:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Add the reference to your layer when you do the query like:

queryTask.execute(query, new AsyncResponder(onResult, onFault, myLayerID));

Then define your result handler like :

function onResult(featureSet:FeatureSet, myLayerID:Number):void
{
...
}&lt;/PRE&gt; &lt;BR /&gt;&lt;BR /&gt;is there a way to do a similar thing in javascript by creating a new AsyncResponder?&lt;BR /&gt;&lt;BR /&gt;Thanks very much&lt;BR /&gt;Andrew&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If the API doesn't provide it to you, I guess you could manually pass the layerId to your callback yourself.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe something like this could work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
function callback(featureset, layerId){
...
}
 
var _this = this;

var query = new esri.tasks.Query();
query.where = "STATE_NAME = 'Washington'";
query.outSpatialReference = {wkid:102100}; 
query.returnGeometry = true;
query.outFields = ["CITY_NAME"];
queryTask.execute(query, function(featureset){ _this.callback.call(_this, featureset, 12); });

.....

queryTask.execute(query, function(featureset){ _this.callback.call(_this, featureset, 14); });

......

etc

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 03:01:37 GMT</pubDate>
    <dc:creator>YohanBienvenue</dc:creator>
    <dc:date>2021-12-12T03:01:37Z</dc:date>
    <item>
      <title>Asynchronous query calls</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/asynchronous-query-calls/m-p/635435#M59348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm still a newbie with the Javascript API, but my issue seems very similar to &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://forums.arcgis.com/threads/9676-Get-layer-ID-from-FeatureSet" rel="nofollow" target="_blank"&gt;one solved on the Flex API forum&lt;/A&gt;&lt;SPAN&gt;. I am running multiple queries, and I need to know which layerId the resulting featuresets come from. As the results are asynchronous, I'm not sure which featureset comes from which layer. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The solution on the Flex forum was:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Add the reference to your layer when you do the query like:&amp;nbsp; queryTask.execute(query, new AsyncResponder(onResult, onFault, myLayerID));&amp;nbsp; Then define your result handler like :&amp;nbsp; function onResult(featureSet:FeatureSet, myLayerID:Number):void { ... }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;is there a way to do a similar thing in javascript by creating a new AsyncResponder?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks very much&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Andrew&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2012 06:04:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/asynchronous-query-calls/m-p/635435#M59348</guid>
      <dc:creator>AndrewLeane</dc:creator>
      <dc:date>2012-05-29T06:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: Asynchronous query calls</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/asynchronous-query-calls/m-p/635436#M59349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi all, &lt;BR /&gt;&lt;BR /&gt;I'm still a newbie with the Javascript API, but my issue seems very similar to &lt;A href="http://forums.arcgis.com/threads/9676-Get-layer-ID-from-FeatureSet" rel="nofollow noopener noreferrer" target="_blank"&gt;one solved on the Flex API forum&lt;/A&gt;. I am running multiple queries, and I need to know which layerId the resulting featuresets come from. As the results are asynchronous, I'm not sure which featureset comes from which layer. &lt;BR /&gt;&lt;BR /&gt;The solution on the Flex forum was:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Add the reference to your layer when you do the query like:

queryTask.execute(query, new AsyncResponder(onResult, onFault, myLayerID));

Then define your result handler like :

function onResult(featureSet:FeatureSet, myLayerID:Number):void
{
...
}&lt;/PRE&gt; &lt;BR /&gt;&lt;BR /&gt;is there a way to do a similar thing in javascript by creating a new AsyncResponder?&lt;BR /&gt;&lt;BR /&gt;Thanks very much&lt;BR /&gt;Andrew&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If the API doesn't provide it to you, I guess you could manually pass the layerId to your callback yourself.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe something like this could work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
function callback(featureset, layerId){
...
}
 
var _this = this;

var query = new esri.tasks.Query();
query.where = "STATE_NAME = 'Washington'";
query.outSpatialReference = {wkid:102100}; 
query.returnGeometry = true;
query.outFields = ["CITY_NAME"];
queryTask.execute(query, function(featureset){ _this.callback.call(_this, featureset, 12); });

.....

queryTask.execute(query, function(featureset){ _this.callback.call(_this, featureset, 14); });

......

etc

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:01:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/asynchronous-query-calls/m-p/635436#M59349</guid>
      <dc:creator>YohanBienvenue</dc:creator>
      <dc:date>2021-12-12T03:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: Asynchronous query calls</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/asynchronous-query-calls/m-p/635437#M59350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;you can also see this sample: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/query_deferred_list.html" rel="nofollow" target="_blank"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/query_deferred_list.html&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2012 18:23:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/asynchronous-query-calls/m-p/635437#M59350</guid>
      <dc:creator>nicogis</dc:creator>
      <dc:date>2012-05-29T18:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: Asynchronous query calls</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/asynchronous-query-calls/m-p/635438#M59351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Yohan and Domenico, I used the dojo.deferredList - it's a nice neat way to keep track of the order of the queries. I'll have to remember to check all the samples, not just the API. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2012 01:52:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/asynchronous-query-calls/m-p/635438#M59351</guid>
      <dc:creator>AndrewLeane</dc:creator>
      <dc:date>2012-05-30T01:52:59Z</dc:date>
    </item>
  </channel>
</rss>

