Skip To Content ArcGIS for Developers Sign In Dashboard

Visualize and compare data over time

Several layers, including AGSFeatureLayer and AGSArcGISMapImageLayer are time-aware, meaning they can use time-based rendering and filtering if it's enabled on the data source at the time of publishing. The SDK provides several ways to work with time:

  • Filter data with a time extent applied to the geo view
  • Apply a time offset to the data in a layer (useful for comparing data over time)
  • Control which eligible layers participate in time filtering
  • Add time-based parameters to queries

Filter data by time

You can filter data in time-aware layers by defining a time extent and applying it to the map or scene view. All time-aware layers in the map (or scene) displayed by the view will filter their data per the view's time extent (except when time filtering is not supported or is disabled).

To filter data by time, first create a time extent that captures the desired time range. For example, to include only data for the last 60 days, create two Dates, one for now and one for now minus 60 days:

The start time must be less than the end time - otherwise, an exception will be thrown.

Next, apply the time extent to the view.

After applying the time extent to the view, all applicable layers in the map or scene contained by the view will only show data from the specified time extent. This includes layers that:

  • Support time filtering
  • Are connected to time-enabled data sources
  • Have not had time filtering disabled

You can explicitly exclude layers from participating in time filtering.

You can also detect if an otherwise time-aware layer is incapable of working with time (e.g. because it is connected to a data source without time values).

Comparing two time periods

Because the time extent is defined for a geo view (map view or scene view), it is applied uniformly to all of the view's layers. Using a time offset, you can add (or subtract) a given amount of time from the filter defined by the geo view. The timeOffset property of time-aware layers is useful for offsetting the filter applied to participating layers. For example, you can use a one-year offset to visualize year-to-year changes in a layer's data.

To visually compare data over time, first create two layers from the same service.

Next, apply a time offset to one layer.

Add the layers to a map and the map to a map view.

Set a time extent on the map view to filter the data.

Compare layers with and without time filtering

You can set the isTimeFilteringEnable property on a layer to prevent it from filtering its content based on the time extent defined on the geo view. To show both filtered and unfiltered data, first add two layers to the map.

Next, exclude the unfiltered layer from time filtering.

Add the layers to a map and the map to a map view.

Set the time extent on the map view to filter the data.