<?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: Accessing graphic attributes on a featurelayer in 4.xx API for label when using a collection in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-graphic-attributes-on-a-featurelayer-in/m-p/1047263#M72542</link>
    <description>&lt;P&gt;Hi Undral,&lt;/P&gt;&lt;P&gt;This is brilliant!&amp;nbsp; This also solves my popup content issues.&amp;nbsp; Thanks so much for the quick response.&amp;nbsp; I really appreciate it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Grant&lt;/P&gt;</description>
    <pubDate>Wed, 14 Apr 2021 20:03:44 GMT</pubDate>
    <dc:creator>GrantElliott</dc:creator>
    <dc:date>2021-04-14T20:03:44Z</dc:date>
    <item>
      <title>Accessing graphic attributes on a featurelayer in 4.xx API for label when using a collection</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-graphic-attributes-on-a-featurelayer-in/m-p/1047197#M72534</link>
      <description>&lt;P&gt;I have a simple map that loads points as Graphics onto a FeatureLayer using a source collection.&amp;nbsp; I want to access the attributes of the graphics to use in the popup and point label but I just can't get it to work.&lt;/P&gt;&lt;P&gt;In the code snip below, I populate the collection (esri/core/Collection), define a labelClass and add the layer to a map.&amp;nbsp; The sourceSymbol is a PictureMarkerSymbol.&amp;nbsp; You can see that each point in the collection has 3 attributes.&amp;nbsp; I set the DESCRIPTION attribute as static text: "DESCRIPTION" so as to ensure that it has a value.&lt;/P&gt;&lt;P&gt;What I see is that the label properly contains the ObjectID, but the NAME and DESCRIPTION are not populated in the label expression.&lt;/P&gt;&lt;P&gt;Here's the code.&amp;nbsp; I'd really appreciate it if someone could point out my mistake.&amp;nbsp; Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var collection = new Collection();&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;for (var i = 0; i &amp;lt; features.length; i++) {&lt;BR /&gt;var data = features[i];&lt;/P&gt;&lt;P&gt;if (data.Type == "Feature") {&lt;BR /&gt;featureGeometry = data.Geometry&lt;BR /&gt;featureProperties = data.Properties&lt;BR /&gt;if (featureGeometry.Type == "Point") {&lt;BR /&gt;const point = {}&lt;BR /&gt;point.type = "point";&lt;BR /&gt;point.longitude = featureGeometry.Coordinates.Longitude;&lt;BR /&gt;point.latitude = featureGeometry.Coordinates.Latitude;&lt;/P&gt;&lt;P&gt;var pointGraphic = new Graphic({&lt;BR /&gt;geometry: point,&lt;BR /&gt;symbol: ticketSymbol,&lt;BR /&gt;attributes: {&lt;BR /&gt;ObjectID: i,&lt;BR /&gt;NAME: featureProperties.Name,&lt;BR /&gt;DESCRIPTION: "LABEL DESCRIPTION"&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;collection.add(pointGraphic);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;const labelClass = {&lt;BR /&gt;// autocasts as new LabelClass()&lt;BR /&gt;symbol: {&lt;BR /&gt;type: "text",&lt;BR /&gt;color: "green",&lt;BR /&gt;font: {&lt;BR /&gt;family: "Arial Unicode MS",&lt;BR /&gt;size: 12,&lt;BR /&gt;weight: "bold"&lt;BR /&gt;}&lt;BR /&gt;},&lt;BR /&gt;labelPlacement: "above-center",&lt;BR /&gt;labelExpressionInfo: {&lt;BR /&gt;expression: "'ID:' + $feature.ObjectID + ' Name: ' + $feature.NAME + ' - ' + $feature.DESCRIPTION "&lt;BR /&gt;}&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;sourceLayer = new FeatureLayer({&lt;BR /&gt;title: "Sources",&lt;BR /&gt;outfields: ["*"],&lt;BR /&gt;source: collection,&lt;BR /&gt;objectIdField: "ObjectID",&lt;BR /&gt;labelingInfo: [labelClass],&lt;BR /&gt;&lt;BR /&gt;renderer: { type: "simple", symbol: sourceSymbol }&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;map.layers.add(sourceLayer);&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GrantElliott_0-1618426383542.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/10913iA402A2D202F720BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GrantElliott_0-1618426383542.png" alt="GrantElliott_0-1618426383542.png" /&gt;&lt;/span&gt;&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;&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 18:54:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-graphic-attributes-on-a-featurelayer-in/m-p/1047197#M72534</guid>
      <dc:creator>GrantElliott</dc:creator>
      <dc:date>2021-04-14T18:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing graphic attributes on a featurelayer in 4.xx API for label when using a collection</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-graphic-attributes-on-a-featurelayer-in/m-p/1047228#M72537</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looks like you are not setting fields schema for your feature collection. It should work as expected once you define the fields for the layer. &amp;nbsp;So do something like the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;sourceLayer = new FeatureLayer({
  title: "Sources",
  outfields: ["*"],
  source: collection,
  objectIdField: "ObjectID",
  labelingInfo: [labelClass],
  renderer: { type: "simple", symbol: sourceSymbol },
  fields: [{
    name: "ObjectID",
    alias: "ObjectID",
    type: "oid"
  },
  {
    name: "NAME",
    alias: "Name",
    type: "string"
   },
   {
      name: "DESCRIPTION",
      alias: "Type Description,
      type: "string"
   }]
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this works,&lt;/P&gt;&lt;P&gt;-Undral&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 19:29:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-graphic-attributes-on-a-featurelayer-in/m-p/1047228#M72537</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2021-04-14T19:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing graphic attributes on a featurelayer in 4.xx API for label when using a collection</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-graphic-attributes-on-a-featurelayer-in/m-p/1047263#M72542</link>
      <description>&lt;P&gt;Hi Undral,&lt;/P&gt;&lt;P&gt;This is brilliant!&amp;nbsp; This also solves my popup content issues.&amp;nbsp; Thanks so much for the quick response.&amp;nbsp; I really appreciate it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Grant&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 20:03:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-graphic-attributes-on-a-featurelayer-in/m-p/1047263#M72542</guid>
      <dc:creator>GrantElliott</dc:creator>
      <dc:date>2021-04-14T20:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing graphic attributes on a featurelayer in 4.xx API for label when using a collection</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-graphic-attributes-on-a-featurelayer-in/m-p/1050084#M72694</link>
      <description>&lt;P&gt;I was wondering if it is possible to use this code for Esri WEB app to generate feature labels for layers added to the map? I am struggling to add labels to my map in ESRI WAB:(&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 14:16:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-graphic-attributes-on-a-featurelayer-in/m-p/1050084#M72694</guid>
      <dc:creator>ErfanGoharian</dc:creator>
      <dc:date>2021-04-22T14:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing graphic attributes on a featurelayer in 4.xy API for label when using a collection</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-graphic-attributes-on-a-featurelayer-in/m-p/1574186#M86358</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:05:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-graphic-attributes-on-a-featurelayer-in/m-p/1574186#M86358</guid>
      <dc:creator>hoogw</dc:creator>
      <dc:date>2025-01-09T22:05:34Z</dc:date>
    </item>
  </channel>
</rss>

