Types
import type { TemporalLayer } from "@arcgis/core/layers/mixins/TemporalLayer.js";
Subclasses
AnnotationFeatureLayer, CSVLayer, CatalogLayer, DimensionFeatureLayer, 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

Defines temporal information for a layer, such as start and end date fields used to track when features remain visible, as well as the layer's full time extent. If timeInfo is configured on the underlying service, it is automatically read and used by the layer.

The timeInfo can be set or overridden on the following feature based layers in the layer constructor or at runtime: AnnotationFeatureLayer, CSVLayer, CatalogLayer, DimensionFeatureLayer, FeatureLayer, GeoJSONLayer, OGCFeatureLayer, OrientedImageryLayer, SceneLayer, StreamLayer, and SubtypeGroupLayer.

When overriding a layer's timeInfo, ensure that startField and endField correspond to valid date fields in the layer's schema. To calculate a fullTimeExtent that covers all dates in the configured startField and endField, call getTimeExtentFromLayers() method. Then assign the result to layer.timeInfo.fullTimeExtent.

The startField and endField properties accept date, date-only, or timestamp-offset field types.

See also
Examples
// 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
timeInfo: {
startField: "time",
fullTimeExtent: {
start: new Date(1970, 0, 1),
end: new Date(2000, 11, 31)
},
timeZone: "UTC"
}
});
// update layer's timeInfo at runtime after the feature layer is loaded
featureLayer.timeInfo = {
startField: "DateField",
timeZone: "UTC"
};
// calculate the fullTimeExtent based on startField
const fullTimeExtent = getTimeExtentFromLayers([featureLayer]);
featureLayer.timeInfo.fullTimeExtent = fullTimeExtent;
// set layer's timeInfo to null
layer.timeInfo = null;

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.

See also
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);
}