<?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: Attributes not included in HitTestResult in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/attributes-not-included-in-hittestresult/m-p/1336608#M82427</link>
    <description>&lt;P&gt;Thank you.&amp;nbsp; This worked for me.&amp;nbsp; And, I will add that it was some change that occurred from version 4.13 to 4.14.&lt;/P&gt;</description>
    <pubDate>Tue, 10 Oct 2023 15:34:19 GMT</pubDate>
    <dc:creator>TimDietz</dc:creator>
    <dc:date>2023-10-10T15:34:19Z</dc:date>
    <item>
      <title>Attributes not included in HitTestResult</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/attributes-not-included-in-hittestresult/m-p/144860#M13482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm performing a&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hitTest"&gt;MapView.hitTest()&amp;nbsp;&lt;/A&gt;against a feature layer in a webmap and running across inconsistencies with attributes being returned. I get a reference to the feature layer and set the outFields I want returned. However, sometimes the graphic that is 'hit' only returns the ObjectId. Other times it returns all attributes specified in outFields.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;view.on("click", function (event) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; view.hitTest(event).then(function (response) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; if (response.results.length) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; var graphic = response.results.filter(function (result) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return result.graphic.layer === myLayer;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; })[0].graphic;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // graphic.attributes only contains objectid&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // OR&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // graphic.attributes contains objectid, att1, att2, att3, etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/P&gt;&lt;P&gt;&amp;nbsp; });&lt;/P&gt;&lt;P&gt;});&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the expected behavior? For instance, should you assume that you may only get back an ObjectId and not additional attributes set through FeatureLayer.outFields? Does hitTest ignore outFields?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2019 19:34:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/attributes-not-included-in-hittestresult/m-p/144860#M13482</guid>
      <dc:creator>ShaneBuscher1</dc:creator>
      <dc:date>2019-08-22T19:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: Attributes not included in HitTestResult</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/attributes-not-included-in-hittestresult/m-p/144861#M13483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After some deeper digging the answer lies in the &lt;A href="https://developers.arcgis.com/javascript/latest/guide/programming-patterns/" rel="nofollow noopener noreferrer" target="_blank"&gt;Loadable &lt;/A&gt;pattern. Below is the solution where&amp;nbsp;each feature layer in the web map has its outFields property set to 'all' with the splat. The 'load' function initializes the feature layers the way I need BEFORE adding to the mapView. The issue I had earlier dealt with a lazy-loaded component that was setting the outFields AFTER the webMap and mapView instances had loaded and rendered.&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
let mapView = new MapView({ 
  container: 'mapEl',
});

let webMap = new WebMap(props);

webMap.load()
 .then(() =&amp;gt; {
   webMap.layers
     .filter(layer =&amp;gt; { return layer.type === 'feature' })
     .map(layer =&amp;gt; {
       let featLayer = &amp;lt;esri.FeatureLayer&amp;gt;layer; 
       featLayer.outFields = ['*'];
       return featLayer; 
     });
 });
 
mapView.map = webMap;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:06:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/attributes-not-included-in-hittestresult/m-p/144861#M13483</guid>
      <dc:creator>ShaneBuscher1</dc:creator>
      <dc:date>2021-12-12T16:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: Attributes not included in HitTestResult</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/attributes-not-included-in-hittestresult/m-p/1084601#M74081</link>
      <description>&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt;&amp;nbsp; saved my butt late on a Friday!&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 20:14:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/attributes-not-included-in-hittestresult/m-p/1084601#M74081</guid>
      <dc:creator>rogenjh</dc:creator>
      <dc:date>2021-07-30T20:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: Attributes not included in HitTestResult</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/attributes-not-included-in-hittestresult/m-p/1336608#M82427</link>
      <description>&lt;P&gt;Thank you.&amp;nbsp; This worked for me.&amp;nbsp; And, I will add that it was some change that occurred from version 4.13 to 4.14.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2023 15:34:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/attributes-not-included-in-hittestresult/m-p/1336608#M82427</guid>
      <dc:creator>TimDietz</dc:creator>
      <dc:date>2023-10-10T15:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: Attributes not included in HitTestResult</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/attributes-not-included-in-hittestresult/m-p/1340308#M82531</link>
      <description>&lt;P&gt;Thanks, it really worked for me. Only ObjectID was shown to me&lt;/P&gt;</description>
      <pubDate>Sun, 22 Oct 2023 14:01:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/attributes-not-included-in-hittestresult/m-p/1340308#M82531</guid>
      <dc:creator>LorenzoMara</dc:creator>
      <dc:date>2023-10-22T14:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: Attributes not included in HitTestResult</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/attributes-not-included-in-hittestresult/m-p/1574185#M86357</link>
      <description>&lt;P&gt;Thanks I had same problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;hitTest result only out put object id field, missing all other additional fields.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My feature layer is created from client side array of graphic as source.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If your feature layer created by using URL ( server-side source ) you don't have this kind of issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;OutFields by default will be "*",&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I solve my problem is by adding&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;outFields&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;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;or&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;backgroundFeatureLayer.outFields = ["*"];&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hp_31.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/123072iC304F4ED5EEB7263/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hp_31.png" alt="hp_31.png" /&gt;&lt;/span&gt;&lt;P&gt; &lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 22:04:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/attributes-not-included-in-hittestresult/m-p/1574185#M86357</guid>
      <dc:creator>hoogw</dc:creator>
      <dc:date>2025-01-09T22:04:34Z</dc:date>
    </item>
  </channel>
</rss>

