import DaylightViewModel from "@arcgis/core/widgets/Daylight/DaylightViewModel.js";const DaylightViewModel = await $arcgis.import("@arcgis/core/widgets/Daylight/DaylightViewModel.js");- Inheritance:
- DaylightViewModel→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.14
Provides the logic for the Daylight widget.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| | ||
| | ||
declaredClass readonly inherited | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| |
currentSeason
- Type
- Season
A season can be set instead of a date. Each season uses a fixed date corresponding to the seasonal equinoxes and solstices.
dayPlaying
- Type
- boolean
Starts or pauses the daytime animation cycling through the minutes of the day.
Set to true to start the animation and to false to pause it.
- Default value
- false
directShadowsEnabled
- Type
- boolean
Indicates whether to show shadows cast by the sun. For more details on this property see SceneView.environment.lighting.directShadowsEnabled.
localDate
- Type
- Date
The calendar date in the timezone given by utcOffset.
This property should only be set once the widget and the view are initialized, for example, from within an event handler. To initialize the view with a specific date and time, set a SunLighting on the SceneView.environment.
Example
view.environment.lighting = new SunLighting({ date: new Date("2022-06-21T12:00:00")}); playSpeedMultiplier
- Type
- number
Controls the daytime animation speed.
- Default value
- 1.0
Example
// Plays the daylight animation at half of the default speeddaylightWidget.playSpeedMultiplier = 0.5; sunLightingEnabled
- Type
- boolean
Indicates whether date and time are used to determine position of the light source.
When false, the light source is positioned relative to the camera, using VirtualLighting.
timeSliderPosition
- Type
- number
Slider position for the time of day in the timezone given by utcOffset. The position represents the time of the day in minutes. Possible values range between 0 and 1440.
This property should only be set once the widget and the view are initialized, for example, from within an event handler. To initialize the view with a specific date and time, set a SunLighting on the SceneView.environment.
Example
view.environment.lighting = new SunLighting({ date: new Date("2022-06-21T12:00:00")}); utcOffset
- Type
- number
The difference in hours between UTC time and the time displayed in the widget.
yearPlaying
- Type
- boolean
Starts or pauses the date animation cycling through the months of the year. Set to true to start the animation
and to false to pause it.
- Default value
- false
Methods
| Method | Signature | Class |
|---|---|---|
emit inherited | emit<Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean | |
hasEventListener inherited | hasEventListener<Type extends EventNames<this>>(type: Type): boolean | |
on inherited | on<Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle |
emit
- Signature
-
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
- Type parameters
- <Type extends EventNames<this>>
Emits an event on the instance. This method should only be used when creating subclasses of this class.
hasEventListener
- Signature
-
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
- Type parameters
- <Type extends EventNames<this>>
Indicates whether there is an event listener on the instance that matches the provided event name.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| type | Type | The name of the event. | |
- Returns
- boolean
Returns true if the class supports the input event.
on
- Signature
-
on <Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
- Type parameters
- <Type extends EventNames<this>>
Registers an event handler on the instance. Call this method to hook an event with a listener.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| type | Type | An event or an array of events to listen for. | |
| listener | EventedCallback<this["@eventTypes"][Type]> | The function to call when the event fires. | |
- Returns
- ResourceHandle
Returns an event handler with a
remove()method that should be called to stop listening for the event(s).Property Type Description remove Function When called, removes the listener from the event.
Example
view.on("click", function(event){ // event is the event handle returned after the event fires. console.log(event.mapPoint);});Events
| Name | Type |
|---|---|
user-date-time-change
user-date-time-change: CustomEvent<Record<never, never>> - Since
- ArcGIS Maps SDK for JavaScript 4.33
Fires when the user changes the date or time in the widget by interacting with the slider, the date picker, the season selector or the play buttons.