Build the control. Nothing is rendered or attached until MapLibre calls SunControlWidget.onAdd.
Widget configuration; see SunControlWidgetOptions. Defaults to an empty object (map-center tracking, sun-path + animation shown, enabled).
MapLibre IControl hook: the default corner when the control is added without an explicit
position.
The MapLibre ControlPosition 'top-right'.
MapLibre IControl hook: build the DOM, inject the (ref-counted) stylesheet, wire the
map listeners, and push the initial sun state. Called by map.addControl(...).
The MapLibre map this control is being added to.
The control's root HTMLElement for MapLibre to place; also the element the
sunchange CustomEvent is dispatched on.
MapLibre IControl hook: unsubscribe from the system, disconnect the resize observer and
map listeners, remove the root element, and release this instance's stylesheet reference.
Called by map.removeControl(...).
An embeddable, framework-agnostic MapLibre time-of-day control (a
maplibregl.IControl).Renders a panel with a scrubber whose track shows the day's golden-hour / twilight color bands, a date picker, Sunrise / Golden / Noon / Sunset presets, an optional sun-path arc, a live altitude/azimuth readout, a play-through-the-day animation, and a shadows toggle. Time is modeled as local mean solar time at the displayed longitude, so it reads correctly anywhere without a timezone database.
On each change it pushes the new instant to the SunControlWidgetOptions.system (or calls SunControlWidgetOptions.onChange) and dispatches a DOM
CustomEvent('sunchange', { detail: SunState, bubbles: true })on its root element, so any framework can bind without coupling to this class.Example
Example
See
SunControlWidgetOptions for the configuration fields.