@maptiler/sdk 3.8.0-rc8 → 3.8.0

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.
@@ -13,12 +13,31 @@ export type ImageViewerEaseToOptions = Omit<EaseToOptions, "pitch"> & {
13
13
  center: [number, number];
14
14
  };
15
15
  export type ImageViewerConstructorOptions = Pick<MapOptions, AllowedConstrcutorOptions> & {
16
+ /**
17
+ * The UUID of the image.
18
+ */
16
19
  imageUUID: string;
20
+ /**
21
+ * Whether to show debug information.
22
+ */
17
23
  debug?: boolean;
24
+ /**
25
+ * The center of the image.
26
+ */
18
27
  center?: [number, number];
28
+ /**
29
+ * Whether to show a control to fit the image to the viewport.
30
+ */
19
31
  fitToBoundsControl?: boolean;
32
+ /**
33
+ * Whether to show a navigation control.
34
+ */
20
35
  navigationControl?: boolean;
21
36
  };
37
+ /**
38
+ * The metadata of the image. This is the shape of the response from the API.
39
+ * And used to convert px to lnglat and vice versa.
40
+ */
22
41
  export type ImageMetadata = {
23
42
  id: string;
24
43
  description: string;
@@ -82,6 +101,22 @@ export default class ImageViewer extends Evented {
82
101
  * The constructor for the ImageViewer.
83
102
  *
84
103
  * @param {Partial<ImageViewerConstructorOptions>} imageViewerConstructorOptions - The options for the ImageViewer.
104
+ * @example
105
+ * ```ts
106
+ * import "@maptiler/sdk/dist/maptiler-sdk.css"; // import css
107
+ * import { ImageViewer } from "@maptiler/sdk"; // import the sdk
108
+ *
109
+ * const imageViewer = new ImageViewer({
110
+ * container: document.getElementById("map"),
111
+ * imageUUID: "01986025-ceb9-7487-9ea6-7a8637dcc1a1",
112
+ * debug: true, // show tile boundaries, padding, collision boxes etc
113
+ * fitToBoundsControl: true, // show a control to fit the image to the viewport
114
+ * navigationControl: true, // show a navigation control
115
+ * center: [0, 0], // center in pixels
116
+ * zoom: 1, // zoom level
117
+ * bearing: 0, // bearing
118
+ * });
119
+ * ```
85
120
  */
86
121
  constructor(imageViewerConstructorOptions: Partial<ImageViewerConstructorOptions>);
87
122
  /**
@@ -275,32 +310,32 @@ export default class ImageViewer extends Evented {
275
310
  */
276
311
  getZoom(): number;
277
312
  /**
278
- * Get the center of the ImageViewer.
313
+ * Get the center of the ImageViewer in pixels.
279
314
  *
280
315
  * @internal
281
316
  * @returns {[number, number]} The center of the ImageViewer.
282
317
  */
283
318
  getCenter(): [number, number];
284
319
  /**
285
- * Set the center of the ImageViewer.
320
+ * Set the center of the ImageViewer in pixels.
286
321
  *
287
322
  * @param {number} center - The center of the ImageViewer.
288
323
  */
289
324
  setCenter(center: [number, number]): void;
290
325
  /**
291
- * Set the bearing of the ImageViewer.
326
+ * Set the bearing of the ImageViewer in degrees.
292
327
  *
293
328
  * @param {number} bearing - The bearing of the ImageViewer.
294
329
  */
295
330
  setBearing(bearing: number): void;
296
331
  /**
297
- * Get the bearing of the ImageViewer.
332
+ * Get the bearing of the ImageViewer in degrees.
298
333
  *
299
334
  * @returns {number} The bearing of the ImageViewer.
300
335
  */
301
336
  getBearing(): number;
302
337
  /**
303
- * Pan by a given delta.
338
+ * Pan by a given delta in pixels.
304
339
  *
305
340
  * @param {PointLike} delta - The delta to pan by.
306
341
  * @param {ImageViewerEaseToOptions} options - The options for the pan.
@@ -308,7 +343,7 @@ export default class ImageViewer extends Evented {
308
343
  */
309
344
  panBy(delta: PointLike, options?: ImageViewerEaseToOptions, eventData?: any): void;
310
345
  /**
311
- * Pan to a given center.
346
+ * Pan to a given center in pixels.
312
347
  *
313
348
  * @param {number} center - The center to pan to.
314
349
  * @param {ImageViewerEaseToOptions} options - The options for the pan.
package/dist/src/Map.d.ts CHANGED
@@ -90,6 +90,10 @@ export type MapOptions = Omit<MapOptionsML, "style" | "maplibreLogo"> & {
90
90
  * Show the full screen control. (default: `false`, will show if `true`)
91
91
  */
92
92
  fullscreenControl?: boolean | ControlPosition;
93
+ /**
94
+ * Detect custom external controls. (default: `false`, will detect automatically if `true`)
95
+ */
96
+ customControls?: boolean | string;
93
97
  /**
94
98
  * Display a minimap in a user defined corner of the map. (default: `bottom-left` corner)
95
99
  * If set to true, the map will assume it is a minimap and forego the attribution control.
@@ -151,7 +155,33 @@ export declare class Map extends maplibregl.Map {
151
155
  * If an option is not set it will internally revert to the default option
152
156
  * unless explicitly set when calling.
153
157
  */
154
- setSpace(space: CubemapDefinition): void;
158
+ setSpace(space: CubemapDefinition | boolean): void;
159
+ /**
160
+ * Enables the animations for the space layer.
161
+ */
162
+ enableSpaceAnimations(): void;
163
+ /**
164
+ * Disables the animations for the space layer.
165
+ */
166
+ disableSpaceAnimations(): void;
167
+ /**
168
+ * Enables the animations for the halo layer.
169
+ */
170
+ enableHaloAnimations(): void;
171
+ /**
172
+ * Disables the animations for the halo layer.
173
+ */
174
+ disableHaloAnimations(): void;
175
+ /**
176
+ * Sets whether the halo layer should be animated in and out.
177
+ * @param active - Whether the animation should be active.
178
+ */
179
+ setHaloAnimationActive(active: boolean): void;
180
+ /**
181
+ * Sets whether the space layer should be animated in and out.
182
+ * @param active - Whether the animation should be active.
183
+ */
184
+ setSpaceAnimationActive(active: boolean): void;
155
185
  private setSpaceFromStyle;
156
186
  private setHaloFromStyle;
157
187
  private initSpace;
@@ -0,0 +1,17 @@
1
+ import { Map as SDKMap } from '../Map';
2
+ import { IControl, MapLibreEvent } from 'maplibre-gl';
3
+ export type MaptilerCustomControlCallback<E> = (map: SDKMap, element: HTMLElement, event: E) => void;
4
+ /**
5
+ * The MaptilerCustomControl allows any existing element to become a map control.
6
+ */
7
+ export declare class MaptilerCustomControl implements IControl {
8
+ #private;
9
+ /**
10
+ * @param selectorOrElement Element to be used as control, specified as either reference to element itself or a CSS selector to find the element in DOM
11
+ * @param onClick Function called when the element is clicked
12
+ * @param onRender Function called every time the underlying map renders a new state
13
+ */
14
+ constructor(selectorOrElement: string | HTMLElement, onClick?: MaptilerCustomControlCallback<Event>, onRender?: MaptilerCustomControlCallback<MapLibreEvent>);
15
+ onAdd(map: SDKMap): HTMLElement;
16
+ onRemove(): void;
17
+ }
@@ -0,0 +1,25 @@
1
+ import { Map as SDKMap } from '../Map';
2
+ import { IControl } from 'maplibre-gl';
3
+ import { MaptilerCustomControl, MaptilerCustomControlCallback } from './MaptilerCustomControl';
4
+ export type MaptilerExternalControlType = "zoom-in" | "zoom-out" | "toggle-projection" | "toggle-terrain" | "reset-view" | "reset-bearing" | "reset-pitch" | "reset-roll";
5
+ /**
6
+ * The MaptilerExternalControl allows any existing element to automatically become a map control. Used for detected controls if `customControls` config is turned on.
7
+ */
8
+ export declare class MaptilerExternalControl extends MaptilerCustomControl implements IControl {
9
+ #private;
10
+ static controlCallbacks: Record<MaptilerExternalControlType, MaptilerCustomControlCallback<Event>>;
11
+ /**
12
+ * Constructs an instance of External Control to have a predefined functionality
13
+ * @param controlElement Element to be used as control, specified as reference to element itself
14
+ * @param controlType One of the predefined types of functionality
15
+ */
16
+ constructor(controlElement: HTMLElement, controlType?: MaptilerExternalControlType);
17
+ onAdd(map: SDKMap): HTMLElement;
18
+ onRemove(): void;
19
+ /**
20
+ * Configure a child element to be part of this control and to have a predefined functionality added
21
+ * @param controlElement Element that is a descendant of the control element and that optionally should have some functionality
22
+ * @param controlType One of the predefined types of functionality
23
+ */
24
+ configureGroupItem(controlElement: HTMLElement, controlType: MaptilerExternalControlType | undefined): void;
25
+ }
@@ -12,3 +12,4 @@ export declare class MaptilerProjectionControl implements IControl {
12
12
  private toggleProjection;
13
13
  private updateProjectionIcon;
14
14
  }
15
+ export declare function toggleProjection(map: SDKMap): void;
@@ -14,3 +14,4 @@ export declare class MaptilerTerrainControl implements IControl {
14
14
  _toggleTerrain(): void;
15
15
  _updateTerrainIcon(): void;
16
16
  }
17
+ export declare function toggleTerrain(map: SDKMap): void;
@@ -1,3 +1,5 @@
1
+ export * from './MaptilerCustomControl';
2
+ export * from './MaptilerExternalControl';
1
3
  export * from './MaptilerGeolocateControl';
2
4
  export * from './MaptilerLogoControl';
3
5
  export * from './MaptilerTerrainControl';
@@ -96,6 +96,7 @@ declare class CubemapLayer implements CustomLayerInterface {
96
96
  * @private
97
97
  */
98
98
  private options;
99
+ private animationActive;
99
100
  /**
100
101
  * Creates a new instance of CubemapLayer
101
102
  *
@@ -186,6 +187,7 @@ declare class CubemapLayer implements CustomLayerInterface {
186
187
  * @private
187
188
  */
188
189
  private animateOut;
190
+ setAnimationActive(active: boolean): void;
189
191
  /**
190
192
  * Renders the cubemap layer to the WebGL context.
191
193
  * This method is called internally during the rendering phase of the map.
@@ -214,7 +216,7 @@ declare class CubemapLayer implements CustomLayerInterface {
214
216
  * and if so, it updates the cubemap faces.
215
217
  * Finally, it calls `updateCubemap` to apply the changes and trigger a repaint of the map.
216
218
  */
217
- setCubemap(cubemap: CubemapDefinition): Promise<void>;
219
+ setCubemap(spec: CubemapDefinition | boolean): Promise<void>;
218
220
  /**
219
221
  * Shows the cubemap layer by setting its visibility to "visible".
220
222
  * This method is used to make the cubemap layer visible on the map.
@@ -226,5 +228,5 @@ declare class CubemapLayer implements CustomLayerInterface {
226
228
  */
227
229
  hide(): void;
228
230
  }
229
- export declare function validateSpaceSpecification(space: CubemapDefinition | boolean): boolean;
231
+ export declare function validateSpaceSpecification(space?: CubemapDefinition | boolean): boolean;
230
232
  export { CubemapLayer };
@@ -67,6 +67,12 @@ export declare class RadialGradientLayer implements CustomLayerInterface {
67
67
  * @type {Object3D<(typeof ATTRIBUTES_KEYS)[number], (typeof UNIFORMS_KEYS)[number]>}
68
68
  */
69
69
  private plane?;
70
+ /**
71
+ * Whether the halo should be animated in and out.
72
+ * @private
73
+ * @type {boolean}
74
+ */
75
+ private animationActive;
70
76
  /**
71
77
  * Creates a new RadialGradientLayer instance.
72
78
  *
@@ -128,7 +134,8 @@ export declare class RadialGradientLayer implements CustomLayerInterface {
128
134
  * @param {GradientDefinition} gradient - The new gradient definition to set for this layer.
129
135
  * @returns {Promise<void>} A promise that resolves when the new gradient is set and animated in.
130
136
  */
131
- setGradient(gradient: GradientDefinition): Promise<void>;
137
+ setGradient(gradient: GradientDefinition | boolean): Promise<void>;
138
+ setAnimationActive(active: boolean): void;
132
139
  show(): void;
133
140
  hide(): void;
134
141
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maptiler/sdk",
3
- "version": "3.8.0-rc8",
3
+ "version": "3.8.0",
4
4
  "description": "The Javascript & TypeScript map SDK tailored for MapTiler Cloud",
5
5
  "author": "MapTiler",
6
6
  "module": "dist/maptiler-sdk.mjs",
@@ -86,14 +86,11 @@
86
86
  "vitest": "^3.0.9"
87
87
  },
88
88
  "dependencies": {
89
- "@koa/cors": "^5.0.0",
90
- "@koa/router": "^13.1.1",
91
89
  "@maplibre/maplibre-gl-style-spec": "~23.3.0",
92
- "@maptiler/client": "~2.5.0",
90
+ "@maptiler/client": "~2.5.1",
93
91
  "events": "^3.3.0",
94
92
  "gl-matrix": "^3.4.3",
95
93
  "js-base64": "^3.7.7",
96
- "koa": "^3.0.0",
97
94
  "maplibre-gl": "~5.6.0",
98
95
  "uuid": "^11.0.5"
99
96
  }