require(["esri/support/timeUtils"], (timeUtils) => { /* code goes here */ });
import * as timeUtils from "@arcgis/core/support/timeUtils.js";
esri/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 | |
Promise<Object> | Extracts time slider settings from a WebMap if the webmap contains a time slider widget definition. | timeUtils |
Method Details
-
getTimeExtentFromLayers
getTimeExtentFromLayers(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
start
andend
set tonull
. For FeatureLayer or MapImageLayer withhasLiveData
set 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 AbortSignaloptionalAbortSignal 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
getTimeSliderSettingsFromWebDocument(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
null
is returned.ParametersAn instance of a webmap or webscene to extract time slider settings from.
signal AbortSignaloptionalSignal 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 }); });
-
getTimeSliderSettingsFromWebMap
getTimeSliderSettingsFromWebMap(webMap, signal){Promise<Object>}
Since: ArcGIS Maps SDK for JavaScript 4.29timeUtils since 4.21, getTimeSliderSettingsFromWebMap added at 4.29. Deprecated since 4.30. Use getTimeSliderSettingsFromWebDocument instead. -
Extracts time slider settings from a WebMap if the webmap contains a time slider widget definition. Returns an object with properties that can be used to configure the TimeSlider or TimeSliderViewModel. If a webmap does not contain a time slider definition then
null
is returned.ParameterswebMap WebMapAn instance of a webmap to extract time slider settings from.
signal AbortSignaloptionalSignal 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.getTimeSliderSettingsFromWebMap(map).then((timeSliderSettings) => { const timeSlider = new TimeSlider({ ...timeSliderSettings, view }); });