<?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 can I find features around a point using a QueryTask? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-find-features-around-a-point-using-a/m-p/275754#M25448</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Many thanks for this. I was wondering if I could avoid an extra request by using a geometry service first, but if it's the most efficient way I'll most likely implement this. I'm currently looking into running my own geometry service in ArcGIS Server&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 Aug 2013 10:52:24 GMT</pubDate>
    <dc:creator>YohanBienvenue</dc:creator>
    <dc:date>2013-08-02T10:52:24Z</dc:date>
    <item>
      <title>How can I find features around a point using a QueryTask?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-find-features-around-a-point-using-a/m-p/275752#M25446</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a map with a ArcGISDynamicMapServiceLayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have added a graphic to the map, and now I want to query the map to get all the features around this point according to some radius in KM.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's important that the features are not located further then the circle radius around the point, so I can't use a box geometry as a spatial filter for my Query.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, in short, how can I search for features within a circle defined by a point plus a certain buffer around that point?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Can I do this with a QueryTask?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2013 19:09:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-find-features-around-a-point-using-a/m-p/275752#M25446</guid>
      <dc:creator>YohanBienvenue</dc:creator>
      <dc:date>2013-08-01T19:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: How can I find features around a point using a QueryTask?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-find-features-around-a-point-using-a/m-p/275753#M25447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can do the following if you feel that this workflow works for you&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Use the ESRI geometry task to create a buffer around the point at your specified distance&lt;/SPAN&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="https://developers.arcgis.com/en/javascript/jsapi/geometryservice.html#buffer" rel="nofollow" target="_blank"&gt;https://developers.arcgis.com/en/javascript/jsapi/geometryservice.html#buffer&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) use the returned geometry and pass in to your query.geometry property the new buffer geometry&lt;/SPAN&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="https://developers.arcgis.com/en/javascript/jsapi/query.html" rel="nofollow" target="_blank"&gt;https://developers.arcgis.com/en/javascript/jsapi/query.html&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;use the following query params to fine tune your query&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;query.geometry ==&amp;gt; your buffer geom&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;query.spatialRelationship ==&amp;gt; SPATIAL_REL_WITHIN&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Default Value: SPATIAL_REL_INTERSECTS&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3) use the results as needed&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There should be plenty of examples out there for how to execute the buffer task and of course the query task as well. I have provided some sample code that I put together to show one of many ways to accomplish this task. The most important thing to keep in mind is that both the exectute buffer and execture query return deffered objects. You will want to utitlize this so that you can prevent the application/code from running away from you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is a brief example of how you might accomplish this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;//buffer code that accepts the params for buffering and returns the dojo deferred object &amp;nbsp; bufferGeometry: function (inGeometryArray, distanceArray, inSpatialRef, outSpatialRef, geomServiceURL) { &amp;nbsp;&amp;nbsp;&amp;nbsp; var geomService = new esri.tasks.GeometryService(geomServiceURL); &amp;nbsp;&amp;nbsp;&amp;nbsp; var bufferParams = new esri.tasks.BufferParameters(); &amp;nbsp;&amp;nbsp;&amp;nbsp; bufferParams.geometries = inGeometryArray; &amp;nbsp;&amp;nbsp;&amp;nbsp; bufferParams.bufferSpatialReference = inSpatialRef; &amp;nbsp;&amp;nbsp;&amp;nbsp; bufferParams.outSpatialReference = outSpatialRef; &amp;nbsp;&amp;nbsp;&amp;nbsp; bufferParams.distances = distanceArray; //units in feet &amp;nbsp;&amp;nbsp;&amp;nbsp; bufferParams.unit = esri.tasks.GeometryService.UNIT_METER;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; var deferred = geomService.buffer(bufferParams); &amp;nbsp;&amp;nbsp;&amp;nbsp; return deferred; &amp;nbsp; }&amp;nbsp; //js code that is used to run the buffer and add the query task&amp;nbsp; var deferred = bufferGeometry([pointGeom], [50], pointGeom.spatialReference, map.spatialReference); deferred.then(function (results) { var query = new esri.tasks.Query(); query.geometry = results[0]; //or use one of the other constants to fine tune this query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_WITHIN;&amp;nbsp; query.returnGeometry = true; query.outFields = ["CITY_NAME"]; var queryTask = new esri.tasks.QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/0"); //exectute the query and call the queryComplete function/callback queryTask.execute(query, queryComplete); }, function (error) { alert("Error during buffer Geom: " + error.message); });&amp;nbsp; //another function to process your query results function queryComplete(featureSet) {&amp;nbsp;&amp;nbsp; &amp;nbsp; var features = featureSet.features;&amp;nbsp;&amp;nbsp; &amp;nbsp; //loop through your featureset and do something here! }&amp;nbsp; &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2013 20:32:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-find-features-around-a-point-using-a/m-p/275753#M25447</guid>
      <dc:creator>DianaBenedict</dc:creator>
      <dc:date>2013-08-01T20:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: How can I find features around a point using a QueryTask?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-find-features-around-a-point-using-a/m-p/275754#M25448</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Many thanks for this. I was wondering if I could avoid an extra request by using a geometry service first, but if it's the most efficient way I'll most likely implement this. I'm currently looking into running my own geometry service in ArcGIS Server&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Aug 2013 10:52:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-find-features-around-a-point-using-a/m-p/275754#M25448</guid>
      <dc:creator>YohanBienvenue</dc:creator>
      <dc:date>2013-08-02T10:52:24Z</dc:date>
    </item>
  </channel>
</rss>

