<?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: Using two queries with a few different layers in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-two-queries-with-a-few-different-layers/m-p/461969#M42691</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;well, as to the objective. I would want the user to be able to search for a stream within the tax district. I wrote it that way, because I wanted to make sure the taxquery worked before I tried to write the next query which would find the specified stream&amp;nbsp; that intersect or are within the geometry of the taxquery geometry. which would use spatial ref intersect or contain I think&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Aug 2013 15:05:44 GMT</pubDate>
    <dc:creator>EvanKarmazin</dc:creator>
    <dc:date>2013-08-08T15:05:44Z</dc:date>
    <item>
      <title>Using two queries with a few different layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-two-queries-with-a-few-different-layers/m-p/461964#M42686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have been working on finding samples that would give me an idea of where to go next. Alot of the sample I have found are back in the 1.6 javascript api&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;[HTML]&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jssamples_start.htm#jssamples/query_bypoly.html[/HTML]" rel="nofollow" target="_blank"&gt;http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jssamples_start.htm#jssamples/query_bypoly.html[/HTML]&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The objective I have is that I would like to allow users to search for a polygon location from one layer, and use a second query to determine if a different layer intersects the graphic returned by that first query.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;While I realize the code is old, does the code below add the first query's graphic to the map then call the second query?&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;var firstGraphic = null; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // +++++Listen for QueryTask onComplete event+++++ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.connect(queryTask, "onComplete", function(graphics) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; firstGraphic = graphics.features[0]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new dojo.Color([100,100,100]), 3), new dojo.Color([255,0,0,0.20])); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; firstGraphic.setSymbol(symbol); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; firstGraphic.setInfoTemplate(infoTemplate);&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.graphics.add(firstGraphic); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query.geometry = firstGraphic.geometry; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_TOUCHES; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queryTaskTouches.execute(query); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.byId('messages').innerHTML = "&amp;lt;b&amp;gt;Executing Polygon Touches Query...&amp;lt;/b&amp;gt;";&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 18:18:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-two-queries-with-a-few-different-layers/m-p/461964#M42686</guid>
      <dc:creator>EvanKarmazin</dc:creator>
      <dc:date>2013-08-06T18:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using two queries with a few different layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-two-queries-with-a-few-different-layers/m-p/461965#M42687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The whole idea should work. Since there are some code missing, it's hard to tell if the code works. What went wrong with your code?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 22:10:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-two-queries-with-a-few-different-layers/m-p/461965#M42687</guid>
      <dc:creator>JasonZou</dc:creator>
      <dc:date>2013-08-07T22:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using two queries with a few different layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-two-queries-with-a-few-different-layers/m-p/461966#M42688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I would like to allow users to search for a polygon location from one layer, and use a second query to determine if a different layer intersects the graphic returned by that first query.&lt;BR /&gt;&lt;BR /&gt;Does the code below add the first query's graphic to the map then call the second query?&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I agree with Jason - this code fragment does what you're asking. If it's failing, it's probably because you haven't defined &lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/en/javascript/jsapi/query.html"&gt;query&lt;/A&gt;&lt;SPAN&gt; or &lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/en/javascript/jsapi/querytask.html"&gt;queryTaskTouches&lt;BR /&gt;&lt;BR /&gt;Y&lt;/A&gt;&lt;SPAN&gt;ou also haven't verified that there are any results:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;firstGraphic = graphics.features[0];&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;this might be null if there are no returned graphics.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 22:28:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-two-queries-with-a-few-different-layers/m-p/461966#M42688</guid>
      <dc:creator>StephenLead</dc:creator>
      <dc:date>2013-08-07T22:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using two queries with a few different layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-two-queries-with-a-few-different-layers/m-p/461967#M42689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That is code from the example, I was just trying to make sure I understood it as far as I had gotten, my code is below: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The query does send, and gets a geometry response, I just was thinking what might be the best way to add the geometry to the map. I am not sure that I have finalized the query. I have been working on using a json file to make the input more accurate for the fields using drop downs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function queryFunction() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; county = document.getElementById("countyField").value;
