<?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 How do to know when a featureLayer has loaded the features? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-to-know-when-a-featurelayer-has-loaded-the/m-p/643920#M60070</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When I create a new FeatureLayer, I need to know when it has loaded the features into the layer.&amp;nbsp; Using the onLoad event doesn't get it because that only tells me when&amp;nbsp; "layer properties for the layer are successfully populated."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Watching the console. I can see that all of my JavaScript code immediately after creating the featureLayer is executed before the response from the map service comes back.&amp;nbsp; Therefore, if I use the featureLayer.on("load", function(){}) event, and tell it to count the number of features, it returns zero.&amp;nbsp;&amp;nbsp; If I execute the same count a few seconds later, it returns the expected number of features.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Consolas;"&gt;MyFeatureLayer = new&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt; esri.layers.FeatureLayer(mapServiceURL, {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;id: &lt;/SPAN&gt;&lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Consolas;"&gt;"MyFeatureLayer"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;outFields: [&lt;/SPAN&gt;&lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Consolas;"&gt;"*"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;});&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Consolas;"&gt;MyFeatureLayer.on("load", function(){&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log("MyFeatureLayer loaded with: " + MyFeatureLayer.graphics.length + " features");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;})&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;console: MyFeatureLayer loaded with 0 features&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 24 Jul 2014 00:15:05 GMT</pubDate>
    <dc:creator>MichaelJenkins</dc:creator>
    <dc:date>2014-07-24T00:15:05Z</dc:date>
    <item>
      <title>How do to know when a featureLayer has loaded the features?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-to-know-when-a-featurelayer-has-loaded-the/m-p/643920#M60070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When I create a new FeatureLayer, I need to know when it has loaded the features into the layer.&amp;nbsp; Using the onLoad event doesn't get it because that only tells me when&amp;nbsp; "layer properties for the layer are successfully populated."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Watching the console. I can see that all of my JavaScript code immediately after creating the featureLayer is executed before the response from the map service comes back.&amp;nbsp; Therefore, if I use the featureLayer.on("load", function(){}) event, and tell it to count the number of features, it returns zero.&amp;nbsp;&amp;nbsp; If I execute the same count a few seconds later, it returns the expected number of features.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Consolas;"&gt;MyFeatureLayer = new&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt; esri.layers.FeatureLayer(mapServiceURL, {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;id: &lt;/SPAN&gt;&lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Consolas;"&gt;"MyFeatureLayer"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;outFields: [&lt;/SPAN&gt;&lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Consolas;"&gt;"*"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;});&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Consolas;"&gt;MyFeatureLayer.on("load", function(){&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log("MyFeatureLayer loaded with: " + MyFeatureLayer.graphics.length + " features");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;})&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;console: MyFeatureLayer loaded with 0 features&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 00:15:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-to-know-when-a-featurelayer-has-loaded-the/m-p/643920#M60070</guid>
      <dc:creator>MichaelJenkins</dc:creator>
      <dc:date>2014-07-24T00:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do to know when a featureLayer has loaded the features?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-to-know-when-a-featurelayer-has-loaded-the/m-p/643921#M60071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Michael,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check out the &lt;A href="https://developers.arcgis.com/javascript/jsapi/featurelayer-amd.html#event-update-end"&gt;update-end event&lt;/A&gt; for feature layers. I have created a &lt;A href="http://jsbin.com/qepukaxa/1"&gt;quick demo here&lt;/A&gt; to show this in action (make sure to open a console window).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the results in the console window:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="2521" alt="example.png" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/2521_example.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 03:08:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-to-know-when-a-featurelayer-has-loaded-the/m-p/643921#M60071</guid>
      <dc:creator>OwenEarley</dc:creator>
      <dc:date>2014-07-24T03:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do to know when a featureLayer has loaded the features?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-to-know-when-a-featurelayer-has-loaded-the/m-p/643922#M60072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's it!&amp;nbsp; I had also tried using the "update" event, but that fires every time you pan and zoom the map.&amp;nbsp; "update-end" seems to only fire the one time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks very much!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 16:11:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-to-know-when-a-featurelayer-has-loaded-the/m-p/643922#M60072</guid>
      <dc:creator>MichaelJenkins</dc:creator>
      <dc:date>2014-07-24T16:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do to know when a featureLayer has loaded the features?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-to-know-when-a-featurelayer-has-loaded-the/m-p/643923#M60073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Michael,&lt;/P&gt;&lt;P&gt;The update-end will fire with each pan/zoom if you are using FeatureLayer.MODE_ONDEMAND, but only once if you're using FeatureLayer.MODE_SNAPSHOT.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 23:20:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-to-know-when-a-featurelayer-has-loaded-the/m-p/643923#M60073</guid>
      <dc:creator>BjornSvensson</dc:creator>
      <dc:date>2014-07-24T23:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do to know when a featureLayer has loaded the features?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-to-know-when-a-featurelayer-has-loaded-the/m-p/643924#M60074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is correct.&amp;nbsp;&amp;nbsp; I my case I am using SNAPSHOT mode so it only fires once, unless I have a refresh interval set, in which case it also gets fired after each refresh.&amp;nbsp;&amp;nbsp; I tried it with 30 minutes initially.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jul 2014 22:34:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-to-know-when-a-featurelayer-has-loaded-the/m-p/643924#M60074</guid>
      <dc:creator>MichaelJenkins</dc:creator>
      <dc:date>2014-07-29T22:34:26Z</dc:date>
    </item>
  </channel>
</rss>

