Select to view content in your preferred language

Time Slider not Interacting with Time Enabled Feature Layer

1547
3
Jump to solution
08-12-2021 02:31 PM
cschooley
Occasional Contributor

Hey everyone. I am brand new to the Javascript API and Javascript in general, so I don't fully understand how the code syntax works, but I am learning. 

My issue is that I have created an online web app with the Javascript API and the time slider widget doesn't interact with the layer.

It is a map of Utah with points for Oil and Gas wells. In this layer, time is enabled. Within Map Viewer online the time slider works as expected, points appear and disappear as time progresses. In the web map, the time slider shows up and runs but doesn't affect the layer of points at all. 

My code is pretty simple and can be found below. 

require([
    "esri/WebMap",
    "esri/views/MapView",
    "esri/widgets/TimeSlider"
], function (WebMap, MapView, TimeSlider) {

    //Grabbing my web map
  const map = new WebMap({
    portalItem: { )
      id: "1e9a6937760e46d3bd047c108ebf8246"
    }
  });

  const view = new MapView({
    container: "viewDiv",
    map: map
  });
  
  //Creating Timeslider
  const timeSlider = new TimeSlider({
      container: "timeSlider",
      fullTimeExtent: {
          start: new Date(1900,0,1),
          end: new Date(2022,0,1)
      }
  });

  view.ui.add(timeSlider)

});

 If you want to see the Web Map, it can be found here

If you would like to see the online web application, it can be found here.

0 Kudos
1 Solution

Accepted Solutions
cschooley
Occasional Contributor

The issue was that even though the layer was time enabled, the fields used for the time were wrong. Once I fixed those to the proper start and end dates, it worked as expected. 

View solution in original post

0 Kudos
3 Replies
JeffreyWilkerson
Frequent Contributor

That looks like it will work, at least it's what Esri shows in its examples.  My guess is that your feature class isn't set up to be time aware.  Maybe look at this, not for the part about Web App Builder, but in how to setup time-enabled layers.

https://support.esri.com/en/technical-article/000024856 

0 Kudos
cschooley
Occasional Contributor

The feature class is set up to be time-aware. That's part of my confusion. If you click on the map link I provided and open the map, the slider exists and works as expected when I hit 'play'. 

Here's a picture showing that the time is enabled:

cschooley_0-1628806107341.png

Do you think I need to grab the layer specifically? I have tried doing that, but am struggling with understanding all the parameters in the time slider widget, and I think I can view.when() maybe, but that didn't work when I tried, maybe I got that wrong

0 Kudos
cschooley
Occasional Contributor

The issue was that even though the layer was time enabled, the fields used for the time were wrong. Once I fixed those to the proper start and end dates, it worked as expected. 

0 Kudos