UNPKG

maplibre-gl-nightlayer

Version:

A Night Layer for MapLibre GL JS

158 lines (157 loc) 4.86 kB
import type { CustomLayerInterface, CustomRenderMethodInput, Map as MaplibreMap } from 'maplibre-gl'; import type { mat4 } from 'gl-matrix'; /** * Get the subsolar point (longitude and latitude) at the given date. * @param date If null, the current date is used. * @returns The subsolar point. */ export declare function getSubsolarPoint(date?: Date): { lng: number; lat: number; }; type Color3 = [number, number, number]; type Color4 = [number, number, number, number]; type Color = Color3 | Color4; /** * Options for the NightLayer. */ type Options = { /** * Date for the shadow. * If null, the current date is used. */ date?: Date | null; /** * Opacity of the layer. * 0.0 means fully transparent, 1.0 means fully opaque * default: 0.5 */ opacity?: number; /** * Color of the shadow: [r, g, b, a] * Each value should be in the range [0, 255]. * default: [0, 0, 0, 255] */ color?: Color; /** * Color of the daytime: [r, g, b, a] * Each value should be in the range [0, 255]. * default: [0, 0, 0, 0] */ daytimeColor?: Color; /** * Number of twilight steps. * 0 means no steps (gradation), 1 means one step (day/night), etc. * default: 0 */ twilightSteps?: number; /** * Attenuation factor for each twilight step. * 0.0 means no attenuation, 1.0 means full attenuation * default: 0.5 */ twilightAttenuation?: number; /** * Update interval in milliseconds. * Periodically triggers a repaint. * default: 10000 */ updateInterval?: number; }; /** * A custom Maplibre GL JS layer that renders the night side of the Earth. */ export declare class NightLayer implements CustomLayerInterface { #private; id: string; type: "custom"; renderingMode: "2d"; /** * Create a new NightLayer instance. Intended to be passed to `map.addLayer`. * @param opts The options. */ constructor(opts?: Options); /** * Get the current subsolar point (longitude and latitude) * @returns The subsolar point. */ getSubsolarPoint(): { lng: number; lat: number; }; /** * Get the date for the shadow. * @returns The date. If null, the current date is used. */ getDate(): Date | null; /** * Set the date for the shadow. * @param date If null, the current date is used. */ setDate(date: Date | null): void; /** * Get the opacity of the shadow. * @returns The opacity. 0.0 means fully transparent, 1.0 means fully opaque. */ getOpacity(): number; /** * Set the opacity of the shadow. * @param opacity 0.0 means fully transparent, 1.0 means fully opaque. */ setOpacity(opacity: number): void; /** * Get the color of the shadow. * @returns The color. Each value is in the range [0, 255]. */ getColor(): Color4; /** * Set the color of the shadow. * @param color Each value should be in the range [0, 255]. */ setColor(color: Color): void; /** * Get the color of the daytime. * @returns The color [r, g, b, a]. Each value is in the range [0, 255]. */ getDaytimeColor(): Color4; /** * Set the color of the daytime. * @param color Each value should be in the range [0, 255]. */ setDaytimeColor(color: Color): void; /** * Get the number of twilight steps. * @returns The steps. 0 means no steps (gradation), 1 means one step (day/night), etc. */ getTwilightSteps(): number; /** * Set the number of twilight steps. * @param steps 0 means no steps (gradation), 1 means one step (day/night), etc. */ setTwilightSteps(steps: number): void; /** * Get the attenuation factor for each twilight step. * @returns The attenuation. 0.0 means no attenuation, 1.0 means full attenuation. */ getTwilightAttenuation(): number; /** * Set the attenuation factor for each twilight step. * @param attenuation 0.0 means no attenuation, 1.0 means full attenuation. */ setTwilightAttenuation(attenuation: number): void; /** * Get the update interval. * @returns The interval in milliseconds. */ getUpdateInterval(): number; /** * Set the update interval. * @param interval The interval in milliseconds.. */ setUpdateInterval(interval: number): void; onAdd(map: MaplibreMap, gl: WebGLRenderingContext | WebGL2RenderingContext): void; onRemove(): void; render(gl: WebGLRenderingContext | WebGL2RenderingContext, matrix: mat4, options: CustomRenderMethodInput): void; render(gl: WebGLRenderingContext | WebGL2RenderingContext, options: CustomRenderMethodInput): void; } export default NightLayer;