<?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 Graphics from featureLayer - do I need to do a selection to get them? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-from-featurelayer-do-i-need-to-do-a/m-p/695140#M64671</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a featureLayer loaded as &lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; app.bufferLayer = new FeatureLayer(config.pathName + "/arcgis/rest/services/DPS/VetComm_bufferAnalysis/FeatureServer/0" ,{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id:"bufferLayer",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outFields:['*']
&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;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also have an onDemandGrid that shows the attributes for this layer.&amp;nbsp; When I first load the layer, I'd like to be able to populate the grid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on(app.bufferLayer, 'load', function(){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myGrid.populateGrid();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//function in myGrid&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; populateGrid: function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var graphics = app.bufferLayer.graphics;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var gAttributes = arrayUtils.map(graphics, function(g){&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; return g.attributes;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; var currentMemory = new Memory ({data:gAttributes, idProperty:'id'}); 
&lt;SPAN style="line-height: 1.5;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app.totalsGrid.set('store', currentMemory);&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm confused about featureLayer.graphics, which is documented as as an array of graphics from the featureLayer.&amp;nbsp; When the load event executes for the bufferLayer, app.bufferLayer.graphics is an array with the length of 0. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I add&amp;nbsp; graphics to this layer, I can execute this same function again, and this time, instead of the array length being 0, it now has all the previous graphics that were in bufferLayer, along with the new feature I added.&amp;nbsp; The grid gets populated with everything.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on (app.bufferLayer, 'edits-complete', function (adds,updates,deletes){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myGrid.populateGrid();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can run a query against the bufferLayer once it's loaded and use the results to populate my grid initially, but it seems like extras steps, since from the documentation is sounds like I can get all the graphics from the layer without doing all that.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 05:15:47 GMT</pubDate>
    <dc:creator>TracySchloss</dc:creator>
    <dc:date>2021-12-12T05:15:47Z</dc:date>
    <item>
      <title>Graphics from featureLayer - do I need to do a selection to get them?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-from-featurelayer-do-i-need-to-do-a/m-p/695140#M64671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a featureLayer loaded as &lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; app.bufferLayer = new FeatureLayer(config.pathName + "/arcgis/rest/services/DPS/VetComm_bufferAnalysis/FeatureServer/0" ,{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id:"bufferLayer",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outFields:['*']
