@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,408 @@
|
|
|
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
|
+
import { Map } from '../Map';
|
|
4
|
+
import { ImageViewerFitImageToBoundsControl } from '../controls/ImageViewerFitImageToBoundsControl';
|
|
5
|
+
import { lngLatToPxInternalSymbolKey, pxToLngLatInternalSymbolKey } from './symbols';
|
|
6
|
+
declare const Evented: typeof MaplibreGL.Evented;
|
|
7
|
+
export type AllowedConstrcutorOptions = "container" | "apiKey" | "maxZoom" | "minZoom" | "zoom" | "bearing";
|
|
8
|
+
export type ImageViewerFlyToOptions = Omit<FlyToOptions, "pitch"> & {
|
|
9
|
+
center: [number, number];
|
|
10
|
+
};
|
|
11
|
+
export type ImageViewerJumpToOptions = Omit<JumpToOptions, "pitch"> & {
|
|
12
|
+
center: [number, number];
|
|
13
|
+
};
|
|
14
|
+
export type ImageViewerEaseToOptions = Omit<EaseToOptions, "pitch"> & {
|
|
15
|
+
center: [number, number];
|
|
16
|
+
};
|
|
17
|
+
export type ImageViewerConstructorOptions = Pick<MapOptions, AllowedConstrcutorOptions> & {
|
|
18
|
+
/**
|
|
19
|
+
* The UUID of the image.
|
|
20
|
+
*/
|
|
21
|
+
imageUUID: string;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to show debug information.
|
|
24
|
+
*/
|
|
25
|
+
debug?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The center of the image.
|
|
28
|
+
*/
|
|
29
|
+
center?: [number, number];
|
|
30
|
+
/**
|
|
31
|
+
* Whether to show a control to fit the image to the viewport.
|
|
32
|
+
*/
|
|
33
|
+
fitToBoundsControl?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether to show a navigation control.
|
|
36
|
+
*/
|
|
37
|
+
navigationControl?: boolean;
|
|
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
|
+
*/
|
|
43
|
+
export type ImageMetadata = {
|
|
44
|
+
id: string;
|
|
45
|
+
description: string;
|
|
46
|
+
attribution: string;
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
minzoom: number;
|
|
50
|
+
maxzoom: number;
|
|
51
|
+
tileSize: number;
|
|
52
|
+
};
|
|
53
|
+
export default class ImageViewer extends Evented {
|
|
54
|
+
/**
|
|
55
|
+
* The UUID of the image.
|
|
56
|
+
*
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
private imageUUID;
|
|
60
|
+
/**
|
|
61
|
+
* Whether to enable debug mode.
|
|
62
|
+
*
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
private debug;
|
|
66
|
+
/**
|
|
67
|
+
* The metadata of the image.
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
private imageMetadata?;
|
|
71
|
+
/**
|
|
72
|
+
* Why not extend the Map class?
|
|
73
|
+
* Because ImageViewer technically operates in screen space and not in map space.
|
|
74
|
+
* We wrap map and perform calculations in screen space.
|
|
75
|
+
* We do not want to have to extend the Map class and give access to
|
|
76
|
+
* methods and properties that operate in LngLat space. *
|
|
77
|
+
*/
|
|
78
|
+
private sdk;
|
|
79
|
+
/**
|
|
80
|
+
* The options for the ImageViewer.
|
|
81
|
+
*
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
private options;
|
|
85
|
+
/**
|
|
86
|
+
* The size of the image.
|
|
87
|
+
*
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
private imageSize?;
|
|
91
|
+
/**
|
|
92
|
+
* The padded size max.
|
|
93
|
+
*
|
|
94
|
+
* @internal
|
|
95
|
+
*/
|
|
96
|
+
private paddedSizeMax?;
|
|
97
|
+
/**
|
|
98
|
+
* The version of the ImageViewer / SDK.
|
|
99
|
+
*/
|
|
100
|
+
get version(): string;
|
|
101
|
+
/**
|
|
102
|
+
* The control to fit the image to the viewport.
|
|
103
|
+
*/
|
|
104
|
+
fitToBoundsControlInstance: ImageViewerFitImageToBoundsControl;
|
|
105
|
+
/**
|
|
106
|
+
* The constructor for the ImageViewer.
|
|
107
|
+
*
|
|
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
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
constructor(imageViewerConstructorOptions: Partial<ImageViewerConstructorOptions>);
|
|
127
|
+
/**
|
|
128
|
+
* Waits for the ImageViewer to be ready.
|
|
129
|
+
*
|
|
130
|
+
* @returns {Promise<void>}
|
|
131
|
+
*/
|
|
132
|
+
onReadyAsync(): Promise<void>;
|
|
133
|
+
shouldFitImageToViewport: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Initializes the ImageViewer
|
|
136
|
+
* - fetches the image metadata
|
|
137
|
+
* - adds the image source to the sdk instance
|
|
138
|
+
* - sets the center to the middle of the image (if center is not provided)
|
|
139
|
+
* - monkeypatches the maplibre-gl sdk transform method to allow for overpanning and underzooming.
|
|
140
|
+
* - sets up global event forwarding / intercepting from the map instance
|
|
141
|
+
* - sets the center to the middle of the image (if center is not provided)
|
|
142
|
+
*
|
|
143
|
+
* @internal
|
|
144
|
+
* @returns {Promise<void>}
|
|
145
|
+
*/
|
|
146
|
+
private init;
|
|
147
|
+
/**
|
|
148
|
+
* Fits the image to the viewport.
|
|
149
|
+
*
|
|
150
|
+
* @param {Object} options - The options for the fit image to viewport.
|
|
151
|
+
* @param {boolean} options.ease - Whether to ease to the viewport bounds.
|
|
152
|
+
*/
|
|
153
|
+
fitImageToViewport({ ease }?: {
|
|
154
|
+
ease?: boolean;
|
|
155
|
+
}): void;
|
|
156
|
+
/**
|
|
157
|
+
* Fetches the image metadata from the API.
|
|
158
|
+
*
|
|
159
|
+
* @internal
|
|
160
|
+
* @returns {Promise<void>}
|
|
161
|
+
*/
|
|
162
|
+
private fetchImageMetadata;
|
|
163
|
+
/**
|
|
164
|
+
* Adds the image source to the sdk instance.
|
|
165
|
+
*
|
|
166
|
+
* @internal
|
|
167
|
+
* @returns {void}
|
|
168
|
+
*/
|
|
169
|
+
private addImageSource;
|
|
170
|
+
/**
|
|
171
|
+
* Triggers a repaint of the ImageViewer. Same as map.triggerRepaint().
|
|
172
|
+
*
|
|
173
|
+
* @internal
|
|
174
|
+
* @returns {void}
|
|
175
|
+
*/
|
|
176
|
+
triggerRepaint(): void;
|
|
177
|
+
/**
|
|
178
|
+
* The scroll zoom handler.
|
|
179
|
+
*
|
|
180
|
+
* @internal
|
|
181
|
+
* @returns {ScrollZoomHandler}
|
|
182
|
+
*/
|
|
183
|
+
get scrollZoom(): ScrollZoomHandler;
|
|
184
|
+
/**
|
|
185
|
+
* The scroll zoom handler.
|
|
186
|
+
*
|
|
187
|
+
* @internal
|
|
188
|
+
* @param {ScrollZoomHandler} value - The scroll zoom handler.
|
|
189
|
+
*/
|
|
190
|
+
set scrollZoom(value: ScrollZoomHandler);
|
|
191
|
+
/**
|
|
192
|
+
* The box zoom handler.
|
|
193
|
+
*
|
|
194
|
+
* @internal
|
|
195
|
+
* @returns {BoxZoomHandler}
|
|
196
|
+
*/
|
|
197
|
+
get boxZoom(): BoxZoomHandler;
|
|
198
|
+
/**
|
|
199
|
+
* The box zoom handler.
|
|
200
|
+
*
|
|
201
|
+
* @internal
|
|
202
|
+
* @param {BoxZoomHandler} value - The box zoom handler.
|
|
203
|
+
*/
|
|
204
|
+
set boxZoom(value: BoxZoomHandler);
|
|
205
|
+
/**
|
|
206
|
+
* The drag pan handler.
|
|
207
|
+
*
|
|
208
|
+
* @internal
|
|
209
|
+
* @returns {DragPanHandler}
|
|
210
|
+
*/
|
|
211
|
+
get dragPan(): DragPanHandler;
|
|
212
|
+
/**
|
|
213
|
+
* The drag pan handler.
|
|
214
|
+
*
|
|
215
|
+
* @internal
|
|
216
|
+
* @param {DragPanHandler} value - The drag pan handler.
|
|
217
|
+
*/
|
|
218
|
+
set dragPan(value: DragPanHandler);
|
|
219
|
+
/**
|
|
220
|
+
* The keyboard handler.
|
|
221
|
+
*
|
|
222
|
+
* @internal
|
|
223
|
+
* @returns {KeyboardHandler}
|
|
224
|
+
*/
|
|
225
|
+
get keyboard(): KeyboardHandler;
|
|
226
|
+
/**
|
|
227
|
+
* The keyboard handler.
|
|
228
|
+
*
|
|
229
|
+
* @internal
|
|
230
|
+
* @param {KeyboardHandler} value - The keyboard handler.
|
|
231
|
+
*/
|
|
232
|
+
set keyboard(value: KeyboardHandler);
|
|
233
|
+
/**
|
|
234
|
+
* The double click zoom handler.
|
|
235
|
+
*
|
|
236
|
+
* @internal
|
|
237
|
+
* @returns {DoubleClickZoomHandler}
|
|
238
|
+
*/
|
|
239
|
+
get doubleClickZoom(): DoubleClickZoomHandler;
|
|
240
|
+
/**
|
|
241
|
+
* The double click zoom handler.
|
|
242
|
+
*
|
|
243
|
+
* @internal
|
|
244
|
+
* @param {DoubleClickZoomHandler} value - The double click zoom handler.
|
|
245
|
+
*/
|
|
246
|
+
set doubleClickZoom(value: DoubleClickZoomHandler);
|
|
247
|
+
/**
|
|
248
|
+
* The touch zoom rotate handler.
|
|
249
|
+
*
|
|
250
|
+
* @internal
|
|
251
|
+
* @returns {TwoFingersTouchZoomRotateHandler}
|
|
252
|
+
*/
|
|
253
|
+
get touchZoomRotate(): TwoFingersTouchZoomRotateHandler;
|
|
254
|
+
/**
|
|
255
|
+
* The touch zoom rotate handler.
|
|
256
|
+
*
|
|
257
|
+
* @internal
|
|
258
|
+
* @param {TwoFingersTouchZoomRotateHandler} value - The touch zoom rotate handler.
|
|
259
|
+
*/
|
|
260
|
+
set touchZoomRotate(value: TwoFingersTouchZoomRotateHandler);
|
|
261
|
+
/**
|
|
262
|
+
* The cooperative gestures handler.
|
|
263
|
+
*
|
|
264
|
+
* @internal
|
|
265
|
+
* @returns {CooperativeGesturesHandler}
|
|
266
|
+
*/
|
|
267
|
+
get cooperativeGestures(): CooperativeGesturesHandler;
|
|
268
|
+
/**
|
|
269
|
+
* The cooperative gestures handler.
|
|
270
|
+
*
|
|
271
|
+
* @internal
|
|
272
|
+
* @param {CooperativeGesturesHandler} value - The cooperative gestures handler.
|
|
273
|
+
*/
|
|
274
|
+
set cooperativeGestures(value: CooperativeGesturesHandler);
|
|
275
|
+
/**
|
|
276
|
+
* Converts a LngLat to a px coordinate, based on the image metadata.
|
|
277
|
+
*
|
|
278
|
+
* @internal
|
|
279
|
+
* @param {LngLat} lngLat - The LngLat to convert.
|
|
280
|
+
* @returns {[number, number]} The px coordinate.
|
|
281
|
+
*/
|
|
282
|
+
private lngLatToPx;
|
|
283
|
+
/**
|
|
284
|
+
* Converts a px coordinate to a LngLat, based on the image metadata.
|
|
285
|
+
*
|
|
286
|
+
* @internal
|
|
287
|
+
* @param {LngLat} lngLat - The LngLat to convert.
|
|
288
|
+
* @returns {[number, number]} The px coordinate.
|
|
289
|
+
*/
|
|
290
|
+
private pxToLngLat;
|
|
291
|
+
/**
|
|
292
|
+
* Get the internal SDK instance.
|
|
293
|
+
*
|
|
294
|
+
* @returns {Map} The internal SDK instance.
|
|
295
|
+
* @internal
|
|
296
|
+
*/
|
|
297
|
+
getSDKInternal(): Map;
|
|
298
|
+
/**
|
|
299
|
+
* Get the canvas of the internal SDK instance.
|
|
300
|
+
*
|
|
301
|
+
* @returns {HTMLCanvasElement} The canvas of the internal SDK instance.
|
|
302
|
+
*/
|
|
303
|
+
getCanvas(): HTMLCanvasElement;
|
|
304
|
+
/**
|
|
305
|
+
* Fly to a given center.
|
|
306
|
+
*
|
|
307
|
+
* @param {ImageViewerFlyToOptions} options - The options for the fly to.
|
|
308
|
+
* @param {MapDataEvent} eventData - The event data.
|
|
309
|
+
* @returns {ImageViewer} The ImageViewer instance.
|
|
310
|
+
*/
|
|
311
|
+
flyTo(options: ImageViewerFlyToOptions, eventData?: MapDataEvent): this;
|
|
312
|
+
/**
|
|
313
|
+
* Jump to a given center.
|
|
314
|
+
*
|
|
315
|
+
* @param {ImageViewerJumpToOptions} options - The options for the jump to.
|
|
316
|
+
* @param {MapDataEvent} eventData - The event data.
|
|
317
|
+
* @returns {ImageViewer} The ImageViewer instance.
|
|
318
|
+
*/
|
|
319
|
+
jumpTo(options: ImageViewerJumpToOptions, eventData?: MapDataEvent): this;
|
|
320
|
+
/**
|
|
321
|
+
* Set the zoom level.
|
|
322
|
+
*
|
|
323
|
+
* @param {number} zoom - The zoom level.
|
|
324
|
+
* @returns {ImageViewer} The ImageViewer instance.
|
|
325
|
+
*/
|
|
326
|
+
setZoom(zoom: number): this;
|
|
327
|
+
/**
|
|
328
|
+
* Get the zoom level.
|
|
329
|
+
*
|
|
330
|
+
* @returns {number} The zoom level.
|
|
331
|
+
*/
|
|
332
|
+
getZoom(): number;
|
|
333
|
+
/**
|
|
334
|
+
* Get the center of the ImageViewer in pixels.
|
|
335
|
+
*
|
|
336
|
+
* @internal
|
|
337
|
+
* @returns {[number, number]} The center of the ImageViewer.
|
|
338
|
+
*/
|
|
339
|
+
getCenter(): [number, number];
|
|
340
|
+
/**
|
|
341
|
+
* Set the center of the ImageViewer in pixels.
|
|
342
|
+
*
|
|
343
|
+
* @param {number} center - The center of the ImageViewer.
|
|
344
|
+
* @returns {ImageViewer} The ImageViewer instance.
|
|
345
|
+
*/
|
|
346
|
+
setCenter(center: [number, number]): this;
|
|
347
|
+
/**
|
|
348
|
+
* Set the bearing of the ImageViewer in degrees.
|
|
349
|
+
*
|
|
350
|
+
* @param {number} bearing - The bearing of the ImageViewer.
|
|
351
|
+
* @returns {ImageViewer} The ImageViewer instance.
|
|
352
|
+
*/
|
|
353
|
+
setBearing(bearing: number): this;
|
|
354
|
+
/**
|
|
355
|
+
* Get the bearing of the ImageViewer in degrees.
|
|
356
|
+
*
|
|
357
|
+
* @returns {number} The bearing of the ImageViewer.
|
|
358
|
+
*/
|
|
359
|
+
getBearing(): number;
|
|
360
|
+
/**
|
|
361
|
+
* Pan by a given delta in pixels.
|
|
362
|
+
*
|
|
363
|
+
* @param {PointLike} delta - The delta to pan by.
|
|
364
|
+
* @param {ImageViewerEaseToOptions} options - The options for the pan.
|
|
365
|
+
* @param {any} eventData - The event data.
|
|
366
|
+
* @returns {ImageViewer} The ImageViewer instance.
|
|
367
|
+
*/
|
|
368
|
+
panBy(delta: PointLike, options?: ImageViewerEaseToOptions, eventData?: any): this;
|
|
369
|
+
/**
|
|
370
|
+
* Pan to a given center in pixels.
|
|
371
|
+
*
|
|
372
|
+
* @param {number} center - The center to pan to.
|
|
373
|
+
* @param {ImageViewerEaseToOptions} options - The options for the pan.
|
|
374
|
+
* @param {any} eventData - The event data.
|
|
375
|
+
* @returns {ImageViewer} The ImageViewer instance.
|
|
376
|
+
*/
|
|
377
|
+
panTo(center: [number, number], options?: ImageViewerEaseToOptions, eventData?: any): this;
|
|
378
|
+
/**
|
|
379
|
+
* Get the image metadata.
|
|
380
|
+
*
|
|
381
|
+
* @returns {ImageMetadata} The image metadata.
|
|
382
|
+
*/
|
|
383
|
+
getImageMetadata(): ImageMetadata | undefined;
|
|
384
|
+
/**
|
|
385
|
+
* Get the visible bounds of the image in the viewport in imagePixels.
|
|
386
|
+
* [topLeft, bottomRight]
|
|
387
|
+
*
|
|
388
|
+
* @returns {[[number, number], [number, number]]} The visible bounds of the image.
|
|
389
|
+
*/
|
|
390
|
+
getImageBounds(): number[][];
|
|
391
|
+
/**
|
|
392
|
+
* Set the bounds of the image.
|
|
393
|
+
*
|
|
394
|
+
* @param {[[number, number], [number, number]]} bounds - The bounds of the image.
|
|
395
|
+
* @returns {ImageViewer} The ImageViewer instance.
|
|
396
|
+
*/
|
|
397
|
+
fitImageBounds([tl, br]: [[number, number], [number, number]]): this;
|
|
398
|
+
/**
|
|
399
|
+
* Destroys the ImageViewer, removes the map instance and all event listeners. Useful for cleanup.
|
|
400
|
+
*
|
|
401
|
+
* @returns {ImageViewer} The ImageViewer instance.
|
|
402
|
+
*/
|
|
403
|
+
remove(): void;
|
|
404
|
+
pointIsWithinImageBounds(px: [number, number]): boolean;
|
|
405
|
+
[lngLatToPxInternalSymbolKey]: (lngLat: LngLat) => [number, number];
|
|
406
|
+
[pxToLngLatInternalSymbolKey]: (px: [number, number]) => LngLat;
|
|
407
|
+
}
|
|
408
|
+
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 {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Map } from '../Map';
|
|
2
|
+
import { default as ImageViewer } from './ImageViewer';
|
|
3
|
+
import { LngLat } from 'maplibre-gl';
|
|
4
|
+
export declare class ImageViewerEvent {
|
|
5
|
+
readonly type: string;
|
|
6
|
+
readonly target: ImageViewer;
|
|
7
|
+
readonly originalEvent: MouseEvent | TouchEvent | WheelEvent | WebGLContextEvent | null;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
imageX: number;
|
|
10
|
+
imageY: number;
|
|
11
|
+
isOutOfBounds: boolean;
|
|
12
|
+
constructor(type: string, viewer: ImageViewer, originalEvent?: MouseEvent | TouchEvent | WheelEvent | WebGLContextEvent | null, data?: Record<string, any>);
|
|
13
|
+
}
|
|
14
|
+
declare const BASE_MAP_EVENT_TYPES: readonly ["idle", "render", "load", "remove", "idle"];
|
|
15
|
+
declare const ERROR_EVENTS: readonly ["error"];
|
|
16
|
+
declare const RESIZE_EVENTS: readonly ["resize"];
|
|
17
|
+
declare const WEBGL_CONTEXT_EVENTS: readonly ["webglcontextlost", "webglcontextrestored"];
|
|
18
|
+
declare const CAMERA_EVENTS: readonly ["moveend", "movestart", "move", "zoomend", "zoomstart", "zoom", "rotatestart", "rotateend", "rotate", "dragstart", "dragend", "drag", "boxzoomcancel", "boxzoomend", "boxzoomstart"];
|
|
19
|
+
declare const UI_EVENTS: readonly ["click", "dblclick", "mousedown", "mouseup", "mousemove", "mouseout", "mouseover", "contextmenu", "touchstart", "touchend", "touchmove", "touchcancel"];
|
|
20
|
+
declare const COOPERATIVE_GESTURE_EVENTS: readonly ["cooperativegestureprevented"];
|
|
21
|
+
declare const DATA_EVENTS: readonly ["data", "dataloading", "sourcedata", "sourcedataloading", "dataabort", "sourcedataabort"];
|
|
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")[];
|
|
23
|
+
type BaseMapEventKeys = (typeof BASE_MAP_EVENT_TYPES)[number];
|
|
24
|
+
type UiEventKeys = (typeof UI_EVENTS)[number];
|
|
25
|
+
type CameraEventKeys = (typeof CAMERA_EVENTS)[number];
|
|
26
|
+
type ErrorEventKeys = (typeof ERROR_EVENTS)[number];
|
|
27
|
+
type ResizeEventKeys = (typeof RESIZE_EVENTS)[number];
|
|
28
|
+
type WebglContextEventKeys = (typeof WEBGL_CONTEXT_EVENTS)[number];
|
|
29
|
+
type DataEventKeys = (typeof DATA_EVENTS)[number];
|
|
30
|
+
type CooperativeGestureEventKeys = (typeof COOPERATIVE_GESTURE_EVENTS)[number];
|
|
31
|
+
export type ImageViewerEventTypes = BaseMapEventKeys | UiEventKeys | CameraEventKeys | ErrorEventKeys | ResizeEventKeys | WebglContextEventKeys | DataEventKeys | CooperativeGestureEventKeys | "imageviewerready" | "imagevieweriniterror" | "beforeremove";
|
|
32
|
+
type LngLatToPixel = (lngLat: LngLat) => [number, number];
|
|
33
|
+
interface SetupGlobalMapEventForwarderOptions {
|
|
34
|
+
map: Map;
|
|
35
|
+
viewer: ImageViewer;
|
|
36
|
+
lngLatToPx: LngLatToPixel;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Sets up event forwarding from Map to ImageViewer with proper categorization
|
|
40
|
+
* @param {SetupGlobalMapEventForwarderOptions} options - The options for setting up the event forwarder.
|
|
41
|
+
* @param {Map} options.map - The map to forward events from.
|
|
42
|
+
* @param {ImageViewer} options.viewer - The viewer to forward events to.
|
|
43
|
+
* @param {LngLatToPixel} options.lngLatToPx - A function to convert LngLat to pixel coordinates.
|
|
44
|
+
* @returns {void}
|
|
45
|
+
*/
|
|
46
|
+
export declare function setupGlobalMapEventForwarder({ map, viewer, lngLatToPx }: SetupGlobalMapEventForwarderOptions): void;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as ImageViewer } from './ImageViewer';
|
|
2
|
+
export { ImageViewerMarker, ImageViewerMarkerEvent, type ImageViewerMarkerOptions } from './ImageViewerMarker';
|
|
3
|
+
export type { ImageViewerEventTypes } from './events';
|
|
4
|
+
export type { ImageViewerConstructorOptions, ImageViewerFlyToOptions, ImageViewerJumpToOptions, ImageMetadata } from './ImageViewer';
|
|
5
|
+
export { ImageViewerEvent } from './events';
|