import * as timeUtils from "@arcgis/core/support/timeUtils.js";
const timeUtils = await $arcgis.import("@arcgis/core/support/timeUtils.js");
@arcgis/core/support/timeUtils
Provides utility methods for working with dates.
Method Overview
| Name | Return Type | Summary | Object |
|---|---|---|---|
Promise<TimeExtent> | 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. | timeUtils | |
Promise<Object> | Extracts time slider settings from a WebMap or WebScene if the document contains a time slider widget definition. | timeUtils |
Method Details
-
getTimeExtentFromLayers
MethodgetTimeExtentFromLayers(layers, signal){Promise<TimeExtent>} -
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
startandendset tonull. For FeatureLayer or MapImageLayer withhasLiveDataset totrue, the method fetches the time extent from the server.Parameterslayers Layer[]|Collection<Layer>An array or collection of layers to compute a time extent from.
signal AbortSignal|null|undefinedoptionalAbortSignal allows for cancelable requests. If canceled, the promise will be rejected with an error named
AbortError. See also AbortController.ReturnsType Description 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
MethodgetTimeSliderSettingsFromWebDocument(document, signal){Promise<Object>}Since: ArcGIS Maps SDK for JavaScript 4.30timeUtils since 4.21, getTimeSliderSettingsFromWebDocument added at 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
nullis returned.ParametersAn instance of a webmap or webscene to extract time slider settings from.
signal AbortSignal|null|undefinedoptionalSignal object that can be used to abort the asynchronous task.
ReturnsType Description Promise<Object> When resolved, returns an object with the following properties. Property Type Description fullTimeExtent TimeExtent The temporal extent of the entire slider. loop Boolean When true, the time slider will play its animation in a loop.mode "instant" | "time-window" | "cumulative-from-start" | "cumulative-from-end" The time slider mode. playRate Number The time (in milliseconds) between animation steps. stops StopsByDates | StopsByCount | StopsByInterval Defines specific locations on the time slider where thumbs will snap to when manipulated. timeExtent TimeExtent The current time extent of the time slider. - See also
Example// Import and apply time slider settings stored in a webmap. const map = new WebMap({ portalItem: { id: "your-webmap-id", } }); timeUtils.getTimeSliderSettingsFromWebDocument(map).then((timeSliderSettings) => { const timeSlider = new TimeSlider({ ...timeSliderSettings, view }); });