The time slider provides controls that allow you to visualize temporal data by applying a specific time extent to a map view.
Use case
When viewing feature layers that contain a large amount of data with timestamps, you may want to filter the data to only show data relevant to a specific time range. This can help visualize changes in the data over time and aids in making better interpretations and predictions of future trends.
How to use the sample
Use the slider at the bottom of the map to customize the date range for which you want to view the data. The date for the hurricanes sample data ranges from September 1st, 2005 to December 31st, 2005. Once the start and end dates have been selected, the map view will update to only show the relevant data that falls in the time extent selected. Use the play button to step through the data one day at a time. Use the previous and next buttons to go back and forth in 2 day increments as demonstrated below.
How it works
- Create a
MapView
with aMap
, and add layers that have time-enabled data. - Create a
TimeSlider
from the ArcGIS Runtime Toolkit to allow users to show data only from the given date range. - Call
TimeSlider.InitializeTimePropertiesAsync
to initialize the full extent and time intervals of theTimeSlider
based on the time-awareFeaturelayer
. - Create a
TimeSlider.CurrentExtentChanged
event handler to update theMapView
when theTimeSlider
extent changes.
Relevant API
- FeatureLayer
- Map
- MapView
- ServiceFeatureTable
Additional information
This sample uses Atlantic hurricane data from the National Hurricane Center (NOAA / National Weather Service) and the TimeSlider
toolkit component which requires the toolkit to be cloned and set up locally. For information about setting up the toolkit, see the repository's root README.md here.
Tags
animate, data, filter, time, time extent, time frame, toolkit
Sample Code
<UserControl x:Class="ArcGISRuntime.WPF.Samples.FilterByTimeExtent.FilterByTimeExtent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<esri:MapView x:Name="MyMapView" Grid.Row="0" />
<esri:TimeSlider x:Name="MyTimeSlider"
Grid.Row="1"
MaxWidth="800"
Margin="0,20"
CurrentExtentChanged="TimeSlider_CurrentExtentChanged" />
</Grid>
</UserControl>