<?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: Question about hitTest() in JSAPI v4.30 in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-hittest-in-jsapi-v4-30/m-p/1525193#M85456</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/53756"&gt;@UndralBatsukh&lt;/a&gt;&amp;nbsp;Sorry about the late reply... how do I create the layer?&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/237415"&gt;@Arne_Gelfert&lt;/a&gt;&amp;nbsp;wrote:&lt;P&gt;Where does &lt;EM&gt;interesting_layer&lt;/EM&gt; come from? I currently loop through webmap layers once view has loaded and assign some names to key layers I want to interact with later.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var interesting_layer;

view.when(function() {

   //The following is another simplified version of what's actually 
   //defined in another function elsewhere
   webmap.layers.forEach(lyr =&amp;gt; { 
      if (lyr.title == 'layer_of_interest')
          { interesting_layer = lyr }

});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, it's actually a sublayer from the web map of type 'map-image'. I figured that would work. But maybe ESRI is throwing me another curveball. I'll take another look when I get a chance. Thanks for chiming in.&lt;/P&gt;</description>
    <pubDate>Wed, 21 Aug 2024 16:05:24 GMT</pubDate>
    <dc:creator>Arne_Gelfert</dc:creator>
    <dc:date>2024-08-21T16:05:24Z</dc:date>
    <item>
      <title>Question about hitTest() in JSAPI v4.30</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-hittest-in-jsapi-v4-30/m-p/1520898#M85331</link>
      <description>&lt;P&gt;Simple question(s) alert !&amp;nbsp; (Although some of you may find it vague or missing more detailed code. Unfortunately, I cannot paste all my code here.)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Why would hitTest() only return basemap hits as a result when I have several layers in my map? Do layers from a webmap&amp;nbsp;brought into your app as Portal item work differently from those that are added as layers (Featurelayer/MapImageLayer) via URL?&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I recently started transitioning from JSAPI 3.x (WAB-DE stuff) to 4.x (4.30) and might be stuck in some legacy way of thinking.&lt;/P&gt;&lt;P&gt;When I do this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.on("click", (event)=&amp;gt; {
   
   view.hitTest(event).then((response) =&amp;gt; {

// Hoping for some results from the layers in the map
// but response.results include only the basemap.
   console.log(response.results.length) // = 1

   });
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try with options, and specifically list one of the layers in the map, I get the same result.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.on("click", (event)=&amp;gt; {
   opts = { include: interesting_layer};
   view.hitTest(event,opts).then((response) =&amp;gt; {

   //Hoping for some results from the layers in the map;
   //But no!
   console.log(response.results.length) // still = 1
   });
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where does &lt;EM&gt;interesting_layer&lt;/EM&gt; come from? I currently loop through webmap layers once view has loaded and assign some names to key layers I want to interact with later.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var interesting_layer;

view.when(function() {

   //The following is another simplified version of what's actually 
   //defined in another function elsewhere
   webmap.layers.forEach(lyr =&amp;gt; { 
      if (lyr.title == 'layer_of_interest')
          { interesting_layer = lyr }

});
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 22:20:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-hittest-in-jsapi-v4-30/m-p/1520898#M85331</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2024-08-13T22:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Question about hitTest() in JSAPI v4.30</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-hittest-in-jsapi-v4-30/m-p/1520915#M85339</link>
      <description>&lt;P&gt;How are you creating an instance of the interesting_layer? What type of layer is it? The hitTest returns results for the layer types listed here in this doc:&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hitTest" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hitTest&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 22:46:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-hittest-in-jsapi-v4-30/m-p/1520915#M85339</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2024-08-13T22:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: Question about hitTest() in JSAPI v4.30</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-hittest-in-jsapi-v4-30/m-p/1525193#M85456</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/53756"&gt;@UndralBatsukh&lt;/a&gt;&amp;nbsp;Sorry about the late reply... how do I create the layer?&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/237415"&gt;@Arne_Gelfert&lt;/a&gt;&amp;nbsp;wrote:&lt;P&gt;Where does &lt;EM&gt;interesting_layer&lt;/EM&gt; come from? I currently loop through webmap layers once view has loaded and assign some names to key layers I want to interact with later.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var interesting_layer;

view.when(function() {

   //The following is another simplified version of what's actually 
   //defined in another function elsewhere
   webmap.layers.forEach(lyr =&amp;gt; { 
      if (lyr.title == 'layer_of_interest')
          { interesting_layer = lyr }

});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, it's actually a sublayer from the web map of type 'map-image'. I figured that would work. But maybe ESRI is throwing me another curveball. I'll take another look when I get a chance. Thanks for chiming in.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 16:05:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/question-about-hittest-in-jsapi-v4-30/m-p/1525193#M85456</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2024-08-21T16:05:24Z</dc:date>
    </item>
  </channel>
</rss>

