Skip to content
import { getTimeExtentFromLayers, getTimeSliderSettingsFromWebDocument } from "@arcgis/core/support/timeUtils.js";
Since
ArcGIS Maps SDK for JavaScript 4.21

Provides utility methods for working with dates.

See also

Functions

getTimeExtentFromLayers

Function

Returns the time extent of all layers which are "feature based" time-aware and/or have a "layer based" time-aware with Layer.visibilityTimeExtent set. If the time extent of the layers is set, the method returns the union of the time extents of all layers. If the time extent of a layer is not set, the method returns TimeExtent with start and end set to null. For FeatureLayer or MapImageLayer with hasLiveData set to true, the method fetches the time extent from the server.

Signature
getTimeExtentFromLayers (layers: ReadonlyArrayOrCollection<Layer>, signal?: AbortSignal | null | undefined): Promise<TimeExtent>
Parameters
ParameterTypeDescriptionRequired
layers

An array or collection of layers to compute a time extent from.

signal

AbortSignal allows for cancelable requests. If canceled, the promise will be rejected with an error named AbortError. See also AbortController.

Returns
Promise<TimeExtent>

Returns a promise that resolves to a TimeExtent.

Examples
// Get the time extent of all layers in the view.
const fullTimeExtent = await getTimeExtentFromLayers(view.map.allLayers);
// Get the time extent from an array of layers.
const timeExtent = await getTimeExtentFromLayers([
earthquakes,
emergencyCalls
]);

getTimeSliderSettingsFromWebDocument

Function
Since
ArcGIS Maps SDK for JavaScript 4.30

Extracts time slider settings from a WebMap or WebScene if the document contains a time slider widget definition. Returns an object with properties that can be used to configure the TimeSlider or TimeSliderViewModel. If a document does not contain a time slider definition then null is returned.

See also
Signature
getTimeSliderSettingsFromWebDocument (document: Map | WebScene | WebMap | null | undefined, signal?: AbortSignal | null | undefined): Promise<TimeSliderSettings | null | undefined>
Parameters
ParameterTypeDescriptionRequired
document

An instance of a webmap or webscene to extract time slider settings from.

signal

Signal object that can be used to abort the asynchronous task.

Returns
Promise<TimeSliderSettings | null | undefined>
Example
// Import and apply time slider settings stored in a webmap.
const map = new WebMap({
portalItem: {
id: "your-webmap-id",
}
});
const timeUtils = await $arcgis.import("esri/support/timeUtils.js");
const timeSliderSettings = await timeUtils.getTimeSliderSettingsFromWebDocument(map);
// Create a new TimeSlider using the settings from the web map.
const timeSlider = new TimeSlider({
...timeSliderSettings,
view
});