Skip to content
Types
import type { TemporalLayer } from "@arcgis/core/layers/mixins/TemporalLayer.js";
Subclasses:
CSVLayer, CatalogLayer, FeatureLayer, GeoJSONLayer, ImageryLayer, ImageryTileLayer, MapImageLayer, OGCFeatureLayer, StreamLayer, SubtypeGroupLayer, WCSLayer, WMSLayer, KnowledgeGraphSublayer
Since
ArcGIS Maps SDK for JavaScript 4.11

TemporalLayer is a mixin that adds timeExtent, timeInfo, timeOffset and useViewTime properties to layers that support temporal data.

Properties

timeExtent

autocast Property
Type
TimeExtent | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.14

The layer's time extent. When the layer's useViewTime is false, the layer instructs the view to show data from the layer based on this time extent. If the useViewTime is true, and both layer and view time extents are set, then features that fall within the intersection of the view and layer time extents will be displayed. For example, if the layer's time extent is set to display features between 1970 and 1975 and the view has a time extent set to 1972-1980, the effective time on the feature layer will be 1972-1975.

Examples
if (!layer.useViewTime) {
if (layer.timeExtent) {
console.log("Current timeExtent:", layer.timeExtent.start, " - ", layer.timeExtent.end}
} else {
console.log("The layer will display data within the view's timeExtent.");
console.log("Current view.timeExtent:", view.timeExtent.start, " - ", view.timeExtent.end}
}
}
// set the timeExtent on the layer and useViewTime false
// In this case, the layer will honor its timeExtent and ignore
// the view's timeExtent
const layer = new ImageryLayer({
url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ScientificData/SeaTemperature/ImageServer",
timeExtent: {
start: new Date(2014, 4, 18),
end: new Date(2014, 4, 19)
},
useViewTime: false
});
// timeExtent is set on the layer and the view
// In this case, the layer will display features that fall
// within the intersection of view and layer time extents
// features within Jan 1, 1976 - Jan 1, 1981 will be displayed
const view = new MapView({
timeExtent: {
start: new Date(1976, 0, 1),
end: new Date(2002, 0, 1)
}
});
const layer = new FeatureLayer({
url: myUrl,
timeExtent: {
start: new Date(1974, 0, 1),
end: new Date(1981, 0, 1)
}
});

timeInfo

autocast Property
Type
TimeInfo | null | undefined

TimeInfo provides information such as date fields that store start and end time for each feature and the fullTimeExtent for the layer. The timeInfo property, along with its startField and endField properties, must be set at the time of layer initialization if it is being set for a CSVLayer, GeoJSONLayer or FeatureLayer initialized from client-side features. The fullTimeExtent for timeInfo is automatically calculated based on its startField and endField properties. The timeInfo parameters cannot be changed after the layer is loaded.

TimeInfo's TimeInfo.startField and endField can be date, date-only or timestamp-offset field type for FeatureLayer and MapImageLayer.

Example
// create geojson layer from usgs earthquakes geojson feed
const geojsonLayer = new GeoJSONLayer({
url: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson",
copyright: "USGS Earthquakes",
fields: [
{ "name": "mag", "type": "double" },
{ "name": "place", "type": "string" },
{ "name": "time", "type": "date" }, // date field
{ "name": "depth", "type": "double" }
],
// timeInfo can be used to do temporal queries
// set the startField and endField.
// timeExtent is automatically calculated from the
// the start and end date fields
// The date values must be in milliseconds number from the UNIX epoch specified in UTC.
timeInfo: {
startField: "time"
}
});

timeOffset

autocast Property
Type
TimeInterval | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.14

A temporary offset of the time data based on a certain TimeInterval. This allows users to overlay features from two or more time-aware layers with different time extents. For example, if a layer has data recorded for the year 1970, an offset value of 2 years would temporarily shift the data to 1972. You can then overlay this data with data recorded in 1972. A time offset can be used for display purposes only. The query and selection are not affected by the offset.

Example
// Offset a CSV Layer containing hurricanes from 2015 so that they appear in 2019 (+4 years).
let layer = new CSVLayer({
url: `hurricanes-and-storms-2015.csv`,
timeOffset: {
value: 4,
unit: "years"
},
timeInfo: {
startField: "ISO_time"
},
renderer: {
type: "simple",
symbol: {
type: "simple-marker",
size: 6,
color: "red",
outline: {
width: 0.5,
color: "black"
}
}
}
});

useViewTime

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.14

Determines if the time enabled layer will update its temporal data based on the view's timeExtent. When false, the layer will display its temporal data based on the layer's timeExtent, regardless of changes to the view. If both view and layer time extents are set while this property is true, then the features that fall within the intersection of the view and layer time extents will be displayed. For example, if a layer's time extent is set to display features between 1970 and 1975 and the view has a time extent set to 1972-1980, the effective time on the feature layer will be 1972-1975.

Changing useViewTime to false does not affect layer's visibilityTimeExtent.

Default value
true
Example
if (featureLayer.useViewTime) {
console.log("Displaying data between:", view.timeExtent.start, " - ", view.timeExtent.end);
}