Skip to content
import DaylightViewModel from "@arcgis/core/widgets/Daylight/DaylightViewModel.js";
Inheritance:
DaylightViewModelAccessor
Since
ArcGIS Maps SDK for JavaScript 4.14

Provides the logic for the Daylight widget.

See also

Constructors

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.

currentSeason

Property
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

Property
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

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor

The name of the class. The declared class name is formatted as esri.folder.className.

directShadowsEnabled

Property
Type
boolean

Indicates whether to show shadows cast by the sun. For more details on this property see SceneView.environment.lighting.directShadowsEnabled.

localDate

autocast Property
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

Property
Type
number

Controls the daytime animation speed.

Default value
1.0
Example
// Plays the daylight animation at half of the default speed
daylightWidget.playSpeedMultiplier = 0.5;

sunLightingEnabled

Property
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

Property
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

Property
Type
number

The difference in hours between UTC time and the time displayed in the widget.

view

Property
Type
SceneView | null | undefined

The view from which the widget will operate.

yearPlaying

Property
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

MethodSignatureClass
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

inherited Method
Signature
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Emits an event on the instance. This method should only be used when creating subclasses of this class.

Parameters
ParameterTypeDescriptionRequired
type
Type

The name of the event.

event
this["@eventTypes"][Type]

The event payload.

Returns
boolean

true if a listener was notified

hasEventListener

inherited Method
Signature
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Indicates whether there is an event listener on the instance that matches the provided event name.

Parameters
ParameterTypeDescriptionRequired
type
Type

The name of the event.

Returns
boolean

Returns true if the class supports the input event.

on

inherited Method
Signature
on <Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Registers an event handler on the instance. Call this method to hook an event with a listener.

Parameters
ParameterTypeDescriptionRequired
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).

PropertyTypeDescription
removeFunctionWhen 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

user-date-time-change

Event
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.

bubbles composed cancelable

Type definitions