<?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: TimeSlider - Get Irregular Stops from Field in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/timeslider-get-irregular-stops-from-field/m-p/1047885#M72574</link>
    <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://gist.github.com/onpubcom/1772996" target="_self"&gt;This approach&lt;/A&gt; appears to be working. I updated &lt;A href="https://codepen.io/U_B_U/pen/gOgeMpQ?editors=1000" target="_self"&gt;the test app&lt;/A&gt; to showcase this. The following is the gist of it.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt; var randomDates = [
  new Date(2021, 0, 11, 13, 52, 59, 452),
  new Date(2021, 0, 11, 13, 32, 58, 956),
  new Date(2021, 0, 12, 13, 55, 33, 216),
  new Date(2021, 0, 11, 14, 02, 56, 873),
  new Date(2021, 0, 11, 14, 22, 44, 315),
  new Date(2021, 0, 11, 14, 44,  21, 273),
  new Date(2021, 0, 11, 15, 02, 24, 093),
  new Date(2021, 0, 11, 17, 49, 56, 344),
  new Date(2021, 0, 12, 1, 08, 45, 504),
  new Date(2021, 0, 12, 1, 54, 36, 290),
  new Date(2021, 0, 12, 8, 31, 16, 087),
  new Date(2021, 0, 11, 16, 34, 05, 781),
  new Date(2000, 0, 11, 16, 36, 11, 802),
 ];
            
 var date_sort_asc = function (date1, date2) {
   if (date1 &amp;gt; date2) return 1;
   if (date1 &amp;lt; date2) return -1;
   return 0;
 };
 randomDates.sort(date_sort_asc);
 randomDates.forEach(function(dt){
 console.log(dt.toLocaleString())
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Apr 2021 22:37:41 GMT</pubDate>
    <dc:creator>UndralBatsukh</dc:creator>
    <dc:date>2021-04-15T22:37:41Z</dc:date>
    <item>
      <title>TimeSlider - Get Irregular Stops from Field</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/timeslider-get-irregular-stops-from-field/m-p/1044877#M72397</link>
      <description>&lt;P&gt;Looking for a little guidance on irregular stops for the TimeSlider widget. I have a point feature layer with a start_time field. Normally I use the "instant" mode and add the stops manually by adding the new date/time instance to the end of the array. For example&amp;nbsp;&lt;STRONG&gt;&lt;SPAN class="hljs-attr"&gt;stops&lt;/SPAN&gt;: { &lt;SPAN class="hljs-attr"&gt;dates&lt;/SPAN&gt;: [ &lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; &lt;SPAN class="hljs-built_in"&gt;Date&lt;/SPAN&gt;(&lt;SPAN class="hljs-number"&gt;2021&lt;/SPAN&gt;, &lt;SPAN class="hljs-number"&gt;3&lt;/SPAN&gt;, &lt;SPAN class="hljs-number"&gt;7, 5, 25, 0&lt;/SPAN&gt;), &lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; &lt;SPAN class="hljs-built_in"&gt;Date&lt;/SPAN&gt;(&lt;SPAN class="hljs-number"&gt;2021&lt;/SPAN&gt;, &lt;SPAN class="hljs-number"&gt;3&lt;/SPAN&gt;, 7, 9, 15, 0), &lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; &lt;SPAN class="hljs-built_in"&gt;Date&lt;/SPAN&gt;(&lt;SPAN class="hljs-number"&gt;2021&lt;/SPAN&gt;, &lt;SPAN class="hljs-number"&gt;3&lt;/SPAN&gt;, 7, 15,10, 0)) ] }.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This works fine and meets the need, but as updates to the layer are frequent I don't have the time to consistently add the new dates as they occur. Is there a method that would allow me to add each date in the field as a stop in the TimeSlider widget without having to add it manually? Each timestamp in the layer must be viewed on the slider, though multiple points may share the exact same timestamp.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 21:58:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/timeslider-get-irregular-stops-from-field/m-p/1044877#M72397</guid>
      <dc:creator>YogaYoda</dc:creator>
      <dc:date>2021-04-07T21:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: TimeSlider - Get Irregular Stops from Field</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/timeslider-get-irregular-stops-from-field/m-p/1046135#M72470</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are several ways of doing this. I created a&lt;A href="https://codepen.io/U_B_U/pen/gOgeMpQ?editors=1000" target="_self"&gt; simple app&lt;/A&gt; for you to show how to get all unique date values from your FeatureLayer and create date arrays. This way, your app should pick all changes when your layer updates.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;In the app, I am waiting for the layer to load then I am getting all unique values from the date field using smarting mapping &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-smartMapping-statistics-uniqueValues.html#uniqueValues" target="_self"&gt;uniqueValues&lt;/A&gt;&amp;nbsp;&amp;nbsp;module as shown below. Then I loop through the date values and add them to dates array. Use the date array to set the TimeSlider.stops and fullTimeExtent.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.whenLayerView(layer).then(function (lv) {
  // get unique values from the date field 
  uniqueValues({
    layer: layer,
    field: "perimeterdatetime"
  }).then(function (response) {
    let infos = response.uniqueValueInfos;
    infos.forEach(function (info) {
      const dt = new Date(info.value);
      dates.push(dt);
    });
    timeSlider.stops = { dates };
    timeSlider.fullTimeExtent = {
       start: dates[0],
       end: dates[dates.length - 1]
     };
     const start = dates[0].getTime();
     const where = `perimeterdatetime = ${start}`;

     layerView = lv;
     layerView.filter = {
       where
     };
   });
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;-Undral&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 22:15:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/timeslider-get-irregular-stops-from-field/m-p/1046135#M72470</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2021-04-12T22:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: TimeSlider - Get Irregular Stops from Field</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/timeslider-get-irregular-stops-from-field/m-p/1046623#M72510</link>
      <description>&lt;P&gt;Wow, I really appreciate this. It works well for me and is exactly what I needed. Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 20:33:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/timeslider-get-irregular-stops-from-field/m-p/1046623#M72510</guid>
      <dc:creator>YogaYoda</dc:creator>
      <dc:date>2021-04-13T20:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: TimeSlider - Get Irregular Stops from Field</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/timeslider-get-irregular-stops-from-field/m-p/1047873#M72573</link>
      <description>&lt;P&gt;Thanks again for the assistance. One more quick question if you don't mind. Would it also be possible to sort the array in ascending order? Your solution works perfectly on most data I've tested it on, but on one dataset the dates array is out of order. Therefore &lt;STRONG&gt;start: dates[0]&lt;/STRONG&gt;, and &lt;STRONG&gt;end:&amp;nbsp;dates[dates.length - 1]&amp;nbsp;&lt;/STRONG&gt;are creating a time extent that is different than it should be. I've tried using a few sort methods without success. Thanks again!&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 22:07:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/timeslider-get-irregular-stops-from-field/m-p/1047873#M72573</guid>
      <dc:creator>YogaYoda</dc:creator>
      <dc:date>2021-04-15T22:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: TimeSlider - Get Irregular Stops from Field</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/timeslider-get-irregular-stops-from-field/m-p/1047885#M72574</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://gist.github.com/onpubcom/1772996" target="_self"&gt;This approach&lt;/A&gt; appears to be working. I updated &lt;A href="https://codepen.io/U_B_U/pen/gOgeMpQ?editors=1000" target="_self"&gt;the test app&lt;/A&gt; to showcase this. The following is the gist of it.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt; var randomDates = [
  new Date(2021, 0, 11, 13, 52, 59, 452),
  new Date(2021, 0, 11, 13, 32, 58, 956),
  new Date(2021, 0, 12, 13, 55, 33, 216),
  new Date(2021, 0, 11, 14, 02, 56, 873),
  new Date(2021, 0, 11, 14, 22, 44, 315),
  new Date(2021, 0, 11, 14, 44,  21, 273),
  new Date(2021, 0, 11, 15, 02, 24, 093),
  new Date(2021, 0, 11, 17, 49, 56, 344),
  new Date(2021, 0, 12, 1, 08, 45, 504),
  new Date(2021, 0, 12, 1, 54, 36, 290),
  new Date(2021, 0, 12, 8, 31, 16, 087),
  new Date(2021, 0, 11, 16, 34, 05, 781),
  new Date(2000, 0, 11, 16, 36, 11, 802),
 ];
            
 var date_sort_asc = function (date1, date2) {
   if (date1 &amp;gt; date2) return 1;
   if (date1 &amp;lt; date2) return -1;
   return 0;
 };
 randomDates.sort(date_sort_asc);
 randomDates.forEach(function(dt){
 console.log(dt.toLocaleString())
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 22:37:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/timeslider-get-irregular-stops-from-field/m-p/1047885#M72574</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2021-04-15T22:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: TimeSlider - Get Irregular Stops from Field</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/timeslider-get-irregular-stops-from-field/m-p/1048343#M72611</link>
      <description>&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 20:40:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/timeslider-get-irregular-stops-from-field/m-p/1048343#M72611</guid>
      <dc:creator>YogaYoda</dc:creator>
      <dc:date>2021-04-16T20:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: TimeSlider - Get Irregular Stops from Field</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/timeslider-get-irregular-stops-from-field/m-p/1204523#M78368</link>
      <description>&lt;P&gt;Hi! I have tried your solution on an imagery service but I am getting some problems. The imagery displays but the time slider shows "No time extent". All I did was to replace the feature service with the imagery service and change the date field, which in my case is called "AcquisitionDate". Is the approach different for imagery services?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2022 14:11:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/timeslider-get-irregular-stops-from-field/m-p/1204523#M78368</guid>
      <dc:creator>bogdanpalade2</dc:creator>
      <dc:date>2022-08-19T14:11:31Z</dc:date>
    </item>
  </channel>
</rss>

