<?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: Can Graphics Layers be Queried?  in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/613954#M57432</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Taking a second look this morning I see how you can take a collection of graphics and set them as a &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source"&gt;source &lt;/A&gt;for a new FeatureLayer. That way you have access to queryFeatures and related functionality. I thought that a FeatureLayer required a REST endpoint or Map/FeatureService as it's source.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Nov 2019 17:46:16 GMT</pubDate>
    <dc:creator>RyanSutcliffe</dc:creator>
    <dc:date>2019-11-14T17:46:16Z</dc:date>
    <item>
      <title>Can Graphics Layers be Queried?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/613949#M57427</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;Can Graphics Layers be Queried? &amp;nbsp;I cannot see anywhere that says that they cannot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know that CSV Layers cannot be queried.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 May 2017 14:22:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/613949#M57427</guid>
      <dc:creator>ChristopherSchreiber</dc:creator>
      <dc:date>2017-05-03T14:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: Can Graphics Layers be Queried?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/613950#M57428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Chris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; The simple answer is No. But you could manually query the GL by looping through it's graphics and checking the graphics attributes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 May 2017 14:41:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/613950#M57428</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2017-05-03T14:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: Can Graphics Layers be Queried?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/613951#M57429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the 4.XX API a layer view can be queried for a graphics layer the same way you would query the layer view for a feature layer:&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;&lt;SPAN&gt;// source: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fdevelopers.arcgis.com%2Fjavascript%2Flatest%2Fapi-reference%2Fesri-layers-FeatureLayer.html" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html&lt;/A&gt;&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;// returns all the graphics from the layer view&lt;/SPAN&gt;
view&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;whenLayerView&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;then&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyrView&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp; lyrView&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;watch&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"updating"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;val&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;!&lt;/SPAN&gt;val&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="comment token"&gt;// wait for the layer view to finish updating&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyrView&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;queryFeatures&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;then&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;results&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;log&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;results&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="comment token"&gt;// prints all the client-side graphics to the console&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could pass a Query into layerView.queryFeatures with an extent geometry and the 'intersects' spatial relationship to query for features inside an extent. &amp;nbsp;See &lt;A class="link-titled" href="https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html" title="https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html" rel="nofollow noopener noreferrer" target="_blank"&gt;Query | API Reference | ArcGIS API for JavaScript 4.3&lt;/A&gt;&amp;nbsp;&amp;nbsp;for more details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you're using the 3.XX API, my bet would be that you could easily write a query method yourself by accessing each graphic in a graphics layer and using the geometry engine to test each one. &amp;nbsp;This is not an approach that scales especially well. &amp;nbsp;I'm not sure if layerView.queryFeatures scales very well either.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:15:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/613951#M57429</guid>
      <dc:creator>ThomasSolow</dc:creator>
      <dc:date>2021-12-12T02:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Can Graphics Layers be Queried?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/613952#M57430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all for the feedback!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 May 2017 15:41:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/613952#M57430</guid>
      <dc:creator>ChristopherSchreiber</dc:creator>
      <dc:date>2017-05-03T15:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: Can Graphics Layers be Queried?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/613953#M57431</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I could be wrong but I don't see how you can get a LayerView class from a GraphicsLayer. Seems a GraphicsLayer creates a&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-GraphicsLayerView.html"&gt;&amp;nbsp;GraphicsLayerView&lt;/A&gt;&amp;nbsp;which only has queryGraphics(). The example and link above works only for a FeatureLayer. If either of you were indeed able to do the above would love to see a code sample of how you got this: specifically a LayerView from a GraphicsLayer in a map.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Nov 2019 02:17:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/613953#M57431</guid>
      <dc:creator>RyanSutcliffe</dc:creator>
      <dc:date>2019-11-14T02:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: Can Graphics Layers be Queried?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/613954#M57432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Taking a second look this morning I see how you can take a collection of graphics and set them as a &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source"&gt;source &lt;/A&gt;for a new FeatureLayer. That way you have access to queryFeatures and related functionality. I thought that a FeatureLayer required a REST endpoint or Map/FeatureService as it's source.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Nov 2019 17:46:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/613954#M57432</guid>
      <dc:creator>RyanSutcliffe</dc:creator>
      <dc:date>2019-11-14T17:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: Can Graphics Layers be Queried?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/1550538#M85922</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/6031"&gt;@RyanSutcliffe&lt;/a&gt;&amp;nbsp;, did you manage to get this to work for querying a GraphicsLayer? Would you be open to sharing a code snippet? Thank you very much!&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 17:14:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/1550538#M85922</guid>
      <dc:creator>Sparkles</dc:creator>
      <dc:date>2024-10-21T17:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Can Graphics Layers be Queried?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/1550547#M85924</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/6031"&gt;@RyanSutcliffe&lt;/a&gt;&amp;nbsp;, did you manage to get this to work for querying a GraphicsLayer? Would you be open to sharing a code snippet? Thank you very much!&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 17:38:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/1550547#M85924</guid>
      <dc:creator>Sparkles</dc:creator>
      <dc:date>2024-10-21T17:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Can Graphics Layers be Queried?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/1551135#M85941</link>
      <description>&lt;P&gt;Its been a few years, if I recall the above OP's code worked, the trick was to make your graphicsLayer the source of a FeatureLayer and then you should be good to go. Sorry no codepen kicking around.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2024 01:15:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-graphics-layers-be-queried/m-p/1551135#M85941</guid>
      <dc:creator>RyanSutcliffe</dc:creator>
      <dc:date>2024-10-23T01:15:40Z</dc:date>
    </item>
  </channel>
</rss>

