@maptiler/sdk 3.8.0-rc8 → 3.9.0-rc.1

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.
@@ -1,8 +1,10 @@
1
- import { DoubleClickZoomHandler, DragPanHandler, EaseToOptions, PointLike, TwoFingersTouchZoomRotateHandler, default as MapLibre } from 'maplibre-gl';
2
- import { FlyToOptions, MapDataEvent, MapOptions, JumpToOptions, ScrollZoomHandler, BoxZoomHandler, KeyboardHandler, CooperativeGesturesHandler } from '..';
1
+ import { default as MaplibreGL } from 'maplibre-gl';
2
+ import { EaseToOptions, DoubleClickZoomHandler, DragPanHandler, TwoFingersTouchZoomRotateHandler, FlyToOptions, MapOptions, JumpToOptions, ScrollZoomHandler, BoxZoomHandler, KeyboardHandler, CooperativeGesturesHandler, LngLat, MapDataEvent, PointLike } from '..';
3
3
  import { Map } from '../Map';
4
+ import { ImageViewerFitImageToBoundsControl } from '../controls/ImageViewerFitImageToBoundsControl';
5
+ import { lngLatToPxInternalSymbolKey, pxToLngLatInternalSymbolKey, sdkSymbolKey } from './symbols';
6
+ declare const Evented: typeof MaplibreGL.Evented;
4
7
  export type AllowedConstrcutorOptions = "container" | "apiKey" | "maxZoom" | "minZoom" | "zoom" | "bearing";
5
- declare const Evented: typeof MapLibre.Evented;
6
8
  export type ImageViewerFlyToOptions = Omit<FlyToOptions, "pitch"> & {
7
9
  center: [number, number];
8
10
  };
@@ -13,12 +15,31 @@ export type ImageViewerEaseToOptions = Omit<EaseToOptions, "pitch"> & {
13
15
  center: [number, number];
14
16
  };
15
17
  export type ImageViewerConstructorOptions = Pick<MapOptions, AllowedConstrcutorOptions> & {
18
+ /**
19
+ * The UUID of the image.
20
+ */
16
21
  imageUUID: string;
22
+ /**
23
+ * Whether to show debug information.
24
+ */
17
25
  debug?: boolean;
26
+ /**
27
+ * The center of the image.
28
+ */
18
29
  center?: [number, number];
30
+ /**
31
+ * Whether to show a control to fit the image to the viewport.
32
+ */
19
33
  fitToBoundsControl?: boolean;
34
+ /**
35
+ * Whether to show a navigation control.
36
+ */
20
37
  navigationControl?: boolean;
21
38
  };
