TimeSlider widget
This sample demonstrates how to use TimeSlider widget with minimal configuration. The TimeSlider widget simplifies the process of visualizing temporal data in a JavaScript application.
It uses an instance of FeatureLayer to visualize incremental precipitation forecast for next 72 hours across the contiguous United States with 6-hour interval.
The map displays the Quantitative Precipitation Forecast (QPF) for the next 72 hours across the contiguous United States. Data are updated hourly from the National Digital Forecast Database produced by the National Weather Service. Visit the portal item description page for more information.
There are four different mode options when initializing the TimeSlider widget: instant
, time-window
, cumulative-from-start
, and cumulative-from-end
. The default mode
for the time slider is time-window
. The sample uses this default mode, meaning that slider will show precipitation data that falls within a given time range, which is 6 hours in this case.
We are setting the view property on the time slider widget. The TimeSlider widget will update the view's timeExtent whenever the time slider's timeExtent changes. Setting the view
property will affect any time-aware layer in the view.
Once the layer view has loaded, the fullTimeExtent of the time slider widget is set as shown below. The end
time of the layer.timeInfo.fullTimeExtent for the service does not make full hour. So the TimeExtent.expandTo() method is called to around up the time slider's full
to fit full hours.