@maptiler/sdk 3.9.0-rc.4 → 3.9.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eslint.mjs +133 -0
- package/dist/maptiler-sdk.d.ts +2 -0
- package/dist/maptiler-sdk.mjs +14208 -0
- package/dist/maptiler-sdk.mjs.map +1 -0
- package/dist/src/ColorRamp.d.ts +359 -0
- package/dist/src/ImageViewer/ImageViewer.d.ts +408 -0
- package/dist/src/ImageViewer/ImageViewerMarker.d.ts +236 -0
- package/dist/src/ImageViewer/events.d.ts +47 -0
- package/dist/src/ImageViewer/index.d.ts +5 -0
- package/dist/src/ImageViewer/monkeyPatchML.d.ts +11 -0
- package/dist/src/ImageViewer/symbols.d.ts +2 -0
- package/dist/src/MLAdapters/AttributionControl.d.ts +5 -0
- package/dist/src/MLAdapters/BoxZoomHandler.d.ts +7 -0
- package/dist/src/MLAdapters/CanvasSource.d.ts +5 -0
- package/dist/src/MLAdapters/CooperativeGesturesHandler.d.ts +5 -0
- package/dist/src/MLAdapters/FullscreenControl.d.ts +5 -0
- package/dist/src/MLAdapters/GeoJSONSource.d.ts +5 -0
- package/dist/src/MLAdapters/GeolocateControl.d.ts +5 -0
- package/dist/src/MLAdapters/ImageSource.d.ts +5 -0
- package/dist/src/MLAdapters/KeyboardHandler.d.ts +5 -0
- package/dist/src/MLAdapters/LogoControl.d.ts +5 -0
- package/dist/src/MLAdapters/MapMouseEvent.d.ts +5 -0
- package/dist/src/MLAdapters/MapTouchEvent.d.ts +5 -0
- package/dist/src/MLAdapters/MapWheelEvent.d.ts +5 -0
- package/dist/src/MLAdapters/Marker.d.ts +5 -0
- package/dist/src/MLAdapters/NavigationControl.d.ts +5 -0
- package/dist/src/MLAdapters/Popup.d.ts +5 -0
- package/dist/src/MLAdapters/RasterDEMTileSource.d.ts +5 -0
- package/dist/src/MLAdapters/RasterTileSource.d.ts +5 -0
- package/dist/src/MLAdapters/ScaleControl.d.ts +5 -0
- package/dist/src/MLAdapters/ScrollZoomHandler.d.ts +5 -0
- package/dist/src/MLAdapters/Style.d.ts +5 -0
- package/dist/src/MLAdapters/TerrainControl.d.ts +5 -0
- package/dist/src/MLAdapters/TwoFingersTouchPitchHandler.d.ts +5 -0
- package/dist/src/MLAdapters/VectorTileSource.d.ts +5 -0
- package/dist/src/MLAdapters/VideoSource.d.ts +5 -0
- package/dist/src/Map.d.ts +470 -0
- package/dist/src/Point.d.ts +177 -0
- package/dist/src/Telemetry.d.ts +23 -0
- package/dist/src/caching.d.ts +4 -0
- package/dist/src/config.d.ts +85 -0
- package/dist/src/constants/defaults.d.ts +15 -0
- package/dist/src/controls/ImageViewerFitImageToBoundsControl.d.ts +13 -0
- package/dist/src/controls/MaptilerCustomControl.d.ts +17 -0
- package/dist/src/controls/MaptilerExternalControl.d.ts +25 -0
- package/dist/src/controls/MaptilerGeolocateControl.d.ts +21 -0
- package/dist/src/controls/MaptilerLogoControl.d.ts +19 -0
- package/dist/src/controls/MaptilerNavigationControl.d.ts +17 -0
- package/dist/src/controls/MaptilerProjectionControl.d.ts +15 -0
- package/dist/src/controls/MaptilerTerrainControl.d.ts +17 -0
- package/dist/src/controls/Minimap.d.ts +57 -0
- package/dist/src/controls/index.d.ts +8 -0
- package/dist/src/converters/index.d.ts +1 -0
- package/dist/src/converters/xml.d.ts +54 -0
- package/dist/src/custom-layers/CubemapLayer/CubemapLayer.d.ts +239 -0
- package/dist/src/custom-layers/CubemapLayer/constants.d.ts +3 -0
- package/dist/src/custom-layers/CubemapLayer/index.d.ts +2 -0
- package/dist/src/custom-layers/CubemapLayer/loadCubemapTexture.d.ts +42 -0
- package/dist/src/custom-layers/CubemapLayer/types.d.ts +67 -0
- package/dist/src/custom-layers/RadialGradientLayer/RadialGradientLayer.d.ts +149 -0
- package/dist/src/custom-layers/RadialGradientLayer/index.d.ts +2 -0
- package/dist/src/custom-layers/RadialGradientLayer/types.d.ts +50 -0
- package/dist/src/custom-layers/extractCustomLayerStyle.d.ts +17 -0
- package/dist/src/custom-layers/index.d.ts +6 -0
- package/dist/src/helpers/index.d.ts +5 -0
- package/dist/src/helpers/screenshot.d.ts +18 -0
- package/dist/src/helpers/stylehelper.d.ts +28 -0
- package/dist/src/helpers/vectorlayerhelpers.d.ts +508 -0
- package/dist/src/index.d.ts +91 -0
- package/dist/src/language.d.ts +107 -0
- package/dist/src/mapstyle.d.ts +18 -0
- package/dist/src/tools.d.ts +84 -0
- package/dist/src/types.d.ts +1 -0
- package/dist/src/utils/dom.d.ts +2 -0
- package/dist/src/utils/errors.d.ts +5 -0
- package/dist/src/utils/geo-utils.d.ts +6 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/math-utils.d.ts +8 -0
- package/dist/src/utils/object.d.ts +1 -0
- package/dist/src/utils/webgl-utils.d.ts +49 -0
- package/package.json +2 -2
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { CustomLayerInterface, CustomRenderMethodInput } from 'maplibre-gl';
|
|
2
|
+
import { Map as MapSDK } from '../../Map';
|
|
3
|
+
import { WebGLContext } from '../../utils/webgl-utils';
|
|
4
|
+
import { CubemapDefinition, CubemapFaces, CubemapLayerConstructorOptions } from './types';
|
|
5
|
+
declare class CubemapLayer implements CustomLayerInterface {
|
|
6
|
+
id: string;
|
|
7
|
+
type: CustomLayerInterface["type"];
|
|
8
|
+
renderingMode: CustomLayerInterface["renderingMode"];
|
|
9
|
+
/**
|
|
10
|
+
* The map instance to which this layer is added.
|
|
11
|
+
* @type {MapSDK}
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
private map;
|
|
15
|
+
/**
|
|
16
|
+
* The cubemap faces definition, which can be either a preset, path, or explicit face URLs.
|
|
17
|
+
* @type {CubemapFaces | null}
|
|
18
|
+
* @remarks
|
|
19
|
+
* This property is set during the initialization of the layer and can be updated later.
|
|
20
|
+
* If no faces are defined, it will be `null`.
|
|
21
|
+
*/
|
|
22
|
+
private faces?;
|
|
23
|
+
/**
|
|
24
|
+
* Indicates whether to use a cubemap texture for rendering.
|
|
25
|
+
* @type {boolean}
|
|
26
|
+
* @private
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
private useCubemapTexture;
|
|
30
|
+
/**
|
|
31
|
+
* The current opacity of the fade effect applied to the cubemap image texture, used for fading in and out.
|
|
32
|
+
* @type {number}
|
|
33
|
+
* @private
|
|
34
|
+
* @default 0.0
|
|
35
|
+
*/
|
|
36
|
+
private currentFadeOpacity;
|
|
37
|
+
/**
|
|
38
|
+
* Indicates whether the cubemap needs to be updated, typically when the faces or texture changes.
|
|
39
|
+
* @type {boolean}
|
|
40
|
+
* @private
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
private cubeMapNeedsUpdate;
|
|
44
|
+
/**
|
|
45
|
+
* The background color of the cubemap layer, represented as a Vec4 (RGBA).
|
|
46
|
+
* @type {Vec4}
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
private bgColor;
|
|
50
|
+
/**
|
|
51
|
+
* The previous background color used for transition animations.
|
|
52
|
+
* @type {Vec4}
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
private previousBgColor;
|
|
56
|
+
/**
|
|
57
|
+
* The target background color to which the layer will transition.
|
|
58
|
+
* @type {Vec4}
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
private targetBgColor;
|
|
62
|
+
/**
|
|
63
|
+
* The delta value used for transitioning the background color. 0 = start of transition, 1 = end of transition.
|
|
64
|
+
* This value is incremented over time to create a smooth transition effect.
|
|
65
|
+
* @type {number}
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
private transitionDelta;
|
|
69
|
+
/**
|
|
70
|
+
* The WebGL context used for rendering the cubemap layer.
|
|
71
|
+
* @type {WebGLContext}
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
private gl;
|
|
75
|
+
/**
|
|
76
|
+
* The cubemap object that contains the shader program, buffers and uniform locations for rendering.
|
|
77
|
+
* @type {Object3D}
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
private cubemap?;
|
|
81
|
+
/**
|
|
82
|
+
* The WebGL texture used for the cubemap, which is created from the defined faces.
|
|
83
|
+
* This texture is used to render the cubemap in the scene.
|
|
84
|
+
* @type {WebGLTexture | undefined}
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
private texture?;
|
|
88
|
+
/**
|
|
89
|
+
* The key representing the current faces definition, used to diff / track changes in the cubemap faces.
|
|
90
|
+
* @type {string}
|
|
91
|
+
*/
|
|
92
|
+
currentFacesDefinitionKey: string;
|
|
93
|
+
/**
|
|
94
|
+
* The configuration options for the cubemap layer.
|
|
95
|
+
* @type {CubemapLayerConstructorOptions}
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
private options;
|
|
99
|
+
private animationActive;
|
|
100
|
+
/**
|
|
101
|
+
* Creates a new instance of CubemapLayer
|
|
102
|
+
*
|
|
103
|
+
* @param {CubemapLayerConstructorOptions | true} cubemapConfig - Configuration options for the cubemap layer or `true` to use default options.
|
|
104
|
+
* Can specify faces, preset, path, and color properties to configure the cubemap.
|
|
105
|
+
*
|
|
106
|
+
* @remarks You shouldn't have to use this class directly.
|
|
107
|
+
* Instead, use the `Map.setHalo` method to create and add a halo layer to the map.
|
|
108
|
+
* The constructor initializes the cubemap with the provided configuration.
|
|
109
|
+
* It processes the faces definition, sets up background colors, and determines
|
|
110
|
+
* whether to use a cubemap texture based on the provided options.
|
|
111
|
+
*/
|
|
112
|
+
constructor(cubemapConfig: CubemapLayerConstructorOptions | true);
|
|
113
|
+
/**
|
|
114
|
+
* Updates the cubemap object with the current faces and shader configuration.
|
|
115
|
+
* This method is called when the cubemap faces change or when the layer is initialized.
|
|
116
|
+
* @returns {void}
|
|
117
|
+
* @remarks
|
|
118
|
+
* It creates a new Object3D instance with the specified vertex and fragment shaders,
|
|
119
|
+
* attributes, and uniforms. The cubemap will be rendered using this configuration.
|
|
120
|
+
*/
|
|
121
|
+
updateCubemap({ facesNeedUpdate }?: {
|
|
122
|
+
facesNeedUpdate: boolean;
|
|
123
|
+
}): void;
|
|
124
|
+
/**
|
|
125
|
+
* Called when the layer is added to the map.
|
|
126
|
+
* Initializes the cubemap and sets up the WebGL context.
|
|
127
|
+
*
|
|
128
|
+
* @param {MapSDK} map - The map instance to which this layer is added.
|
|
129
|
+
* @param {WebGLRenderingContext | WebGL2RenderingContext} gl - The WebGL context used for rendering.
|
|
130
|
+
*/
|
|
131
|
+
onAdd(map: MapSDK, gl: WebGLRenderingContext | WebGL2RenderingContext): void;
|
|
132
|
+
/**
|
|
133
|
+
* Called when the layer is removed from the map.
|
|
134
|
+
* Cleans up the cubemap resources and WebGL buffers.
|
|
135
|
+
*
|
|
136
|
+
* @param {MapSDK} _map - The map instance from which this layer is removed.
|
|
137
|
+
* @param {WebGLRenderingContext | WebGL2RenderingContext} gl - The WebGL context used for rendering.
|
|
138
|
+
*/
|
|
139
|
+
onRemove(_map: MapSDK, gl: WebGLRenderingContext | WebGL2RenderingContext): void;
|
|
140
|
+
/**
|
|
141
|
+
* Updates the cubemap texture with the provided faces.
|
|
142
|
+
* This method is called when the cubemap faces change or when the layer is initialized.
|
|
143
|
+
*
|
|
144
|
+
* @param {WebGLContext} gl - The WebGL context used for rendering.
|
|
145
|
+
* @param {CubemapFaces} faces - The cubemap faces to be loaded into the texture.
|
|
146
|
+
*/
|
|
147
|
+
updateTexture(gl: WebGLContext, faces: CubemapFaces): void;
|
|
148
|
+
/**
|
|
149
|
+
* Called before the layer is rendered.
|
|
150
|
+
* Updates the cubemap texture with the current faces.
|
|
151
|
+
*
|
|
152
|
+
* @param {WebGLContext} gl - The WebGL context used for rendering.
|
|
153
|
+
* @param {CustomRenderMethodInput} _options - Additional options for the render method.
|
|
154
|
+
*/
|
|
155
|
+
prerender(_gl: WebGLContext, _options: CustomRenderMethodInput): void;
|
|
156
|
+
/**
|
|
157
|
+
* Lerps the background color transition of the cubemap layer.
|
|
158
|
+
* This method smoothly transitions the background color from the previous color to the target color.
|
|
159
|
+
*
|
|
160
|
+
* @private
|
|
161
|
+
*/
|
|
162
|
+
private animateColorChange;
|
|
163
|
+
/**
|
|
164
|
+
* Animates the cubemap image fading in.
|
|
165
|
+
* This method gradually increases the opacity of the cubemap image to create a fade-in effect.
|
|
166
|
+
*
|
|
167
|
+
* @private
|
|
168
|
+
*/
|
|
169
|
+
private imageIsAnimating;
|
|
170
|
+
/**
|
|
171
|
+
* The delta value used for the image fade-in animation.
|
|
172
|
+
* This value is incremented over time to create a smooth fade-in effect.
|
|
173
|
+
* @type {number}
|
|
174
|
+
* @private
|
|
175
|
+
*/
|
|
176
|
+
private imageFadeInDelta;
|
|
177
|
+
/**
|
|
178
|
+
* Animates the cubemap image fading in.
|
|
179
|
+
* This method gradually increases the opacity of the cubemap image to create a fade-in effect.
|
|
180
|
+
* @private
|
|
181
|
+
*/
|
|
182
|
+
private animateIn;
|
|
183
|
+
/**
|
|
184
|
+
* Animates the cubemap image fading out.
|
|
185
|
+
* This method gradually decreases the opacity of the cubemap image to create a fade-out effect.
|
|
186
|
+
* @returns {Promise<void>} A promise that resolves when the animation is complete.
|
|
187
|
+
* @private
|
|
188
|
+
*/
|
|
189
|
+
private animateOut;
|
|
190
|
+
setAnimationActive(active: boolean): void;
|
|
191
|
+
/**
|
|
192
|
+
* Renders the cubemap layer to the WebGL context.
|
|
193
|
+
* This method is called internally during the rendering phase of the map.
|
|
194
|
+
*
|
|
195
|
+
* @param {WebGLRenderingContext | WebGL2RenderingContext} gl - The WebGL context used for rendering.
|
|
196
|
+
* @param {CustomRenderMethodInput} _options - Additional options for the render method.
|
|
197
|
+
* @throws Error if the map, cubemap, or texture is undefined.
|
|
198
|
+
*/
|
|
199
|
+
render(gl: WebGLRenderingContext | WebGL2RenderingContext, _options: CustomRenderMethodInput): void;
|
|
200
|
+
private setBgColor;
|
|
201
|
+
/**
|
|
202
|
+
* Returns the current configuration options for the cubemap layer.
|
|
203
|
+
* @returns {CubemapLayerConstructorOptions} The current configuration options.
|
|
204
|
+
*/
|
|
205
|
+
getConfig(): CubemapLayerConstructorOptions;
|
|
206
|
+
/**
|
|
207
|
+
* Checks if the cubemap needs to be updated based on the provided specification.
|
|
208
|
+
*
|
|
209
|
+
* @param {CubemapDefinition} spec - The cubemap specification to compare with the current cubemap.
|
|
210
|
+
* @returns {boolean} True if the cubemap needs to be updated, false otherwise.
|
|
211
|
+
*/
|
|
212
|
+
shouldUpdate(newSpec?: CubemapDefinition): boolean;
|
|
213
|
+
private setCubemapFaces;
|
|
214
|
+
/**
|
|
215
|
+
* Sets the cubemap for the layer based on the provided definition.
|
|
216
|
+
* This method updates the cubemap faces, background color, and triggers a repaint of the map.
|
|
217
|
+
*
|
|
218
|
+
* @param {CubemapDefinition} cubemap - The cubemap definition containing faces, preset, path, or color.
|
|
219
|
+
* @returns {Promise<void>} A promise that resolves when the cubemap is set and the map is updated.
|
|
220
|
+
* @remarks
|
|
221
|
+
* This method checks if the provided cubemap definition has a color, and if so, it updates the background color.
|
|
222
|
+
* It also checks if the faces definition has changed compared to the current one,
|
|
223
|
+
* and if so, it updates the cubemap faces.
|
|
224
|
+
* Finally, it calls `updateCubemap` to apply the changes and trigger a repaint of the map.
|
|
225
|
+
*/
|
|
226
|
+
setCubemap(spec: CubemapDefinition | boolean): Promise<void>;
|
|
227
|
+
/**
|
|
228
|
+
* Shows the cubemap layer by setting its visibility to "visible".
|
|
229
|
+
* This method is used to make the cubemap layer visible on the map.
|
|
230
|
+
*/
|
|
231
|
+
show(): void;
|
|
232
|
+
/**
|
|
233
|
+
* Hides the cubemap layer by setting its visibility to "none".
|
|
234
|
+
* This method is used to remove the cubemap layer from the map without deleting it.
|
|
235
|
+
*/
|
|
236
|
+
hide(): void;
|
|
237
|
+
}
|
|
238
|
+
export declare function validateSpaceSpecification(space?: CubemapDefinition | boolean): boolean;
|
|
239
|
+
export { CubemapLayer };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CubemapFaces } from './types';
|
|
2
|
+
type WebGLCtx = WebGLRenderingContext | WebGL2RenderingContext;
|
|
3
|
+
interface LoadCubemapTextureOptions {
|
|
4
|
+
gl: WebGLCtx;
|
|
5
|
+
faces?: CubemapFaces;
|
|
6
|
+
onReady: (texture: WebGLTexture, images?: HTMLImageElement[]) => void;
|
|
7
|
+
forceRefresh?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Loads a cubemap texture from a set of image URLs.
|
|
11
|
+
*
|
|
12
|
+
* This function creates and configures a WebGL cubemap texture from a set of images.
|
|
13
|
+
* It memoizes the created texture to avoid redundant loading of the same faces,
|
|
14
|
+
* unless the `forceRefresh` flag is set.
|
|
15
|
+
*
|
|
16
|
+
* @param {Object} options - The options object.
|
|
17
|
+
* @param {WebGLRenderingContext | WebGL2RenderingContext} options.gl - The WebGL rendering context.
|
|
18
|
+
* @param {CubemapFaces} options.faces - An object containing URLs for each face of the cubemap.
|
|
19
|
+
* Must contain exactly 6 faces.
|
|
20
|
+
* @param {Function} [options.onReady] - Optional callback function to be called when all faces are loaded.
|
|
21
|
+
* @param {boolean} [options.forceRefresh] - If true, forces creation of a new texture instead of returning the memoized one.
|
|
22
|
+
*
|
|
23
|
+
* @returns {WebGLTexture | undefined} The created WebGL cubemap texture, or undefined if there was an error.
|
|
24
|
+
*
|
|
25
|
+
* @see {@link facesKey}
|
|
26
|
+
* @see {@link memoizedReturnValue}
|
|
27
|
+
* @example
|
|
28
|
+
* const texture = loadCubemapTexture({
|
|
29
|
+
* gl: webglContext,
|
|
30
|
+
* faces: {
|
|
31
|
+
* px: 'right.jpg',
|
|
32
|
+
* nx: 'left.jpg',
|
|
33
|
+
* py: 'top.jpg',
|
|
34
|
+
* ny: 'bottom.jpg',
|
|
35
|
+
* pz: 'front.jpg',
|
|
36
|
+
* nz: 'back.jpg'
|
|
37
|
+
* },
|
|
38
|
+
* onReady: () => console.log('Cubemap loaded')
|
|
39
|
+
* });
|
|
40
|
+
*/
|
|
41
|
+
export declare function loadCubemapTexture({ gl, faces, onReady, forceRefresh }: LoadCubemapTextureOptions): void;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export declare enum CubemapImagesPresets {
|
|
2
|
+
UNIVERSE_DARK = "universe-dark"
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Constructor options for the CubemapLayer.
|
|
6
|
+
* This type is equivalent to {@link CubemapDefinition} with no additional properties.
|
|
7
|
+
*/
|
|
8
|
+
export type CubemapLayerConstructorOptions = CubemapDefinition & {};
|
|
9
|
+
export declare const cubemapPresets: Record<string, CubemapDefinition>;
|
|
10
|
+
/**
|
|
11
|
+
* Defines how a cubemap should be constructed from source materials.
|
|
12
|
+
* This is a discriminated union type with four possible formats:
|
|
13
|
+
*
|
|
14
|
+
* 1. Path-based: Specify a base URL and optional format for cube face images
|
|
15
|
+
* 2. Faces-based: Provide explicit URLs for each cube face
|
|
16
|
+
* 3. Preset-based: Use a predefined cubemap from available presets
|
|
17
|
+
* 4. Color-based: Use a single color for all faces
|
|
18
|
+
*
|
|
19
|
+
* Only one of `path`, `faces`, `preset`, or `color` should be provided.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Path-based cubemap
|
|
23
|
+
* const pathCubemap: CubemapDefinition = {
|
|
24
|
+
* path: {
|
|
25
|
+
* baseUrl: 'https://example.com/cubemap',
|
|
26
|
+
* format: 'png'
|
|
27
|
+
* }
|
|
28
|
+
* };
|
|
29
|
+
*
|
|
30
|
+
* // Color-based cubemap
|
|
31
|
+
* const colorCubemap: CubemapDefinition = {
|
|
32
|
+
* color: '#ff0000'
|
|
33
|
+
* };
|
|
34
|
+
*/
|
|
35
|
+
export type CubemapDefinition = {
|
|
36
|
+
path: {
|
|
37
|
+
baseUrl: string;
|
|
38
|
+
format?: "png" | "jpg" | "webp";
|
|
39
|
+
};
|
|
40
|
+
faces?: never;
|
|
41
|
+
preset?: never;
|
|
42
|
+
color?: string;
|
|
43
|
+
} | {
|
|
44
|
+
faces: CubemapFaces;
|
|
45
|
+
path?: never;
|
|
46
|
+
preset?: never;
|
|
47
|
+
color?: string;
|
|
48
|
+
} | {
|
|
49
|
+
preset: keyof typeof cubemapPresets;
|
|
50
|
+
path?: never;
|
|
51
|
+
faces?: never;
|
|
52
|
+
color?: string;
|
|
53
|
+
} | {
|
|
54
|
+
color: string;
|
|
55
|
+
path?: never;
|
|
56
|
+
faces?: never;
|
|
57
|
+
preset?: never;
|
|
58
|
+
};
|
|
59
|
+
export declare enum CubemapFaceNames {
|
|
60
|
+
POSITIVE_X = "pX",
|
|
61
|
+
NEGATIVE_X = "nX",
|
|
62
|
+
POSITIVE_Y = "pY",
|
|
63
|
+
NEGATIVE_Y = "nY",
|
|
64
|
+
POSITIVE_Z = "pZ",
|
|
65
|
+
NEGATIVE_Z = "nZ"
|
|
66
|
+
}
|
|
67
|
+
export type CubemapFaces = Record<CubemapFaceNames, string>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { CustomLayerInterface, CustomRenderMethodInput } from 'maplibre-gl';
|
|
2
|
+
import { Map as MapSDK } from '../../Map';
|
|
3
|
+
import { GradientDefinition, RadialGradientLayerConstructorOptions } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* A custom map layer that renders a radial gradient effect, typically used as a halo around a globe.
|
|
6
|
+
* This layer uses WebGL for rendering and provides animation capabilities.
|
|
7
|
+
*
|
|
8
|
+
* The layer is implemented as a 3D custom layer that renders a billboard quad with a radial gradient shader.
|
|
9
|
+
* The gradient can be configured with multiple color stops and can be animated.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // Create a simple halo layer with default settings
|
|
14
|
+
* const haloLayer = new RadialGradientLayer(true);
|
|
15
|
+
* map.addLayer(haloLayer);
|
|
16
|
+
*
|
|
17
|
+
* // Create a customized halo layer
|
|
18
|
+
* const customHalo = new RadialGradientLayer({
|
|
19
|
+
* scale: 1.5,
|
|
20
|
+
* stops: [
|
|
21
|
+
* [0, "rgba(255, 255, 255, 0.8)"],
|
|
22
|
+
* [1, "rgba(255, 255, 255, 0)"]
|
|
23
|
+
* ]
|
|
24
|
+
* });
|
|
25
|
+
* map.addLayer(customHalo);
|
|
26
|
+
* ```
|
|
27
|
+
* @remarks You shouldn't have to use this class directly.
|
|
28
|
+
* Instead, use the `Map.setHalo` method to create and add a halo layer to the map.
|
|
29
|
+
*/
|
|
30
|
+
export declare class RadialGradientLayer implements CustomLayerInterface {
|
|
31
|
+
id: string;
|
|
32
|
+
type: CustomLayerInterface["type"];
|
|
33
|
+
renderingMode: CustomLayerInterface["renderingMode"];
|
|
34
|
+
/**
|
|
35
|
+
* The gradient definition used by this layer.
|
|
36
|
+
* It contains the stops and scale for the radial gradient.
|
|
37
|
+
* @private
|
|
38
|
+
* @type {GradientDefinition}
|
|
39
|
+
*/
|
|
40
|
+
private gradient;
|
|
41
|
+
/**
|
|
42
|
+
* The scale of the radial gradient, which determines its size.
|
|
43
|
+
* This value is animated from 0 to the target scale during the layer's appearance.
|
|
44
|
+
* @private
|
|
45
|
+
* @type {number}
|
|
46
|
+
*/
|
|
47
|
+
private scale;
|
|
48
|
+
/**
|
|
49
|
+
* The animation delta value used to control the progress of the gradient's appearance animation.
|
|
50
|
+
* It is incremented during each frame of the animation until it reaches 1.
|
|
51
|
+
* @private
|
|
52
|
+
* @type {number}
|
|
53
|
+
*/
|
|
54
|
+
private animationDelta;
|
|
55
|
+
/**
|
|
56
|
+
* The MapSDK instance to which this layer is added.
|
|
57
|
+
* This is set when the layer is added to the map.
|
|
58
|
+
* @private
|
|
59
|
+
* @type {MapSDK}
|
|
60
|
+
*/
|
|
61
|
+
private map;
|
|
62
|
+
/**
|
|
63
|
+
* The 3D object representing the radial gradient plane.
|
|
64
|
+
* This object is created when the layer is added to the map and contains the shader program and buffers.
|
|
65
|
+
* It is used for rendering the radial gradient effect.
|
|
66
|
+
* @private
|
|
67
|
+
* @type {Object3D<(typeof ATTRIBUTES_KEYS)[number], (typeof UNIFORMS_KEYS)[number]>}
|
|
68
|
+
*/
|
|
69
|
+
private plane?;
|
|
70
|
+
/**
|
|
71
|
+
* Whether the halo should be animated in and out.
|
|
72
|
+
* @private
|
|
73
|
+
* @type {boolean}
|
|
74
|
+
*/
|
|
75
|
+
private animationActive;
|
|
76
|
+
/**
|
|
77
|
+
* Creates a new RadialGradientLayer instance.
|
|
78
|
+
*
|
|
79
|
+
* @param {RadialGradientLayerConstructorOptions | boolean} gradient - Configuration options for the radial gradient or a boolean value.
|
|
80
|
+
* If a boolean is provided, default configuration options will be used.
|
|
81
|
+
* If an `RadialGradientLayerConstructorOptions` is provided, it will be merged with default options.
|
|
82
|
+
*/
|
|
83
|
+
constructor(gradient: RadialGradientLayerConstructorOptions | boolean);
|
|
84
|
+
/**
|
|
85
|
+
* Adds the radial gradient layer to the specified map.
|
|
86
|
+
* This method is called by the map when the layer is added to it.
|
|
87
|
+
*
|
|
88
|
+
* @param {MapSDK} map - The MapSDK instance to which this layer is being added
|
|
89
|
+
* @param {WebGLRenderingContext | WebGL2RenderingContext} gl - The WebGL rendering context used for rendering the layer
|
|
90
|
+
* @returns void
|
|
91
|
+
*/
|
|
92
|
+
onAdd(map: MapSDK, gl: WebGLRenderingContext | WebGL2RenderingContext): void;
|
|
93
|
+
/**
|
|
94
|
+
* Returns the current gradient configuration of the radial gradient layer.
|
|
95
|
+
*
|
|
96
|
+
* @returns {GradientDefinition} The current gradient configuration.
|
|
97
|
+
*/
|
|
98
|
+
getConfig(): GradientDefinition;
|
|
99
|
+
/**
|
|
100
|
+
* Checks if the gradient needs to be updated based on the provided specification.
|
|
101
|
+
*
|
|
102
|
+
* @param {GradientDefinition} spec - The gradient specification to compare with the current gradient.
|
|
103
|
+
* @returns {boolean} True if the gradient needs to be updated, false otherwise.
|
|
104
|
+
*/
|
|
105
|
+
shouldUpdate(newSpec?: GradientDefinition): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Animates the radial gradient into view by gradually scaling from 0 to the target scale.
|
|
108
|
+
*
|
|
109
|
+
* This method uses requestAnimationFrame to create a smooth scaling animation effect.
|
|
110
|
+
* During each frame, it:
|
|
111
|
+
* 1. Interpolates the scale value between 0 and the target scale
|
|
112
|
+
* 2. Increments the animation progress (animationDelta)
|
|
113
|
+
* 3. Triggers a map repaint
|
|
114
|
+
*
|
|
115
|
+
* @private
|
|
116
|
+
* @returns {Promise<void>} A promise that resolves when the animation completes
|
|
117
|
+
*/
|
|
118
|
+
private animateIn;
|
|
119
|
+
/**
|
|
120
|
+
* Animates the radial gradient layer out by gradually reducing its scale to zero.
|
|
121
|
+
*
|
|
122
|
+
* This method creates a smooth transition effect by linearly interpolating the scale
|
|
123
|
+
* from its current value to zero over multiple animation frames. During each frame,
|
|
124
|
+
* the animation progresses by incrementing the internal animation delta value.
|
|
125
|
+
*
|
|
126
|
+
* The map is repainted after each animation step to reflect the updated scale.
|
|
127
|
+
*
|
|
128
|
+
* @private
|
|
129
|
+
* @returns A Promise that resolves when the animation is complete.
|
|
130
|
+
*/
|
|
131
|
+
private animateOut;
|
|
132
|
+
onRemove(_map: MapSDK, gl: WebGLRenderingContext | WebGL2RenderingContext): void;
|
|
133
|
+
prerender(_gl: WebGLRenderingContext | WebGL2RenderingContext, _options: CustomRenderMethodInput): void;
|
|
134
|
+
render(gl: WebGLRenderingContext | WebGL2RenderingContext, options: CustomRenderMethodInput): void;
|
|
135
|
+
/**
|
|
136
|
+
* Sets a new gradient for the radial gradient layer and animates the transition.
|
|
137
|
+
*
|
|
138
|
+
* This method first animates the current gradient out, then updates the gradient
|
|
139
|
+
* property with the new gradient definition, and finally animates the new gradient in.
|
|
140
|
+
*
|
|
141
|
+
* @param {GradientDefinition} gradient - The new gradient definition to set for this layer.
|
|
142
|
+
* @returns {Promise<void>} A promise that resolves when the new gradient is set and animated in.
|
|
143
|
+
*/
|
|
144
|
+
setGradient(gradient: GradientDefinition | boolean): Promise<void>;
|
|
145
|
+
setAnimationActive(active: boolean): void;
|
|
146
|
+
show(): void;
|
|
147
|
+
hide(): void;
|
|
148
|
+
}
|
|
149
|
+
export declare function validateHaloSpecification(halo: RadialGradientLayerConstructorOptions | boolean): Array<string>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Object3D } from '../../utils/webgl-utils';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a color string. Can be any valid CSS color format such as hex (#RRGGBB),
|
|
4
|
+
* RGB/RGBA (rgb(r, g, b) / rgba(r, g, b, a)), HSL/HSLA, or named colors (e.g., 'red', 'blue').
|
|
5
|
+
* Used within RadialGradientLayer implementations.
|
|
6
|
+
*/
|
|
7
|
+
export type GradientStopColor = string;
|
|
8
|
+
/**
|
|
9
|
+
* Represents a position in a radial gradient.
|
|
10
|
+
* The numeric value typically indicates the position along the gradient where a color stop should be placed.
|
|
11
|
+
* Usually normalized between 0 and 1, where 0 represents the center of the gradient and 1 represents the outer edge.
|
|
12
|
+
*/
|
|
13
|
+
export type GradientStop = number;
|
|
14
|
+
/**
|
|
15
|
+
* Options for constructing a RadialGradientLayer.
|
|
16
|
+
* This type is an alias for {@link GradientDefinition}, which defines the properties
|
|
17
|
+
* needed to create a radial gradient visualization on a map.
|
|
18
|
+
*/
|
|
19
|
+
export type RadialGradientLayerConstructorOptions = GradientDefinition;
|
|
20
|
+
/**
|
|
21
|
+
* Defines a gradient for use in a radial gradient layer.
|
|
22
|
+
*
|
|
23
|
+
* @typedef {Object} GradientDefinition
|
|
24
|
+
* @property {Array<[GradientStop, GradientStopColor]>} stops - Array of gradient stops, where each stop is a tuple containing a position and a color
|
|
25
|
+
* @property {number} scale - Scale factor that affects the size/reach of the gradient
|
|
26
|
+
*/
|
|
27
|
+
export type GradientDefinition = {
|
|
28
|
+
stops: Array<[GradientStop, GradientStopColor]>;
|
|
29
|
+
scale: number;
|
|
30
|
+
};
|
|
31
|
+
export type GradientAttributeKey = "vertexPosition";
|
|
32
|
+
/**
|
|
33
|
+
* Keys for gradient uniform values used in the RadialGradientLayer.
|
|
34
|
+
*
|
|
35
|
+
* @typedef {string} GradientUniformKey
|
|
36
|
+
* @property {"stopsNumber"} stopsNumber - Key for the number of stops in the gradient.
|
|
37
|
+
* @property {"stops"} stops - Key for the positions of color stops in the gradient.
|
|
38
|
+
* @property {"colors"} colors - Key for the color values at each stop in the gradient.
|
|
39
|
+
*/
|
|
40
|
+
export type GradientUniformKey = "stopsNumber" | "stops" | "colors";
|
|
41
|
+
/**
|
|
42
|
+
* Represents a subset of a 3D object used for gradient rendering.
|
|
43
|
+
*
|
|
44
|
+
* This type picks only the essential properties from Object3D that are needed
|
|
45
|
+
* for rendering radial gradients.
|
|
46
|
+
*
|
|
47
|
+
* @template GradientAttributeKey - The type defining attribute keys for the gradient
|
|
48
|
+
* @template GradientUniformKey - The type defining uniform keys for the gradient
|
|
49
|
+
*/
|
|
50
|
+
export type GradientPlaneObject3D = Pick<Object3D<GradientAttributeKey, GradientUniformKey>, "shaderProgram" | "programInfo" | "positionBuffer">;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Map as MapSDK } from '../Map';
|
|
2
|
+
import { StyleSpecification } from 'maplibre-gl';
|
|
3
|
+
import { CubemapLayerConstructorOptions, RadialGradientLayerConstructorOptions } from '../custom-layers';
|
|
4
|
+
export type StyleSpecificationWithMetaData = StyleSpecification & {
|
|
5
|
+
metadata?: {
|
|
6
|
+
"maptiler:copyright": string;
|
|
7
|
+
maptiler?: {
|
|
8
|
+
halo: RadialGradientLayerConstructorOptions;
|
|
9
|
+
space: CubemapLayerConstructorOptions;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export interface IExtractCustomLayerStyleOptions {
|
|
14
|
+
map: MapSDK;
|
|
15
|
+
property: "halo" | "space";
|
|
16
|
+
}
|
|
17
|
+
export default function extractCustomLayerStyle<T extends CubemapLayerConstructorOptions | RadialGradientLayerConstructorOptions | null>(options: IExtractCustomLayerStyleOptions): T | null;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RadialGradientLayer } from './RadialGradientLayer';
|
|
2
|
+
import { CubemapLayer } from './CubemapLayer';
|
|
3
|
+
export { RadialGradientLayer, CubemapLayer };
|
|
4
|
+
export * from './RadialGradientLayer/types';
|
|
5
|
+
export * from './CubemapLayer/types';
|
|
6
|
+
export type { StyleSpecificationWithMetaData } from './extractCustomLayerStyle';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Map as MapSDK } from '../Map';
|
|
2
|
+
/**
|
|
3
|
+
* Takes a screenshot (PNG file) of the curent map view.
|
|
4
|
+
* Depending on the options, this function can automatically trigger a download of te file.
|
|
5
|
+
*/
|
|
6
|
+
export declare function takeScreenshot(map: MapSDK, options?: {
|
|
7
|
+
/**
|
|
8
|
+
* If `true`, this function will trigger a download in addition to returning a blob.
|
|
9
|
+
* Default: `false`
|
|
10
|
+
*/
|
|
11
|
+
download?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Only if `options.download` is `true`. Indicates the filename under which
|
|
14
|
+
* the file will be downloaded.
|
|
15
|
+
* Default: `"maptiler_screenshot.png"`
|
|
16
|
+
*/
|
|
17
|
+
filename?: string;
|
|
18
|
+
}): Promise<Blob>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DataDrivenPropertyValueSpecification, ExpressionSpecification } from 'maplibre-gl';
|
|
2
|
+
import { ColorRamp } from '../ColorRamp';
|
|
3
|
+
import { DataDrivenStyle, PropertyValues, ZoomNumberValues, ZoomStringValues } from './vectorlayerhelpers';
|
|
4
|
+
export type ColorPalette = [string, string, string, string];
|
|
5
|
+
export declare const colorPalettes: Array<ColorPalette>;
|
|
6
|
+
export declare function getRandomColor(): string;
|
|
7
|
+
export declare function generateRandomSourceName(): string;
|
|
8
|
+
export declare function generateRandomLayerName(): string;
|
|
9
|
+
/**
|
|
10
|
+
* Linera interpolation to find a value at an arbitrary zoom level, given a list of tuple zoom-value
|
|
11
|
+
*/
|
|
12
|
+
export declare function lerpZoomNumberValues(znv: ZoomNumberValues, z: number): number;
|
|
13
|
+
export declare function paintColorOptionsToPaintSpec(color: ZoomStringValues): DataDrivenPropertyValueSpecification<string>;
|
|
14
|
+
export declare function rampedOptionsToLayerPaintSpec(ramp: ZoomNumberValues): DataDrivenPropertyValueSpecification<number>;
|
|
15
|
+
export declare function computeRampedOutlineWidth(lineWidth: number | ZoomNumberValues, outlineWidth: number | ZoomNumberValues): number | DataDrivenPropertyValueSpecification<number>;
|
|
16
|
+
export declare function rampedPropertyValueWeight(ramp: PropertyValues, property: string): DataDrivenPropertyValueSpecification<number>;
|
|
17
|
+
/**
|
|
18
|
+
* Create a dash array from a string pattern that uses underscore and whitespace characters
|
|
19
|
+
*/
|
|
20
|
+
export declare function dashArrayMaker(pattern: string): Array<number>;
|
|
21
|
+
export declare function colorDrivenByProperty(style: DataDrivenStyle, property: string): DataDrivenPropertyValueSpecification<string>;
|
|
22
|
+
export declare function radiusDrivenByProperty(style: DataDrivenStyle, property: string, zoomCompensation?: boolean): DataDrivenPropertyValueSpecification<number>;
|
|
23
|
+
export declare function radiusDrivenByPropertyHeatmap(style: PropertyValues, property: string, zoomCompensation?: boolean): DataDrivenPropertyValueSpecification<number>;
|
|
24
|
+
/**
|
|
25
|
+
* Turns a ColorRamp instance into a MapLibre style for ramping the opacity, driven by a property
|
|
26
|
+
*/
|
|
27
|
+
export declare function opacityDrivenByProperty(colorramp: ColorRamp, property: string): DataDrivenPropertyValueSpecification<number>;
|
|
28
|
+
export declare function heatmapIntensityFromColorRamp(colorRamp: ColorRamp, steps?: number): ExpressionSpecification;
|