39
+ /**
40
+ * The metadata of the image. This is the shape of the response from the API.
41
+ * And used to convert px to lnglat and vice versa.
42
+ */
22
43
  export type ImageMetadata = {
23
44
  id: string;
24
45
  description: string;
@@ -45,7 +66,6 @@ export default class ImageViewer extends Evented {
45
66
  /**
46
67
  * The metadata of the image.
47
68
  *
48
- * @internal
49
69
  */
50
70
  private imageMetadata?;
51
71
  /**
@@ -55,7 +75,7 @@ export default class ImageViewer extends Evented {
55
75
  * We do not want to have to extend the Map class and give access to
56
76
  * methods and properties that operate in LngLat space. *
57
77
  */
58
- private sdk;
78
+ [sdkSymbolKey]: Map;
59
79
  /**
60
80
  * The options for the ImageViewer.
61
81
  *
@@ -78,10 +98,30 @@ export default class ImageViewer extends Evented {
78
98
  * The version of the ImageViewer / SDK.
79
99
  */
80
100
  get version(): string;
101
+ /**
102
+ * The control to fit the image to the viewport.
103
+ */
104
+ fitToBoundsControlInstance: ImageViewerFitImageToBoundsControl;
81
105
  /**
82
106
  * The constructor for the ImageViewer.
83
107
  *
84
108
  * @param {Partial<ImageViewerConstructorOptions>} imageViewerConstructorOptions - The options for the ImageViewer.
109
+ * @example
110
+ * ```ts
111
+ * import "@maptiler/sdk/dist/maptiler-sdk.css"; // import css
112
+ * import { ImageViewer } from "@maptiler/sdk"; // import the sdk
113
+ *
114
+ * const imageViewer = new ImageViewer({
115
+ * container: document.getElementById("map"),
116
+ * imageUUID: "01986025-ceb9-7487-9ea6-7a8637dcc1a1",
117
+ * debug: true, // show tile boundaries, padding, collision boxes etc
118
+ * fitToBoundsControl: true, // show a control to fit the image to the viewport
119
+ * navigationControl: true, // show a navigation control
120
+ * center: [0, 0], // center in pixels
121
+ * zoom: 1, // zoom level
122
+ * bearing: 0, // bearing
123
+ * });
124
+ * ```
85
125
  */
86
126
  constructor(imageViewerConstructorOptions: Partial<ImageViewerConstructorOptions>);
87
127
  /**
@@ -253,21 +293,24 @@ export default class ImageViewer extends Evented {
253
293
  *
254
294
  * @param {ImageViewerFlyToOptions} options - The options for the fly to.
255
295
  * @param {MapDataEvent} eventData - The event data.
296
+ * @returns {ImageViewer} The ImageViewer instance.
256
297
  */
257
- flyTo(options: ImageViewerFlyToOptions, eventData?: MapDataEvent): Map;
298
+ flyTo(options: ImageViewerFlyToOptions, eventData?: MapDataEvent): this;
258
299
  /**
259
300
  * Jump to a given center.
260
301
  *
261
302
  * @param {ImageViewerJumpToOptions} options - The options for the jump to.
262
303
  * @param {MapDataEvent} eventData - The event data.
304
+ * @returns {ImageViewer} The ImageViewer instance.
263
305
  */
264
- jumpTo(options: ImageViewerJumpToOptions, eventData?: MapDataEvent): Map;
306
+ jumpTo(options: ImageViewerJumpToOptions, eventData?: MapDataEvent): this;
265
307
  /**
266
308
  * Set the zoom level.
267
309
  *
268
310
  * @param {number} zoom - The zoom level.
311
+ * @returns {ImageViewer} The ImageViewer instance.
269
312
  */
270
- setZoom(zoom: number): void;
313
+ setZoom(zoom: number): this;
271
314
  /**
272
315
  * Get the zoom level.
273
316
  *
@@ -275,45 +318,78 @@ export default class ImageViewer extends Evented {
275
318
  */
276
319
  getZoom(): number;
277
320
  /**
278
- * Get the center of the ImageViewer.
321
+ * Get the center of the ImageViewer in pixels.
279
322
  *
280
323
  * @internal
281
324
  * @returns {[number, number]} The center of the ImageViewer.
282
325
  */
283
326
  getCenter(): [number, number];
284
327
  /**
285
- * Set the center of the ImageViewer.
328
+ * Set the center of the ImageViewer in pixels.
286
329
  *
287
330
  * @param {number} center - The center of the ImageViewer.
331
+ * @returns {ImageViewer} The ImageViewer instance.
288
332
  */
289
- setCenter(center: [number, number]): void;
333
+ setCenter(center: [number, number]): this;
290
334
  /**
291
- * Set the bearing of the ImageViewer.
335
+ * Set the bearing of the ImageViewer in degrees.
292
336
  *
293
337
  * @param {number} bearing - The bearing of the ImageViewer.
338
+ * @returns {ImageViewer} The ImageViewer instance.
294
339
  */
295
- setBearing(bearing: number): void;
340
+ setBearing(bearing: number): this;
296
341
  /**
297
- * Get the bearing of the ImageViewer.
342
+ * Get the bearing of the ImageViewer in degrees.
298
343
  *
299
344
  * @returns {number} The bearing of the ImageViewer.
300
345
  */
301
346
  getBearing(): number;
302
347
  /**
303
- * Pan by a given delta.
348
+ * Pan by a given delta in pixels.
304
349
  *
305
350
  * @param {PointLike} delta - The delta to pan by.
306
351
  * @param {ImageViewerEaseToOptions} options - The options for the pan.
307
352
  * @param {any} eventData - The event data.
353
+ * @returns {ImageViewer} The ImageViewer instance.
308
354
  */
309
- panBy(delta: PointLike, options?: ImageViewerEaseToOptions, eventData?: any): void;
355
+ panBy(delta: PointLike, options?: ImageViewerEaseToOptions, eventData?: any): this;
310
356
  /**
311
- * Pan to a given center.
357
+ * Pan to a given center in pixels.
312
358
  *
313
359
  * @param {number} center - The center to pan to.
314
360
  * @param {ImageViewerEaseToOptions} options - The options for the pan.
315
361
  * @param {any} eventData - The event data.
362
+ * @returns {ImageViewer} The ImageViewer instance.
363
+ */
364
+ panTo(center: [number, number], options?: ImageViewerEaseToOptions, eventData?: any): this;
365
+ /**
366
+ * Get the image metadata.
367
+ *
368
+ * @returns {ImageMetadata} The image metadata.
369
+ */
370
+ getImageMetadata(): ImageMetadata | undefined;
371
+ /**
372
+ * Get the visible bounds of the image in the viewport in imagePixels.
373
+ * [topLeft, bottomRight]
374
+ *
375
+ * @returns {[[number, number], [number, number]]} The visible bounds of the image.
376
+ */
377
+ getImageBounds(): number[][];
378
+ /**
379
+ * Set the bounds of the image.
380
+ *
381
+ * @param {[[number, number], [number, number]]} bounds - The bounds of the image.
382
+ * @returns {ImageViewer} The ImageViewer instance.
383
+ */
384
+ fitImageBounds([tl, br]: [[number, number], [number, number]]): this;
385
+ /**
386
+ * Destroys the ImageViewer, removes the map instance and all event listeners. Useful for cleanup.
387
+ *
388
+ * @returns {ImageViewer} The ImageViewer instance.
316
389
  */
317
- panTo(center: [number, number], options?: ImageViewerEaseToOptions, eventData?: any): void;
390
+ remove(): void;
391
+ pointIsWithinImageBounds(px: [number, number]): boolean;
392
+ [lngLatToPxInternalSymbolKey]: (lngLat: LngLat) => [number, number];
393
+ [pxToLngLatInternalSymbolKey]: (px: [number, number]) => LngLat;
318
394
  }
319
395
  export {};
@@ -0,0 +1,236 @@
1
+ import { Alignment, Subscription, MarkerOptions, PointLike, Popup } from '../index';
2
+ import { default as MapLibreGL } from 'maplibre-gl';
3
+ import { default as ImageViewer } from './ImageViewer';
4
+ declare const Evented: typeof MapLibreGL.Evented;
5
+ export type ImageViewerMarkerOptions = MarkerOptions & {};
6
+ export interface ImageViewerMarkerInterface {
7
+ on(event: MarkerEventTypes, listener: (e: ImageViewerMarkerEvent) => void): Subscription;
8
+ off(event: MarkerEventTypes, listener: (e: ImageViewerMarkerEvent) => void): void;
9
+ fire(event: ImageViewerMarkerEvent): void;
10
+ getPosition(): [number, number];
11
+ getOffset(): PointLike;
12
+ getPitchAlignment(): Alignment;
13
+ getPopup(): Popup;
14
+ getRotation(): number;
15
+ getRotationAlignment(): Alignment;
16
+ isDraggable(): boolean;
17
+ remove(): void;
18
+ removeClassName(className: string): void;
19
+ setDraggable(draggable: boolean): void;
20
+ setPosition(px: [number, number]): void;
21
+ setOffset(offset: PointLike): void;
22
+ setOpacity(opacity?: string, opacityWhenCovered?: string): void;
23
+ setPitchAlignment(pitchAlignment: Alignment): void;
24
+ setPopup(popup: Popup): void;
25
+ setRotation(rotation: number): void;
26
+ setRotationAlignment(rotationAlignment: Alignment): void;
27
+ setSubpixelPositioning(subpixelPositioning: boolean): void;
28
+ toggleClassName(className: string): void;
29
+ togglePopup(): void;
30
+ }
31
+ export declare class ImageViewerMarker extends Evented {
32
+ private viewer;
33
+ private readonly marker;
34
+ private readonly position;
35
+ constructor({ ...markerOptions }: ImageViewerMarkerOptions);
36
+ /**
37
+ * Adds the ImageViewerMarker to an instance of ImageViewer.
38
+ *
39
+ * @param {ImageViewer} viewer - The instance of ImageViewer to add the ImageViewerMarker to.
40
+ * @returns {ImageViewerMarker} The ImageViewerMarker instance.
41
+ */
42
+ addTo(viewer: ImageViewer): this;
43
+ /**
44
+ * Adds a class name to the ImageViewerMarker.
45
+ *
46
+ * @param {string} className - The class name to add to the ImageViewerMarker.
47
+ * @returns {ImageViewerMarker} The ImageViewerMarker instance.
48
+ */
49
+ addClassName(className: string): this;
50
+ /**
51
+ * Gets the element of the ImageViewerMarker.
52
+ *
53
+ * @returns {HTMLElement} The element of the ImageViewerMarker.
54
+ */
55
+ getElement(): HTMLElement;
56
+ /**
57
+ * Gets the position of the ImageViewerMarker.
58
+ *
59
+ * @returns {PointLike} The position of the ImageViewerMarker.
60
+ * @see [PointLike](https://docs.maptiler.com/sdk-js/api/geography/#pointlike)
61
+ *
62
+ */
63
+ getPosition(): [number, number];
64
+ /**
65
+ * Gets the offset of the ImageViewerMarker.
66
+ *
67
+ * @returns {PointLike} The offset of the ImageViewerMarker.
68
+ * @see [PointLike](https://docs.maptiler.com/sdk-js/api/geography/#pointlike)
69
+ */
70
+ getOffset(): MapLibreGL.Point;
71
+ /**
72
+ * Gets the pitch alignment of the ImageViewerMarker.
73
+ *
74
+ * @returns {Alignment} The pitch alignment of the ImageViewerMarker.
75
+ * @see [MapLibreGL.Alignment](https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/Alignment/)
76
+ */
77
+ getPitchAlignment(): Alignment;
78
+ /**
79
+ * Gets the popup of the ImageViewerMarker.
80
+ *
81
+ * @returns {Popup} The popup of the ImageViewerMarker.
82
+ * @see [Popup](https://docs.maptiler.com/sdk-js/api/markers/#popup)
83
+ */
84
+ getPopup(): MapLibreGL.Popup;
85
+ /**
86
+ * Gets the rotation of the ImageViewerMarker.
87
+ *
88
+ * @returns {number} The rotation of the ImageViewerMarker.
89
+ */
90
+ getRotation(): number;
91
+ /**
92
+ * Gets the rotation alignment of the ImageViewerMarker.
93
+ *
94
+ * @returns {Alignment} The rotation alignment of the ImageViewerMarker.
95
+ * @see [MapLibreGL.Alignment](https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/Alignment/)
96
+ */
97
+ getRotationAlignment(): Alignment;
98
+ /**
99
+ * Checks if the ImageViewerMarker is draggable.
100
+ *
101
+ * @returns {boolean} True if the ImageViewerMarker is draggable, false otherwise.
102
+ */
103
+ isDraggable(): boolean;
104
+ /**
105
+ * Fires an event on the ImageViewerMarker.
106
+ *
107
+ * @param {MarkerEventTypes | Event} event - The event to fire.
108
+ * @param {Record<string, any>} data - The data to fire the event with.
109
+ * @returns {ImageViewerMarker} The ImageViewerMarker instance.
110
+ */
111
+ fire(event: MarkerEventTypes | Event, data?: Record<string, any>): this;
112
+ /**
113
+ * Removes an event listener from the ImageViewerMarker.
114
+ *
115
+ * @param {MarkerEventTypes} event - The event to remove the listener from.
116
+ * @param {ImageViewerMarkerEvent} listener - The listener to remove.
117
+ * @returns {ImageViewerMarker} The ImageViewerMarker instance.
118
+ */
119
+ off(event: MarkerEventTypes, listener: (e: ImageViewerMarkerEvent) => void): this;
120
+ /**
121
+ * Adds an event listener to the ImageViewerMarker.
122
+ *
123
+ * @param {MarkerEventTypes} event - The event to add the listener to.
124
+ * @param {ImageViewerMarkerEvent} listener - The listener to add.
125
+ * @returns {ImageViewerMarker} The ImageViewerMarker instance.
126
+ */
127
+ on(event: MarkerEventTypes, listener: (e: ImageViewerMarkerEvent) => void): Subscription;
128
+ /**
129
+ * Checks if the ImageViewerMarker is within the image bounds.
130
+ *
131
+ * @returns {boolean} True if the ImageViewerMarker is within the image bounds, false otherwise.
132
+ */
133
+ isWithinImageBounds(): boolean;
134
+ /**
135
+ * Removes the ImageViewerMarker from the ImageViewer and cleans up the event listeners.
136
+ *
137
+ * @returns {ImageViewerMarker} The ImageViewerMarker instance.
138
+ */
139
+ remove(): this;
140
+ /**
141
+ * Removes a class name from the ImageViewerMarker dom element.
142
+ *
143
+ * @param {string} className - The class name to remove from the ImageViewerMarker.
144
+ * @returns {ImageViewerMarker} The ImageViewerMarker instance.
145
+ */
146
+ removeClassName(className: string): this;
147
+ /**
148
+ * Sets the draggable state of the ImageViewerMarker.
149
+ *
150
+ * @param {boolean} draggable - The draggable state of the ImageViewerMarker.
151
+ * @returns {ImageViewerMarker} The ImageViewerMarker instance.
152
+ */
153
+ setDraggable(draggable: boolean): this;
154
+ /**
155
+ * Sets the position of the ImageViewerMarker.
156
+ *
157
+ * @param {[number, number]} px - The position of the ImageViewerMarker in image pixels.
158
+ * @returns {ImageViewerMarker} The ImageViewerMarker instance.
159
+ */
160
+ setPosition(px: [number, number]): this;
161
+ /**
162
+ * Sets the offset of the ImageViewerMarker.
163
+ *
164
+ * @param {PointLike} offset - The offset of the ImageViewerMarker.
165
+ * @returns {ImageViewerMarker} The ImageViewerMarker instance.
166
+ */
167
+ setOffset(offset: PointLike): this;
168
+ /**
169
+ * Sets the opacity of the ImageViewerMarker.
170
+ *
171
+ * @param {string} opacity - The opacity of the ImageViewerMarker.
172
+ * @param {string} opacityWhenCovered - The opacity of the ImageViewerMarker when covered.
173
+ * @returns {ImageViewerMarker} The ImageViewerMarker instance.
174
+ */
175
+ setOpacity(opacity?: string, opacityWhenCovered?: string): this;
176
+ /**
177
+ * Sets the pitch alignment of the ImageViewerMarker.
178
+ *
179
+ * @param {Alignment} pitchAlignment - The pitch alignment of the ImageViewerMarker.
180
+ * @returns {ImageViewerMarker} The ImageViewerMarker instance.
181
+ * @see [MapLibreGL.Alignment](https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/Alignment/)
182
+ */
183
+ setPitchAlignment(pitchAlignment: Alignment): this;
184
+ /**
185
+ * Sets the popup of the ImageViewerMarker.
186
+ *
187
+ * @param {Popup} popup - The popup of the ImageViewerMarker.
188
+ * @returns {ImageViewerMarker} The ImageViewerMarker instance.
189
+ * @see [Popup](https://docs.maptiler.com/sdk-js/api/markers/#popup)
190
+ */
191
+ setPopup(popup: Popup): this;
192
+ /**
193
+ * Sets the rotation of the ImageViewerMarker.
194
+ *
195
+ * @param {number} rotation - The rotation of the ImageViewerMarker.
196
+ * @returns {ImageViewerMarker} The ImageViewerMarker instance.
197
+ */
198
+ setRotation(rotation: number): this;
199
+ /**
200
+ * Sets the rotation alignment of the ImageViewerMarker.
201
+ *
202
+ * @param {Alignment} rotationAlignment - The rotation alignment of the ImageViewerMarker.
203
+ * @returns {ImageViewerMarker} The ImageViewerMarker instance.
204
+ * @see [MapLibreGL.Alignment](https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/Alignment/)
205
+ */
206
+ setRotationAlignment(rotationAlignment: Alignment): this;
207
+ /**
208
+ * Sets if subpixel positioning is enabled for the ImageViewerMarker.
209
+ *
210
+ * @param {boolean} subpixelPositioning - The subpixel positioning of the ImageViewerMarker.
211
+ * @returns {ImageViewerMarker} The ImageViewerMarker instance.
212
+ */
213
+ setSubpixelPositioning(subpixelPositioning: boolean): this;
214
+ /**
215
+ * Toggles a class name on the ImageViewerMarker dom element.
216
+ *
217
+ * @param {string} className - The class name to toggle on the ImageViewerMarker.
218
+ * @returns {ImageViewerMarker} The ImageViewerMarker instance.
219
+ */
220
+ toggleClassName(className: string): this;
221
+ /**
222
+ * Toggles the popup of the ImageViewerMarker.
223
+ *
224
+ * @returns {ImageViewerMarker} The ImageViewerMarker instance.
225
+ */
226
+ togglePopup(): this;
227
+ }
228
+ declare const MARKER_EVENT_TYPES: readonly ["dragstart", "drag", "dragend"];
229
+ type MarkerEventTypes = (typeof MARKER_EVENT_TYPES)[number];
230
+ export declare class ImageViewerMarkerEvent {
231
+ readonly type: string;
232
+ readonly target: ImageViewerMarker;
233
+ [key: string]: any;
234
+ constructor(type: MarkerEventTypes, marker: ImageViewerMarker, data: Record<string, any>);
235
+ }
236
+ export {};
@@ -6,6 +6,9 @@ export declare class ImageViewerEvent {
6
6
  readonly target: ImageViewer;
7
7
  readonly originalEvent: MouseEvent | TouchEvent | WheelEvent | WebGLContextEvent | null;
8
8
  [key: string]: any;
9
+ imageX: number;
10
+ imageY: number;
11
+ isOutOfBounds: boolean;
9
12
  constructor(type: string, viewer: ImageViewer, originalEvent?: MouseEvent | TouchEvent | WheelEvent | WebGLContextEvent | null, data?: Record<string, any>);
10
13
  }
11
14
  declare const BASE_MAP_EVENT_TYPES: readonly ["idle", "render", "load", "remove", "idle"];
@@ -16,7 +19,7 @@ declare const CAMERA_EVENTS: readonly ["moveend", "movestart", "move", "zoomend"
16
19
  declare const UI_EVENTS: readonly ["click", "dblclick", "mousedown", "mouseup", "mousemove", "mouseout", "mouseover", "contextmenu", "touchstart", "touchend", "touchmove", "touchcancel"];
17
20
  declare const COOPERATIVE_GESTURE_EVENTS: readonly ["cooperativegestureprevented"];
18
21
  declare const DATA_EVENTS: readonly ["data", "dataloading", "sourcedata", "sourcedataloading", "dataabort", "sourcedataabort"];
19
- export declare const IMAGE_VIEWER_EVENT_TYPES: ("data" | "error" | "load" | "idle" | "remove" | "render" | "resize" | "webglcontextlost" | "webglcontextrestored" | "dataloading" | "sourcedataloading" | "sourcedata" | "dataabort" | "sourcedataabort" | "boxzoomcancel" | "boxzoomstart" | "boxzoomend" | "touchcancel" | "touchmove" | "touchend" | "touchstart" | "click" | "contextmenu" | "dblclick" | "mousemove" | "mouseup" | "mousedown" | "mouseout" | "mouseover" | "movestart" | "move" | "moveend" | "zoomstart" | "zoom" | "zoomend" | "rotatestart" | "rotate" | "rotateend" | "dragstart" | "drag" | "dragend" | "cooperativegestureprevented")[];
22
+ export declare const IMAGE_VIEWER_EVENT_TYPES: ("error" | "load" | "idle" | "remove" | "render" | "resize" | "webglcontextlost" | "webglcontextrestored" | "dataloading" | "data" | "sourcedataloading" | "sourcedata" | "dataabort" | "sourcedataabort" | "boxzoomcancel" | "boxzoomstart" | "boxzoomend" | "touchcancel" | "touchmove" | "touchend" | "touchstart" | "click" | "contextmenu" | "dblclick" | "mousemove" | "mouseup" | "mousedown" | "mouseout" | "mouseover" | "movestart" | "move" | "moveend" | "zoomstart" | "zoom" | "zoomend" | "rotatestart" | "rotate" | "rotateend" | "dragstart" | "drag" | "dragend" | "cooperativegestureprevented")[];
20
23
  type BaseMapEventKeys = (typeof BASE_MAP_EVENT_TYPES)[number];
21
24
  type UiEventKeys = (typeof UI_EVENTS)[number];
22
25
  type CameraEventKeys = (typeof CAMERA_EVENTS)[number];
@@ -25,7 +28,7 @@ type ResizeEventKeys = (typeof RESIZE_EVENTS)[number];
25
28
  type WebglContextEventKeys = (typeof WEBGL_CONTEXT_EVENTS)[number];
26
29
  type DataEventKeys = (typeof DATA_EVENTS)[number];
27
30
  type CooperativeGestureEventKeys = (typeof COOPERATIVE_GESTURE_EVENTS)[number];
28
- export type ImageViewerEventTypes = BaseMapEventKeys | UiEventKeys | CameraEventKeys | ErrorEventKeys | ResizeEventKeys | WebglContextEventKeys | DataEventKeys | CooperativeGestureEventKeys | "imageviewerready" | "imagevieweriniterror";
31
+ export type ImageViewerEventTypes = BaseMapEventKeys | UiEventKeys | CameraEventKeys | ErrorEventKeys | ResizeEventKeys | WebglContextEventKeys | DataEventKeys | CooperativeGestureEventKeys | "imageviewerready" | "imagevieweriniterror" | "beforeremove";
29
32
  type LngLatToPixel = (lngLat: LngLat) => [number, number];
30
33
  interface SetupGlobalMapEventForwarderOptions {
31
34
  map: Map;
@@ -1,4 +1,5 @@
1
1
  export { default as ImageViewer } from './ImageViewer';
2
+ export { ImageViewerMarker } from './ImageViewerMarker';
2
3
  export type { ImageViewerEventTypes } from './events';
3
4
  export type { ImageViewerConstructorOptions, ImageViewerFlyToOptions, ImageViewerJumpToOptions, ImageMetadata } from './ImageViewer';
4
5
  export { ImageViewerEvent } from './events';
@@ -0,0 +1,3 @@
1
+ export declare const sdkSymbolKey: unique symbol;
2
+ export declare const lngLatToPxInternalSymbolKey: unique symbol;
3
+ export declare const pxToLngLatInternalSymbolKey: unique symbol;
package/dist/src/Map.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { default as maplibregl, StyleSpecification, MapOptions as MapOptionsML, ControlPosition, StyleSwapOptions, StyleOptions, RequestTransformFunction, LayerSpecification, SourceSpecification, CustomLayerInterface, FilterSpecification, StyleSetterOptions } from 'maplibre-gl';
1
+ import { default as maplibregl, StyleSpecification, MapOptions as MapOptionsML, ControlPosition, StyleSwapOptions, StyleOptions, RequestTransformFunction, LayerSpecification, SourceSpecification, CustomLayerInterface, FilterSpecification, StyleSetterOptions, ProjectionSpecification } from 'maplibre-gl';
2
2
  import { ReferenceMapStyle, MapStyleVariant } from '@maptiler/client';
3
3
  import { SdkConfig } from './config';
4
4
  import { LanguageInfo } from './language';
@@ -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, updateOptions?: 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;
@@ -409,6 +439,15 @@ export declare class Map extends maplibregl.Map {
409
439
  * map.setTransformRequest((url: string, resourceType: string) => {});
410
440
  */
411
441
  setTransformRequest(transformRequest: RequestTransformFunction): this;
442
+ /**
443
+ * Gets the {@link ProjectionSpecification}.
444
+ * @returns the projection specification.
445
+ * @example
446
+ * ```ts
447
+ * let projection = map.getProjection();
448
+ * ```
449
+ */
450
+ getProjection(): ProjectionSpecification;
412
451
  /**
413
452
  * Returns whether a globe projection is currently being used
414
453
  */
@@ -421,6 +460,7 @@ export declare class Map extends maplibregl.Map {
421
460
  * Activate the mercator projection.
422
461
  */
423
462
  enableMercatorProjection(): void;
463
+ setProjection(projection: maplibregl.ProjectionSpecification): this;
424
464
  /**
425
465
  * Returns `true` is the language was ever updated, meaning changed
426
466
  * from what is delivered in the style.
@@ -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 };