<?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 I query or make selections against a local FeatureLayer based on a featureCollection? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-query-or-make-selections-against-a-local/m-p/98162#M8987</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When FeatureLayers are constructed with a url we can use the .queryFeatures() or selectFeatures() methods to get subsets of the data from the server. How do I get subsets of the data when my FeatureLayer is local (i.e. constructed from a featureCollectionObject)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My app (JS API 3.10) has a toggle to switch between points (feature layer) and heatmap (from Patrick Weid's heatmap.js). My data is time aware and my feature layer is connected to the time slider, and it works fine. I want to time-enable my heatmap as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The solution I've implemented looks like this:&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1413579101923766 jive_text_macro" jivemacro_uid="_1413579101923766"&gt;
&lt;P&gt;on(timeSlider, "time-extent-change", function(){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var visibleGraphics = [];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arrayUtils.forEach(featureLayer.graphics, function(graphic){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (graphic.visible == true){&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; visibleGraphics.push(graphic);&lt;/P&gt;
&lt;P&gt;&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; });&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; heatLayer.setData(visibleGraphics);&lt;/P&gt;
&lt;P&gt;});&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;It works fine as long as the feature layer is limited to a few hundred graphics. When I get more than that this looping method is too slow. Instead of looping through every single graphic in the feature layer I'd rather be able to simply use the TimeExtent like I would with the Query object's query.timeExtent.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to do something like:&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1413579847678679 jive_text_macro" jivemacro_uid="_1413579847678679"&gt;
&lt;P&gt;on(timeSlider, "time-extent-change", function(evt){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var query = new Query();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query.timeExtent = evt.timeExtent;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; featureLayer.queryFeatures(query, function(featureSet){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; heatLayer.setData(featureSet);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;});&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course queryFeatures only works for retrieving data from the server, not for getting subsets of local data. My assumption is that this would be a lot faster than looping to find which graphics are visible. Any ideas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Oct 2014 18:07:51 GMT</pubDate>
    <dc:creator>RyanClancy</dc:creator>
    <dc:date>2014-10-21T18:07:51Z</dc:date>
    <item>
      <title>How do I query or make selections against a local FeatureLayer based on a featureCollection?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-query-or-make-selections-against-a-local/m-p/98162#M8987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When FeatureLayers are constructed with a url we can use the .queryFeatures() or selectFeatures() methods to get subsets of the data from the server. How do I get subsets of the data when my FeatureLayer is local (i.e. constructed from a featureCollectionObject)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My app (JS API 3.10) has a toggle to switch between points (feature layer) and heatmap (from Patrick Weid's heatmap.js). My data is time aware and my feature layer is connected to the time slider, and it works fine. I want to time-enable my heatmap as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The solution I've implemented looks like this:&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1413579101923766 jive_text_macro" jivemacro_uid="_1413579101923766"&gt;
&lt;P&gt;on(timeSlider, "time-extent-change", function(){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var visibleGraphics = [];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arrayUtils.forEach(featureLayer.graphics, function(graphic){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (graphic.visible == true){&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; visibleGraphics.push(graphic);&lt;/P&gt;
&lt;P&gt;&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; });&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; heatLayer.setData(visibleGraphics);&lt;/P&gt;
&lt;P&gt;});&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;It works fine as long as the feature layer is limited to a few hundred graphics. When I get more than that this looping method is too slow. Instead of looping through every single graphic in the feature layer I'd rather be able to simply use the TimeExtent like I would with the Query object's query.timeExtent.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to do something like:&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1413579847678679 jive_text_macro" jivemacro_uid="_1413579847678679"&gt;
&lt;P&gt;on(timeSlider, "time-extent-change", function(evt){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var query = new Query();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query.timeExtent = evt.timeExtent;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; featureLayer.queryFeatures(query, function(featureSet){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; heatLayer.setData(featureSet);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;});&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course queryFeatures only works for retrieving data from the server, not for getting subsets of local data. My assumption is that this would be a lot faster than looping to find which graphics are visible. Any ideas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Oct 2014 18:07:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-query-or-make-selections-against-a-local/m-p/98162#M8987</guid>
      <dc:creator>RyanClancy</dc:creator>
      <dc:date>2014-10-21T18:07:51Z</dc:date>
    </item>
  </channel>
</rss>