&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;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also have an onDemandGrid that shows the attributes for this layer.&amp;nbsp; When I first load the layer, I'd like to be able to populate the grid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on(app.bufferLayer, 'load', function(){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myGrid.populateGrid();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//function in myGrid&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; populateGrid: function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var graphics = app.bufferLayer.graphics;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var gAttributes = arrayUtils.map(graphics, function(g){&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; return g.attributes;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; var currentMemory = new Memory ({data:gAttributes, idProperty:'id'}); 
&lt;SPAN style="line-height: 1.5;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app.totalsGrid.set('store', currentMemory);&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm confused about featureLayer.graphics, which is documented as as an array of graphics from the featureLayer.&amp;nbsp; When the load event executes for the bufferLayer, app.bufferLayer.graphics is an array with the length of 0. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I add&amp;nbsp; graphics to this layer, I can execute this same function again, and this time, instead of the array length being 0, it now has all the previous graphics that were in bufferLayer, along with the new feature I added.&amp;nbsp; The grid gets populated with everything.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on (app.bufferLayer, 'edits-complete', function (adds,updates,deletes){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myGrid.populateGrid();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can run a query against the bufferLayer once it's loaded and use the results to populate my grid initially, but it seems like extras steps, since from the documentation is sounds like I can get all the graphics from the layer without doing all that.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:15:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-from-featurelayer-do-i-need-to-do-a/m-p/695140#M64671</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2021-12-12T05:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Graphics from featureLayer - do I need to do a selection to get them?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-from-featurelayer-do-i-need-to-do-a/m-p/695141#M64672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Instead of using the load event, use the update-end event. I'm guessing you'll want to make that a one time only event.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Take a look at this &lt;A href="http://jsbin.com/viboboziji/edit?html,console,output"&gt;sample&lt;/A&gt; that shows the difference between the graphic count for the two events.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Sep 2015 14:56:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-from-featurelayer-do-i-need-to-do-a/m-p/695141#M64672</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2015-09-24T14:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: Graphics from featureLayer - do I need to do a selection to get them?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-from-featurelayer-do-i-need-to-do-a/m-p/695142#M64673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That did it for populating my grid, but it is now executes for every extent change. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Sep 2015 15:03:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-from-featurelayer-do-i-need-to-do-a/m-p/695142#M64673</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2015-09-24T15:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: Graphics from featureLayer - do I need to do a selection to get them?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-from-featurelayer-do-i-need-to-do-a/m-p/695143#M64674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The sample was updated to take that into account.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;on.once(featureLayer, "update-end", function(){
&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log("update-end: " + featureLayer.graphics.length);
});&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:15:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-from-featurelayer-do-i-need-to-do-a/m-p/695143#M64674</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-12-12T05:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: Graphics from featureLayer - do I need to do a selection to get them?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-from-featurelayer-do-i-need-to-do-a/m-p/695144#M64675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I forgot about on.once.&amp;nbsp; I only needed it one other time.&amp;nbsp; That fixed it, thanks. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Sep 2015 15:13:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-from-featurelayer-do-i-need-to-do-a/m-p/695144#M64675</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2015-09-24T15:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: Graphics from featureLayer - do I need to do a selection to get them?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-from-featurelayer-do-i-need-to-do-a/m-p/695145#M64676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On studying this some more, there's still something not quite right about this.&amp;nbsp; My grid populates, but as I add additional features to my featureLayer using applyEdits, sometimes not all the graphics are discovered.&amp;nbsp; It seems to happen when I zoomed in and I've added a new graphic to the featureLayer.&amp;nbsp; When I run the populateGrid function once I've edited to add a new graphic, instead of all the graphics, it only appears to be picking up the graphics that are at least partially in the current extent.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on (app.bufferLayer, 'edits-complete', function (adds,updates,deletes){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myGrid.populateGrid();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/PRE&gt;&lt;P&gt;the function in myGrid:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; populateGrid: function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var graphics = app.bufferLayer.graphics;// graphics are not always found if zoomed in
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (app.demographicLayer){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app.demographicLayer.clearSelection();
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; app.cityNameList.length = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; var gAttributes = arrayUtils.map(graphics, function(g){&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return g.attributes;
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; arrayUtils.forEach(graphics, function (g){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app.cityNameList.push(g.attributes.CITY);
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var currentMemory = new Memory ({data:gAttributes, idProperty:'OBJECTID'});
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app.totalsGrid.set('store', currentMemory);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't have anything programmatically limiting my graphics to only those in the map extent.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I reload the page, the grid populates correctly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:15:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-from-featurelayer-do-i-need-to-do-a/m-p/695145#M64676</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2021-12-12T05:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Graphics from featureLayer - do I need to do a selection to get them?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-from-featurelayer-do-i-need-to-do-a/m-p/695146#M64677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Update:&amp;nbsp; I have changed the mode of my FeatureLayer to MODE_SNAPSHOT from the default AUTO, and that seems to make a difference.&amp;nbsp; In the discussion&amp;nbsp; &lt;A href="https://developers.arcgis.com/javascript/jshelp/best_practices_feature_layers.html" title="https://developers.arcgis.com/javascript/jshelp/best_practices_feature_layers.html"&gt;Feature Layer Best Practices | Guide | ArcGIS API for JavaScript&lt;/A&gt;&amp;nbsp;&amp;nbsp; it does mention that one benefit of Vector Tiling is that &lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Only features that intersect the map's current extent are retrieved&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I wonder if that's what is going on in this situation?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Sep 2015 18:50:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-from-featurelayer-do-i-need-to-do-a/m-p/695146#M64677</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2015-09-28T18:50:24Z</dc:date>
    </item>
  </channel>
</rss>

