<?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: More than one clicked feature per layer in SceneView - hit test or other approach in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/more-than-one-clicked-feature-per-layer-in/m-p/1010869#M71140</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;what symbols do the graphics have? In 3D we return all the features that were clicked, except if the symbol is a billboarded icon (so &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html" target="_self"&gt;IconSymbol3DLayer&lt;/A&gt; that is not &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#elevationInfo" target="_self"&gt;on the ground&lt;/A&gt;). The &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#HitTestResult" target="_self"&gt;results property&lt;/A&gt; should give you an array of graphics that are intersected by the mouse. We have a sample that shows this behavior: &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sceneview-hittest/index.html" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/sample-code/sceneview-hittest/index.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will update the documentation to show the limitation when using icons. Unfortunately there is no workaround if this is the case you are running into.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 18 Dec 2020 09:29:16 GMT</pubDate>
    <dc:creator>RalucaNicola1</dc:creator>
    <dc:date>2020-12-18T09:29:16Z</dc:date>
    <item>
      <title>More than one clicked feature per layer in SceneView - hit test or other approach</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/more-than-one-clicked-feature-per-layer-in/m-p/548794#M51083</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I was trying to use &lt;SPAN&gt;hitTest&lt;/SPAN&gt; method of &lt;SPAN&gt;MapView&lt;/SPAN&gt;&amp;nbsp;and&amp;nbsp;&lt;SPAN&gt;SceneView&lt;/SPAN&gt; to get all clicked features from all layers displayed on view. Next we want to present user list of possibly clicked features, allow him to choose one of them and perform some action.&lt;/P&gt;&lt;P&gt;However, it seems that hit test returns maximally one feature per layer. As I understand API docs it's intentional, but it doesn't satisfy our requirements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have also tried&amp;nbsp;to call &lt;SPAN&gt;hitTest&lt;/SPAN&gt; method in a loop, adding already returned graphics to&amp;nbsp;&lt;SPAN&gt;exclude&lt;/SPAN&gt; option.&lt;/P&gt;&lt;P&gt;It seems that when one graphic is passed to &lt;SPAN&gt;exclude&lt;/SPAN&gt; parameter then whole layer containing it is excluded from hit test.&lt;/P&gt;&lt;P&gt;I find this counter-intuitive and consider this behavior a bug.&lt;BR /&gt;Here's the TypeScript code that I wrote to try this approach to the problem:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const graphicsToExclude: __esri.Graphic[] = [];
const hitTestGraphicsDictByLayerId = new Dictionary&amp;lt;string, __esri.Graphic[]&amp;gt;();
while (true) {
  const hitTestResult = await this.view.hitTest(e.screenPoint, { exclude: graphicsToExclude });
  if (hitTestResult.results.length === 0)
	break;

  for (const res of hitTestResult.results) {
	const layerId = res.graphic.layer.id;
	if (hitTestGraphicsDictByLayerId.containsKey(layerId)) {
	  const vals = hitTestGraphicsDictByLayerId.getValue(layerId);
	  vals.push(res.graphic);
	  hitTestGraphicsDictByLayerId.setValue(layerId, vals);
	}
	else {
	  hitTestGraphicsDictByLayerId.setValue(layerId, [res.graphic]);
	}
  }

  const graphics = hitTestResult.results.map(res =&amp;gt; res.graphic);
  for (const g of graphics)
     graphicsToExclude.push(g);
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;/LI-CODE&gt;&lt;P&gt;As a workaround for two-dimensional &lt;SPAN&gt;MapView&lt;/SPAN&gt; we don't use &lt;SPAN&gt;hitTest&lt;/SPAN&gt;, but instead we query all layer views using &lt;SPAN&gt;queryFeatures&lt;/SPAN&gt; method for clicked features. This approach doesn't work well for three-dimensional &lt;SPAN&gt;SceneView&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this&amp;nbsp;&lt;SPAN&gt;exclude&lt;/SPAN&gt; parameter behavior intentional or a bug?&lt;/P&gt;&lt;P&gt;Are there any plans to extend &lt;SPAN&gt;hitTest&amp;nbsp;&lt;/SPAN&gt;method to return more than one&amp;nbsp;graphic per layer? Possibly with new parameter controlling this behavior.&lt;/P&gt;&lt;P&gt;Or is there any other way to approach this problem, especially for &lt;SPAN&gt;SceneView&lt;/SPAN&gt;?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Sep 2021 13:35:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/more-than-one-clicked-feature-per-layer-in/m-p/548794#M51083</guid>
      <dc:creator>kamil_szyc</dc:creator>
      <dc:date>2021-09-01T13:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: More than one clicked feature per layer in SceneView - hit test or other approach</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/more-than-one-clicked-feature-per-layer-in/m-p/1010869#M71140</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;what symbols do the graphics have? In 3D we return all the features that were clicked, except if the symbol is a billboarded icon (so &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html" target="_self"&gt;IconSymbol3DLayer&lt;/A&gt; that is not &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#elevationInfo" target="_self"&gt;on the ground&lt;/A&gt;). The &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#HitTestResult" target="_self"&gt;results property&lt;/A&gt; should give you an array of graphics that are intersected by the mouse. We have a sample that shows this behavior: &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sceneview-hittest/index.html" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/sample-code/sceneview-hittest/index.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will update the documentation to show the limitation when using icons. Unfortunately there is no workaround if this is the case you are running into.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 09:29:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/more-than-one-clicked-feature-per-layer-in/m-p/1010869#M71140</guid>
      <dc:creator>RalucaNicola1</dc:creator>
      <dc:date>2020-12-18T09:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: More than one clicked feature per layer in SceneView - hit test or other approach</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/more-than-one-clicked-feature-per-layer-in/m-p/1094358#M74504</link>
      <description>&lt;P&gt;Excuse me for really late answer, I have missed your reply and accidentally came across it now.&lt;/P&gt;&lt;P&gt;If I remember correctly we have come upon the exact limitation that you describe.&lt;BR /&gt;Thank you for updating the documentation.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Sep 2021 13:43:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/more-than-one-clicked-feature-per-layer-in/m-p/1094358#M74504</guid>
      <dc:creator>kamil_szyc</dc:creator>
      <dc:date>2021-09-01T13:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: More than one clicked feature per layer in SceneView - hit test or other approach</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/more-than-one-clicked-feature-per-layer-in/m-p/1094567#M74510</link>
      <description>&lt;P&gt;I updated the doc in the meantime to say that only the first non draped icon is returned from a hit test. &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#hitTest" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#hitTest&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Sep 2021 18:12:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/more-than-one-clicked-feature-per-layer-in/m-p/1094567#M74510</guid>
      <dc:creator>RalucaNicola1</dc:creator>
      <dc:date>2021-09-01T18:12:27Z</dc:date>
    </item>
  </channel>
</rss>

