<?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: How to store multiple featureLayer.queryFeatures results in  an array or object in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-store-multiple-featurelayer-queryfeatures/m-p/548310#M51029</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems to work if I make a new array by using splice and push that to my 'array of arrays' instead.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 04 Sep 2014 19:50:22 GMT</pubDate>
    <dc:creator>TracySchloss</dc:creator>
    <dc:date>2014-09-04T19:50:22Z</dc:date>
    <item>
      <title>How to store multiple featureLayer.queryFeatures results in  an array or object</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-store-multiple-featurelayer-queryfeatures/m-p/548309#M51028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a queryFeatures on a featureLayer that is based on mutiple objectIds. I need to iterate through each feature and store attributes in an array.&amp;nbsp; I need to keep each feature's array in another array (or maybe an object?) so I can have it as input to my chart. &lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14098482722531458 jive_text_macro" jivemacro_uid="_14098482722531458" modifiedtitle="true"&gt;
&lt;P&gt;gQuery = new Query();&lt;/P&gt;
&lt;P&gt;&amp;nbsp; gQuery.objectIds = idList;&amp;nbsp; //defined earlier&lt;/P&gt;
&lt;P&gt;seriesList.length = 0;&amp;nbsp; //declared earlier as seriesList = [];&lt;/P&gt;
&lt;P&gt; featureLayer.queryFeatures(gQuery, function(results) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arrayUtils.forEach(results.features, function (result){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var list = createRateList(result);&lt;/P&gt;
&lt;P&gt;console.log("list is " + list);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; seriesList.push({data: list});&lt;/P&gt;
&lt;P&gt;});&lt;/P&gt;
&lt;P&gt;});&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;function createRateList(results){&lt;/P&gt;
&lt;P&gt;&amp;nbsp; var atts = results.attributes;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; var county = atts.County;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; rateList.length = 0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; reverseRateFields.length = 0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; //gets the rate values for selected county for all years, list of field defined earlier&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arrayUtils.forEach(reverseRateFields, function (field){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rateList.push(atts[field]);&lt;/P&gt;
&lt;P&gt;&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; return rateList;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;At the point I have do a console.log on list, it contains the values I expect.&amp;nbsp; I add it to my seriesList and it still looked OK.&amp;nbsp;&amp;nbsp; Going to the next feature, I the console.log display what I expect from the list, but what I push to seriesList affects what's already in there.&amp;nbsp; Examining the contents of seriesList shows the initial item [0] with content I just added from the 2nd time through.&amp;nbsp; This continues through how ever many features I had from queryFeatures until I have a seriesList full of the exact same list of values, which are from the final feature.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know if I have a looping problem, or don't understand the nature of array variables. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2014 16:46:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-store-multiple-featurelayer-queryfeatures/m-p/548309#M51028</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2014-09-04T16:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to store multiple featureLayer.queryFeatures results in  an array or object</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-store-multiple-featurelayer-queryfeatures/m-p/548310#M51029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems to work if I make a new array by using splice and push that to my 'array of arrays' instead.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2014 19:50:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-store-multiple-featurelayer-queryfeatures/m-p/548310#M51029</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2014-09-04T19:50:22Z</dc:date>
    </item>
  </channel>
</rss>

