<?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 featurelayer properties from an array of feature layers javascript api in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-featurelayer-properties-from-an-array-of/m-p/421668#M38791</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good catch Owen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Mar 2015 18:27:29 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2015-03-03T18:27:29Z</dc:date>
    <item>
      <title>Accessing featurelayer properties from an array of feature layers javascript api</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-featurelayer-properties-from-an-array-of/m-p/421665#M38788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am adding my feature layers to an array and map as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.forEach(globals.layers, function (addit, i) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; globals.featureLayers&lt;I&gt; = new FeatureLayer(addit.url, {&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mode: addit.mode,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id: addit.id,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outFields: addit.outFields,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infoTemplate: addit.infoTemplate&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (addit.type == "poly") {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; globals.featureLayers&lt;I&gt;.setRenderer(renderer)&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.addLayer(globals.featureLayers&lt;I&gt;);&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works fine and the layers needed display in the browser.&amp;nbsp; However, when I try to access the graphics array within the feature layer by doing the below in the above forEach statement:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var graphicstmp = globals.featureLayers&lt;I&gt;.graphics;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log("Features Layer Properties in base ", graphicstmp)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get an empty array in graphicstmp.&amp;nbsp; If I look at the globals.featureLayers&lt;I&gt; array in dev tools I see the graphics object there and it is not empty.&amp;nbsp; It has the properties for the layer that are displaying.&amp;nbsp; So apparently I am doing something wrong with trying to access it this way globals.featureLayers&lt;I&gt;.graphics.&amp;nbsp; Help is appreciated.&amp;nbsp; I eventually want to modify some of the properties but I first need to be able to access them. &lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Feb 2015 14:54:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-featurelayer-properties-from-an-array-of/m-p/421665#M38788</guid>
      <dc:creator>DanRicketts</dc:creator>
      <dc:date>2015-02-25T14:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing featurelayer properties from an array of feature layers javascript api</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-featurelayer-properties-from-an-array-of/m-p/421666#M38789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've had this happen when the layer properties had not loaded before I tried to access them. Could you listen for the 'layers-add-result' event on your map, and after that try to go through the array and access your layers? Or maybe wait for:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;on(&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;globals.featureLayers&lt;I&gt;, 'load', function() {&lt;/I&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log(&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 12px;"&gt;globals.featureLayers&lt;I&gt;.graphics);&lt;/I&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;});&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:02:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-featurelayer-properties-from-an-array-of/m-p/421666#M38789</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T19:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing featurelayer properties from an array of feature layers javascript api</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-featurelayer-properties-from-an-array-of/m-p/421667#M38790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think &lt;A href="https://community.esri.com/migrated-users/41473"&gt;Sarah Clark&lt;/A&gt;​ is correct that you are probably attempting to access the graphics before they have been loaded. However, I would use the update-end event instead of the load event. The load event fires when the layer properties are populated, the update-end event should fire when all graphics have finished loading.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/jsapi/featurelayer-amd.html#event-load"&gt;load event&lt;/A&gt;:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN style="color: #000066; font-family: 'Lucida Grande', 'Segoe UI', Arial, sans-serif; background-color: #fafafa;"&gt;Fires after layer properties for the layer are successfully populated.&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/jsapi/featurelayer-amd.html#event-update-end"&gt;update-end event&lt;/A&gt;:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN style="color: #000066; font-family: 'Lucida Grande', 'Segoe UI', Arial, sans-serif; background-color: #fafafa;"&gt;Fired when the layer has finished updating its content.&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you are only interested in listening to this event the first time the feature layer loads look into &lt;A href="http://livedocs.dojotoolkit.org/dojo/on#once"&gt;on.once()&lt;/A&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Mar 2015 02:37:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-featurelayer-properties-from-an-array-of/m-p/421667#M38790</guid>
      <dc:creator>OwenEarley</dc:creator>
      <dc:date>2015-03-03T02:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing featurelayer properties from an array of feature layers javascript api</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-featurelayer-properties-from-an-array-of/m-p/421668#M38791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good catch Owen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Mar 2015 18:27:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-featurelayer-properties-from-an-array-of/m-p/421668#M38791</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2015-03-03T18:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing featurelayer properties from an array of feature layers javascript api</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-featurelayer-properties-from-an-array-of/m-p/421669#M38792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/41473"&gt;Sarah Clark&lt;/A&gt;​ Thanks for the information.&amp;nbsp; I considered it wasn't loaded but I could access other properties so I thought that wasn't it.&amp;nbsp; This definitely pointed me in the right direction. Owen is correct in I had to wait for the update-end event.&amp;nbsp; The load triggered too soon and was still an empty array. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Mar 2015 18:29:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-featurelayer-properties-from-an-array-of/m-p/421669#M38792</guid>
      <dc:creator>DanRicketts</dc:creator>
      <dc:date>2015-03-03T18:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing featurelayer properties from an array of feature layers javascript api</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-featurelayer-properties-from-an-array-of/m-p/421670#M38793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Owen, the update-end event was the key.&amp;nbsp; Just curious why if I accessed globals.featureLayers&lt;I&gt; in the console without the .graphics I could access the graphics array fine.&amp;nbsp; It was only when I went directly to the globals.featureLayers&lt;I&gt;.graphics that it would return an empty array, until I did update-end. &lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Mar 2015 18:42:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-featurelayer-properties-from-an-array-of/m-p/421670#M38793</guid>
      <dc:creator>DanRicketts</dc:creator>
      <dc:date>2015-03-03T18:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing featurelayer properties from an array of feature layers javascript api</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-featurelayer-properties-from-an-array-of/m-p/421671#M38794</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan, there is surely better phrasing for this, but I have found that when I print an entire object to the Chrome dev tools console that it retroactively fills itself when the object fully loads. I think this is because it is a reference to the object, so any changes to it get updated in the console at any point in time. It's gotten me into a lot of trouble debugging. I always print the object.key value now, not the whole object, because otherwise if I go back in time to see if something loaded and I use the whole object, the order of events may be wrong. Basically trying to say that once the graphics loaded, the object in Chrome was updated but the object.key was not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This in fact was how I got to assuming you were racing loading times.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Mar 2015 18:51:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-featurelayer-properties-from-an-array-of/m-p/421671#M38794</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2015-03-03T18:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing featurelayer properties from an array of feature layers javascript api</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-featurelayer-properties-from-an-array-of/m-p/421672#M38795</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Interesting pick-up Sarah. I haven't noticed Chrome backfilling objects in the console before. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did a quick test (make sure to open the developer tools console and hit F5) and found that if you do not immediately expand the object node to view its properties then the object is updated retroactively by Chrome:&lt;A href="http://jsbin.com/hakuyuhevi/3"&gt;http://jsbin.com/hakuyuhevi/3&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="expandObjectAfterTimeout.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/68124_expandObjectAfterTimeout.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;Also, note that the information in line 1 shows &lt;EM&gt;list2: Array[0]&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, if you expand the object node before the code has populated the array, list2 shows as empty:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="expandObjectBeforeTimeout.png" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/68125_expandObjectBeforeTimeout.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;This is definitely something to be aware of in debugging.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Mar 2015 21:54:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/accessing-featurelayer-properties-from-an-array-of/m-p/421672#M38795</guid>
      <dc:creator>OwenEarley</dc:creator>
      <dc:date>2015-03-03T21:54:11Z</dc:date>
    </item>
  </channel>
</rss>

