<?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: Spatial Query in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/spatial-query/m-p/8810#M809</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have seen the code examples that do what you suggest.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The way I want to go is to start the selection process by entering a state name in a text box.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;And I can select a state by entering the state name in a text box.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My problem is getting the code that will create a spatial query on another layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Robert&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 Mar 2013 04:12:30 GMT</pubDate>
    <dc:creator>RobertPincus</dc:creator>
    <dc:date>2013-03-06T04:12:30Z</dc:date>
    <item>
      <title>Spatial Query</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/spatial-query/m-p/8808#M807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I want to select a polygon in one layer, run a spatial query on another layer and list the attributes of the selected features.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;For example, using the service at "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/" rel="nofollow" target="_blank"&gt;http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/&lt;/A&gt;&lt;SPAN&gt;", I can select the State of California's feature (layer 5). I then want to take this feature and run a spatial query on the Counties layer (layer 3) and list the names of the selected counties.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Robert&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2013 23:23:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/spatial-query/m-p/8808#M807</guid>
      <dc:creator>RobertPincus</dc:creator>
      <dc:date>2013-03-05T23:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: Spatial Query</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/spatial-query/m-p/8809#M808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Robert,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This can be done with two spatial queries:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. query the state using the map click point.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. use the result of first query(state polygon) to query the counties layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope this helps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rahul&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Mar 2013 03:38:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/spatial-query/m-p/8809#M808</guid>
      <dc:creator>RahulMetangale1</dc:creator>
      <dc:date>2013-03-06T03:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: Spatial Query</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/spatial-query/m-p/8810#M809</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have seen the code examples that do what you suggest.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The way I want to go is to start the selection process by entering a state name in a text box.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;And I can select a state by entering the state name in a text box.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My problem is getting the code that will create a spatial query on another layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Robert&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Mar 2013 04:12:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/spatial-query/m-p/8810#M809</guid>
      <dc:creator>RobertPincus</dc:creator>
      <dc:date>2013-03-06T04:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Spatial Query</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/spatial-query/m-p/8811#M810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The first query function finds the geometry, which is then passed to another querytask, this one based on geometry as a search instead of by attributes.&amp;nbsp; In my example, I am using region, but you should be able to follow the logic.&amp;nbsp; I have a dropdown list instead of a text input field to make sure the input is valid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;function findRegion(){ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var e = document.getElementById("regionSelect");&amp;nbsp; //the component name of the region selection &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var regionQueryTask = new esri.tasks.QueryTask("http://myserverpathName/ArcGIS/rest/services/myService/MapServer/3");&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var regionQuery = new esri.tasks.Query; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; regionQuery.text = e.options[e.selectedIndex].text;//this is my primary display field&amp;nbsp; if you needed another field, use a where clause &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; regionQuery.returnGeometry = true; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; regionQueryTask.execute(regionQuery,showRegionResults); &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The result function of the initial query finds the geometry of the feature that is selected in findRegion&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;function showRegionResults (results) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; region = results.features[0].geometry; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.setExtent(region.getExtent(), true);&amp;nbsp; //zooms to the region &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; findFeatureInRegion(region); &amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp; function findFeatureInRegion(region) { &amp;nbsp;&amp;nbsp; var newQueryTask = new esri.tasks.QueryTask("http://myserverpathName/arcgis/rest/services/myService/MapServer/2"); //EUSstaff &amp;nbsp;&amp;nbsp; var newQuery = new esri.tasks.Query; &amp;nbsp;&amp;nbsp; newQuery.outFields = ["*"]; &amp;nbsp;&amp;nbsp; if (region) { &amp;nbsp;&amp;nbsp; newQuery.geometry = region; &amp;nbsp;&amp;nbsp; newQuery.spatialRelationship = esri.tasks.Query.SPATIAL_REL_CONTAINS; &amp;nbsp;&amp;nbsp; newQueryTask.execute(newQuery);&amp;nbsp; dojo.connect(newQueryTask, "onComplete", function(results){&amp;nbsp; //whatever you wanted to do with the features that were selected in the 2nd query } }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Mar 2013 12:47:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/spatial-query/m-p/8811#M810</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2013-03-06T12:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: Spatial Query</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/spatial-query/m-p/8812#M811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This works. Thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Robert&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Mar 2013 20:44:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/spatial-query/m-p/8812#M811</guid>
      <dc:creator>RobertPincus</dc:creator>
      <dc:date>2013-03-06T20:44:41Z</dc:date>
    </item>
  </channel>
</rss>