&amp;nbsp;&amp;nbsp;&amp;nbsp; taxDistrict = document.getElementById("taxDistrict").value;
&amp;nbsp;&amp;nbsp;&amp;nbsp; //streams = document.getElementById("streamField").value;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var queryStreamsTask = new esri.tasks.QueryTask("link");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var queryTaxDistrictsTask = new esri.tasks.QueryTask("link");
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var queryTaxDistricts = new esri.tasks.Query();
&amp;nbsp;&amp;nbsp;&amp;nbsp; queryTaxDistricts.returnGeometry = true;
&amp;nbsp;&amp;nbsp;&amp;nbsp; queryTaxDistricts.outFields = ["DNAME", "CNAME"];
&amp;nbsp;&amp;nbsp;&amp;nbsp; queryTaxDistricts.where = "CNAME = '" + county + "' and DNAME = '" + taxDistrict + "'";
&amp;nbsp;&amp;nbsp;&amp;nbsp; queryTaxDistrictsTask.execute(queryTaxDistricts);&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:32:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-two-queries-with-a-few-different-layers/m-p/461967#M42689</guid>
      <dc:creator>EvanKarmazin</dc:creator>
      <dc:date>2021-12-11T20:32:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using two queries with a few different layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-two-queries-with-a-few-different-layers/m-p/461968#M42690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Not clear what you like to accomplish by reading your code. Do you like to query the TaxDistrict layer first, and then using the returned TaxDistrict features to query against Streams layer using spatial touch or spatial intersect?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are some issues with your code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Since there will be two queries and one will be performed after another, two functions will be needed, one to perform the first query; the other is the callback function of the first query, and will perform the second query.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. You haven't defined the callback function for queryTaxDistrictsTask.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the workflow I would have if you like to query TaxDistricts first, and the Streams layer the second based on the TaxDistricts query result.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;function queryTaxDistrictsFunc() {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; county = document.getElementById("countyField").value;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; taxDistrict = document.getElementById("taxDistrict").value;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var queryTaxDistrictsTask = new esri.tasks.QueryTask("url of the TaxDistricts layer");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var queryTaxDistricts = new esri.tasks.Query();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; queryTaxDistricts.returnGeometry = true;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; queryTaxDistricts.outFields = ["DNAME", "CNAME"];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; queryTaxDistricts.where = "CNAME = '" + county + "' and DNAME = '" + taxDistrict + "'";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; queryTaxDistrictsTask.execute(queryTaxDistricts, callbackTaxDistrictsQuery);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;function callbackTaxDistrictsQuery(featureSet) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; firstGraphic = featureSet.features[0];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new dojo.Color([100,100,100]), 3), new dojo.Color([255,0,0,0.20]));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; firstGraphic.setSymbol(symbol);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; firstGraphic.setInfoTemplate(infoTemplate);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.graphics.add(firstGraphic);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;var queryStreamsTask = new esri.tasks.QueryTask("url of the Streams layer");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query.geometry = firstGraphic.geometry;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_TOUCHES;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queryStreamsTask.execute(query, callbackStreamsQuery);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;function callbackStreamsQuery(featureSet) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;// do what ever you like to handle the Streams result here&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Aug 2013 13:53:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-two-queries-with-a-few-different-layers/m-p/461968#M42690</guid>
      <dc:creator>JasonZou</dc:creator>
      <dc:date>2013-08-08T13:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using two queries with a few different layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-two-queries-with-a-few-different-layers/m-p/461969#M42691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;well, as to the objective. I would want the user to be able to search for a stream within the tax district. I wrote it that way, because I wanted to make sure the taxquery worked before I tried to write the next query which would find the specified stream&amp;nbsp; that intersect or are within the geometry of the taxquery geometry. which would use spatial ref intersect or contain I think&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Aug 2013 15:05:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-two-queries-with-a-few-different-layers/m-p/461969#M42691</guid>
      <dc:creator>EvanKarmazin</dc:creator>
      <dc:date>2013-08-08T15:05:44Z</dc:date>
    </item>
  </channel>
</rss>

