<?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: How to perform multiple querytasks? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-perform-multiple-querytasks/m-p/292944#M26886</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There are a few things to fix but the main one is how you're assigning callback functions for your query tasks. Since you're re-using global variables for your query tasks, each time showResults() is called, a new callback is attached to your query task. To avoid this, I'd recommend passing in a function for the callback argument of &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/querytask.htm#execute"&gt;queryTask.execute()&lt;/A&gt;&lt;SPAN&gt; instead of using dojo.connect to add a new callback each time showResults() runs. Take a look at the attached code to see how this is done. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The other big change I made was to use a new global to keep track of the current map click (variable named "currentClick"). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also took out your bClick variable as it seemed unnecessary (but maybe I'm missing something).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Mar 2011 20:11:31 GMT</pubDate>
    <dc:creator>derekswingley1</dc:creator>
    <dc:date>2011-03-23T20:11:31Z</dc:date>
    <item>
      <title>How to perform multiple querytasks?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-perform-multiple-querytasks/m-p/292943#M26885</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would like to perform series of querytasks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Based on the first query results, I would like to perform a second query.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;And when second query is complete, I would like to show the results in a popup window.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Attached example do seemed to work, but behaves little weird.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've added Alert to the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;On a first map click to select a state, everything seems to work correctly. And I get one alert notice.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;On my next map click to select another state, again things seems to work correctly, but this time I get about 4 alerts. Value of previous selection gets displayed on the info window.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;On my third map click, I get about 10 alert popups.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Looks like the querytasks that I have setup somehow remembers all the previous queries and loops through whenever I do mouse click on the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone see why this is happening???&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Don Kang&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Mar 2011 17:32:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-perform-multiple-querytasks/m-p/292943#M26885</guid>
      <dc:creator>DonKang</dc:creator>
      <dc:date>2011-03-23T17:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform multiple querytasks?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-perform-multiple-querytasks/m-p/292944#M26886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There are a few things to fix but the main one is how you're assigning callback functions for your query tasks. Since you're re-using global variables for your query tasks, each time showResults() is called, a new callback is attached to your query task. To avoid this, I'd recommend passing in a function for the callback argument of &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/querytask.htm#execute"&gt;queryTask.execute()&lt;/A&gt;&lt;SPAN&gt; instead of using dojo.connect to add a new callback each time showResults() runs. Take a look at the attached code to see how this is done. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The other big change I made was to use a new global to keep track of the current map click (variable named "currentClick"). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also took out your bClick variable as it seemed unnecessary (but maybe I'm missing something).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Mar 2011 20:11:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-perform-multiple-querytasks/m-p/292944#M26886</guid>
      <dc:creator>derekswingley1</dc:creator>
      <dc:date>2011-03-23T20:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform multiple querytasks?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-perform-multiple-querytasks/m-p/292945#M26887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Derek,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thank you very much for your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I started off doing something very similar to your fix before I went with dojo.connect&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;option. Yours definitly works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've received ESRI's help and their solution was to implement dojo.disconnect option at the end of function. Which also seems to work very good as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I have two different options, I will just test both and see which one renders the map faster.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry for late response, in old days, I used to get notification email when someone replys my message.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again for your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Don&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;There are a few things to fix but the main one is how you're assigning callback functions for your query tasks. Since you're re-using global variables for your query tasks, each time showResults() is called, a new callback is attached to your query task. To avoid this, I'd recommend passing in a function for the callback argument of &lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/querytask.htm#execute"&gt;queryTask.execute()&lt;/A&gt; instead of using dojo.connect to add a new callback each time showResults() runs. Take a look at the attached code to see how this is done. &lt;BR /&gt;&lt;BR /&gt;The other big change I made was to use a new global to keep track of the current map click (variable named "currentClick"). &lt;BR /&gt;&lt;BR /&gt;I also took out your bClick variable as it seemed unnecessary (but maybe I'm missing something).&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Mar 2011 14:29:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-perform-multiple-querytasks/m-p/292945#M26887</guid>
      <dc:creator>DonKang</dc:creator>
      <dc:date>2011-03-30T14:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform multiple querytasks?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-perform-multiple-querytasks/m-p/292946#M26888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Glad you got it worked out!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Mar 2011 15:11:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-perform-multiple-querytasks/m-p/292946#M26888</guid>
      <dc:creator>derekswingley1</dc:creator>
      <dc:date>2011-03-30T15:11:24Z</dc:date>
    </item>
  </channel>
</rss>

