<?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 do I get an array of Graphics, in a given radius?  in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-get-an-array-of-graphics-in-a-given/m-p/94283#M8600</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you sounds great &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/grin.png" /&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This makes a lot of sense to me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 10 Aug 2017 20:08:11 GMT</pubDate>
    <dc:creator>RobertTaracha</dc:creator>
    <dc:date>2017-08-10T20:08:11Z</dc:date>
    <item>
      <title>How do I get an array of Graphics, in a given radius?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-get-an-array-of-graphics-in-a-given/m-p/94278#M8595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;I am&amp;nbsp;trying to make a function where I can locate near by points. The idea is that I click on a point in the map and a hitTest would return the graphic. This graphic would be the center point and I would find all points within a given radius. Ideally I would want to know the point and the distance and in a array.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am lost at the moment, I am working with multiple Feature Layers. If possible to point me to an example that would be perfect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a sample of what I am doing at the moment.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;""""""""""""""""""""""" This point gives me the graphics objec I clicked on """"""""""""""""""""""""""""""""'&lt;/P&gt;&lt;P&gt;bd4sp.view.hitTest(event)&lt;BR /&gt; .then(bd4sp.getGraphics) //gets the graphics&lt;BR /&gt; .then(bd4sp.createDistanceLayer); // creates the lines for distance&lt;/P&gt;&lt;P&gt;""""""""""""""""""""""""""""""""""""""&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;***********************************************************************************************************************************&lt;/P&gt;&lt;P&gt;// This function takes the response and tries&lt;/P&gt;&lt;P&gt;getGraphics: function (response) {&amp;nbsp;&lt;BR /&gt; //clearPolyline(); //clear old lines&lt;BR /&gt; var graphic = response.results[0].graphic; //the top most graphic from the click location&lt;/P&gt;&lt;P&gt;console.log("Graphic Object", graphic['geometry']);&lt;BR /&gt;var close_points = bd4sp.geo_engine.nearestVertices(graphic['geometry'],graphic['geometry'], 300, 20);&lt;BR /&gt; console.log("Close Points", close_points);&lt;BR /&gt; //Obtain lat and long form graphic information&lt;BR /&gt; var p_o_i = bd4sp.point_of_intrest[0].geogrpraphic_proximity; // point of intrests&lt;BR /&gt; var lat_long_arry = [];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; var polyarry = [];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for (var make in p_o_i) {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;for (var i = 0; i &amp;lt; p_o_i[make].length; i++) {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var x = p_o_i[make]&lt;I&gt;.x;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var y = p_o_i[make]&lt;I&gt;.y;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lat_long_arry.push({x,y});&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;polyarry = bd4sp.getAllClosePoints(graphic.geometry['latitude'], graphic.geometry['longitude'], lat_long_arry); //array of graphic lines&lt;BR /&gt; console.log("LINES TO DRAW -&amp;gt;", polyarry);&lt;BR /&gt; return polyarry;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;***********************************************************************************************************************************&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var close_points = bd4sp.geo_engine.nearestVertices(graphic['geometry'],graphic['geometry'], 300, 20);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;returns an array but I always get 0 because its the same point, is there a way to have one argument only?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Aug 2017 16:52:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-get-an-array-of-graphics-in-a-given/m-p/94278#M8595</guid>
      <dc:creator>RobertTaracha</dc:creator>
      <dc:date>2017-08-10T16:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get an array of Graphics, in a given radius?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-get-an-array-of-graphics-in-a-given/m-p/94279#M8596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Isn't the first parameter of the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#nearestVertices"&gt;nearestVertices&lt;/A&gt; method supposed to be the geometry of the points you're trying to locate instead of the point you clicked?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Aug 2017 17:29:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-get-an-array-of-graphics-in-a-given/m-p/94279#M8596</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2017-08-10T17:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get an array of Graphics, in a given radius?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-get-an-array-of-graphics-in-a-given/m-p/94280#M8597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It might be but i am wondering if there is a way to find those points in a radius and get there information, without knowing where it is exactly.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Aug 2017 18:22:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-get-an-array-of-graphics-in-a-given/m-p/94280#M8597</guid>
      <dc:creator>RobertTaracha</dc:creator>
      <dc:date>2017-08-10T18:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get an array of Graphics, in a given radius?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-get-an-array-of-graphics-in-a-given/m-p/94281#M8598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My approach on this would be to create a &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#buffer"&gt;buffer&lt;/A&gt; and use that geometry in a &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html"&gt;query&lt;/A&gt; of your point layer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Aug 2017 19:33:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-get-an-array-of-graphics-in-a-given/m-p/94281#M8598</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2017-08-10T19:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get an array of Graphics, in a given radius?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-get-an-array-of-graphics-in-a-given/m-p/94282#M8599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What probably want to do here is:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;User clicks map: do a hitTest, if a graphic is a found, take that graphic's geometry and continue&lt;/LI&gt;&lt;LI&gt;Using the geometry obtained in step 1, create a circle geometry with the center as the geometry from step 1 and a radius of whatever you like (note, circles can be geodesic if you're using wgs84 or web mercator, default unit for setting radius is meters)&lt;/LI&gt;&lt;LI&gt;Take the extent of the circle you just created (circles, like polygons automatically compute their extent when created. &amp;nbsp;Access this via circle.extent).&lt;/LI&gt;&lt;LI&gt;Test the extent of the circle against all the graphics on each featureLayer you want to search. &amp;nbsp;This can be done manually or with featureLayerView.queryFeatures or with featureLayer.queryFeatures&lt;/LI&gt;&lt;LI&gt;Take the array of graphics that results from step 4 and filter&amp;nbsp;them against the original circle. &amp;nbsp;Use geometryEngine.intersects(circle, graphic.geometry) for each graphic that passed the previous test.&lt;/LI&gt;&lt;LI&gt;The result is an array of graphics that fit inside the circle for each feature layer you tested.&lt;/LI&gt;&lt;LI&gt;You can now compute distance using the geometry Engine, or Point.distance(point) and display the results however you like.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's preferable (in my opinion) to do the extent search first because it's cheap compared to the circle search, and the majority of graphics will likely be eliminated. &amp;nbsp;The geometryEngine.intersects method is more expensive when using a circle or polygon, so this should only be tested against graphics you know are inside the circle's extent.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit - this is the client-side method. &amp;nbsp;You can also pass in the circle to featureLayer.queryFeatures to do this on the server. &amp;nbsp;If you do this, you'll want to send one featureLayer.queryFeatures request for each featureLayer. &amp;nbsp;You'll wrap these requests in Promise.all(), wait for all of them to return, and then display your results with polylines or however you like. &amp;nbsp;If you use the server, you don't need to worry about the intersects method being expensive so forget the circle.extent stuff for that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Aug 2017 19:42:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-get-an-array-of-graphics-in-a-given/m-p/94282#M8599</guid>
      <dc:creator>ThomasSolow</dc:creator>
      <dc:date>2017-08-10T19:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get an array of Graphics, in a given radius?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-get-an-array-of-graphics-in-a-given/m-p/94283#M8600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you sounds great &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/grin.png" /&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This makes a lot of sense to me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Aug 2017 20:08:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-get-an-array-of-graphics-in-a-given/m-p/94283#M8600</guid>
      <dc:creator>RobertTaracha</dc:creator>
      <dc:date>2017-08-10T20:08:11Z</dc:date>
    </item>
  </channel>
</rss>

