ESM: import * as timeUtils from "@arcgis/core/support/timeUtils.js";
CDN: const timeUtils = await $arcgis.import("@arcgis/core/support/timeUtils.js");
Object: @arcgis/core/support/timeUtils
Since: ArcGIS Maps SDK for JavaScript 4.21
Provides utility methods for working with dates.
Method Overview Method Details 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
and end
set to null
. For FeatureLayer or MapImageLayer with hasLiveData
set to true
, the method fetches the time extent from the server.
Returns
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(document, signal){Promise<Object>}
Since: ArcGIS Maps SDK for JavaScript 4.30 timeUtils 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.
Parameters
An instance of a webmap or webscene to extract time slider settings from.
optionalSignal object that can be used to abort the asynchronous task.
Returns
Type 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 Whentrue
, 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.
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
});
});
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4