<?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: Feature Layer with Time Slider - Fade in individual features with 4.17 in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/feature-layer-with-time-slider-fade-in-individual/m-p/1005688#M70949</link>
    <description>&lt;P&gt;After some digging, I figured out a way to make this happen.&amp;nbsp; Its not perfect, but I saw a few similar questions that had gone unanswered, so I figured I'd post it here for any future passers-by.&lt;/P&gt;&lt;P&gt;Getting each individual feature can be done by calling &lt;FONT face="courier new,courier" color="#0000FF"&gt;layer.queryFeatures()&lt;/FONT&gt; on the layer.&amp;nbsp; This returns a&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html" target="_self"&gt;FeatureSet&lt;/A&gt;&amp;nbsp;, which is essentially a collection of&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html" target="_self"&gt;Graphics&lt;/A&gt;&amp;nbsp;.&amp;nbsp; There is no way to control the opacity of a Graphic.&amp;nbsp; However, you can create an array of new layers from the FeatureSet, each with a singular graphic representing one point:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  let layerView;
  let flFromResults;
  view.whenLayerView(torchRelay).then((lv) =&amp;gt; {
    torchRelay.queryFeatures().then(function (results) {
      // create a new feature layer for each feature in the original layer
      flFromResults = results.features.map((feature) =&amp;gt; {
        const layer = new FeatureLayer({
          objectIdField: "OBJECTID",
          source: [feature],
          fields: results.fields,
          popupTemplate: feature.popupTemplate,
          renderer
        });

        // listen for layer to be created, then call animation function
        layer.on("layerview-create", () =&amp;gt; {
          fadeVisibilityOn(layer);
        });

        return {
          time: feature.attributes.Time,
          onmap: false,
          shouldBeAdded: false,
          layer
        };
      });

    });

    layerView = lv;
    layerView.filter = {
      where: `Time &amp;lt;= 'nope'`
    };

  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;timeSlider.watch("timeExtent", function (value) {
    const dateString = value.end.getTime();

    flFromResults &amp;amp;&amp;amp; flFromResults.forEach((p) =&amp;gt; {
      if (p.time &amp;lt;= dateString) {
        p.shouldBeAdded = true;
      } else {
        p.shouldBeAdded = false;
      }

      if (!p.onmap &amp;amp;&amp;amp; p.shouldBeAdded) {
        map.add(p.layer);
        p.onmap = true;
      }

      if (p.onmap &amp;amp;&amp;amp; !p.shouldBeAdded) {
        map.remove(p.layer);
        p.onmap = false;
      }
    });

  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These if else statements will check the date of the timeslider against the date of each layer, and add and remove layers accordingly.&amp;nbsp; And voila, a fade in effect:&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;A href="https://codepen.io/slutske22/pen/qBadRYK?editors=1010" target="_blank" rel="noopener"&gt;Working codepen&lt;/A&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;The codepen has a bit of a wierd flash effect going on, but that is not occuring on my local machine.&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;This method is probably not optimal, as it requires the creation of a new layer for every feature, but I can't find a way to set opacity on individual features.&amp;nbsp; Perhaps using a &lt;FONT face="courier new,courier" color="#0000FF"&gt;new GraphicsLayer&lt;/FONT&gt; instead of &lt;FONT face="courier new,courier" color="#0000FF"&gt;new FeatureLayer&lt;/FONT&gt; would be more optimal.&amp;nbsp; But it does work.&amp;nbsp; Hopefully this helps someone else in the future.&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Nov 2020 22:31:00 GMT</pubDate>
    <dc:creator>SethLutske</dc:creator>
    <dc:date>2020-11-30T22:31:00Z</dc:date>
    <item>
      <title>Feature Layer with Time Slider - Fade in individual features with 4.17</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/feature-layer-with-time-slider-fade-in-individual/m-p/1005247#M70927</link>
      <description>&lt;P&gt;I have a feature of layer of points which is time enabled. I also have a time slider, with some code that runs a filter on the layer to only show points that are within the time slider range.&amp;nbsp; The time slider uses &lt;FONT face="courier new,courier"&gt;cumulative-from-start&lt;/FONT&gt;.&amp;nbsp; The feature layer is using a picture-marker renderer with a firefly image:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const renderer = {
        symbol: {
          angle: 0,
          contentType: 'image/png',
          height: 18.75,
          width: 18.75,
          type: 'picture-marker',
          url: 'https://static.arcgis.com/images/Symbols/Firefly/FireflyC20.png',
          xoffset: 0,
          yoffset: 0,
        },
        type: 'simple',
      };&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's what my filter looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;timeSlider.watch('timeExtent', function(value) {
  const dateString = value.end.getTime();
  layerView.filter = {
    where: `Time &amp;lt;= '${dateString}'`,
  };
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Here's a &lt;A href="https://codepen.io/slutske22/pen/KKgKjrv?editors=1000" target="_self"&gt;codepen&lt;/A&gt; showing what I'm working with. Its all working nicely.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I would like to do is implement a fade in effect, such that as each point is included in the filter, it fades in, rather than just appears.&amp;nbsp; I know this has been done, as this code is basically an attempt to recreate&amp;nbsp;&lt;A href="https://notredamecobham.maps.arcgis.com/apps/TimeAware/index.html?appid=b8b328c72ce643f7a4a9ccb352713e44" target="_self"&gt;this application.&lt;/A&gt;&amp;nbsp;That app seems to be using version 3 of the arcgis api.&amp;nbsp; What's nice about that is that the markers are rendered as actual &amp;lt;img /&amp;gt; elements, so the css classes can be harnessed to create a very nice fade in effect.&amp;nbsp; However, with v4 of the API, I don't see a way to have such simple access to the elements as they're drawn into the canvas of the map.&lt;/P&gt;&lt;P&gt;How can I apply a fade-in effect to the points as the timeslider includes them in the layer's filter?&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2020 20:03:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/feature-layer-with-time-slider-fade-in-individual/m-p/1005247#M70927</guid>
      <dc:creator>SethLutske</dc:creator>
      <dc:date>2020-11-27T20:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: Feature Layer with Time Slider - Fade in individual features with 4.17</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/feature-layer-with-time-slider-fade-in-individual/m-p/1005688#M70949</link>
      <description>&lt;P&gt;After some digging, I figured out a way to make this happen.&amp;nbsp; Its not perfect, but I saw a few similar questions that had gone unanswered, so I figured I'd post it here for any future passers-by.&lt;/P&gt;&lt;P&gt;Getting each individual feature can be done by calling &lt;FONT face="courier new,courier" color="#0000FF"&gt;layer.queryFeatures()&lt;/FONT&gt; on the layer.&amp;nbsp; This returns a&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html" target="_self"&gt;FeatureSet&lt;/A&gt;&amp;nbsp;, which is essentially a collection of&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html" target="_self"&gt;Graphics&lt;/A&gt;&amp;nbsp;.&amp;nbsp; There is no way to control the opacity of a Graphic.&amp;nbsp; However, you can create an array of new layers from the FeatureSet, each with a singular graphic representing one point:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  let layerView;
  let flFromResults;
  view.whenLayerView(torchRelay).then((lv) =&amp;gt; {
    torchRelay.queryFeatures().then(function (results) {
      // create a new feature layer for each feature in the original layer
      flFromResults = results.features.map((feature) =&amp;gt; {
        const layer = new FeatureLayer({
          objectIdField: "OBJECTID",
          source: [feature],
          fields: results.fields,
          popupTemplate: feature.popupTemplate,
          renderer
        });

        // listen for layer to be created, then call animation function
        layer.on("layerview-create", () =&amp;gt; {
          fadeVisibilityOn(layer);
        });

        return {
          time: feature.attributes.Time,
          onmap: false,
          shouldBeAdded: false,
          layer
        };
      });

    });

    layerView = lv;
    layerView.filter = {
      where: `Time &amp;lt;= 'nope'`
    };

  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;timeSlider.watch("timeExtent", function (value) {
    const dateString = value.end.getTime();

    flFromResults &amp;amp;&amp;amp; flFromResults.forEach((p) =&amp;gt; {
      if (p.time &amp;lt;= dateString) {
        p.shouldBeAdded = true;
      } else {
        p.shouldBeAdded = false;
      }

      if (!p.onmap &amp;amp;&amp;amp; p.shouldBeAdded) {
        map.add(p.layer);
        p.onmap = true;
      }

      if (p.onmap &amp;amp;&amp;amp; !p.shouldBeAdded) {
        map.remove(p.layer);
        p.onmap = false;
      }
    });

  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These if else statements will check the date of the timeslider against the date of each layer, and add and remove layers accordingly.&amp;nbsp; And voila, a fade in effect:&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;A href="https://codepen.io/slutske22/pen/qBadRYK?editors=1010" target="_blank" rel="noopener"&gt;Working codepen&lt;/A&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;The codepen has a bit of a wierd flash effect going on, but that is not occuring on my local machine.&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;This method is probably not optimal, as it requires the creation of a new layer for every feature, but I can't find a way to set opacity on individual features.&amp;nbsp; Perhaps using a &lt;FONT face="courier new,courier" color="#0000FF"&gt;new GraphicsLayer&lt;/FONT&gt; instead of &lt;FONT face="courier new,courier" color="#0000FF"&gt;new FeatureLayer&lt;/FONT&gt; would be more optimal.&amp;nbsp; But it does work.&amp;nbsp; Hopefully this helps someone else in the future.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 22:31:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/feature-layer-with-time-slider-fade-in-individual/m-p/1005688#M70949</guid>
      <dc:creator>SethLutske</dc:creator>
      <dc:date>2020-11-30T22:31:00Z</dc:date>
    </item>
  </channel>
</rss>

