@maptiler/sdk 4.2.0 → 5.0.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.
- package/README.md +98 -29
- package/dist/ImageViewer/ImageViewer.d.ts +6 -8
- package/dist/ImageViewer/ImageViewerMarker.d.ts +9 -9
- package/dist/Map.d.ts +73 -10
- package/dist/bundler/maplibre-gl-worker.mjs +13839 -0
- package/dist/bundler/next-worker.mjs +16 -0
- package/dist/bundler/next.cjs +42 -0
- package/dist/bundler/next.d.ts +6 -0
- package/dist/bundler/next.mjs +48 -0
- package/dist/bundler/side-effect.d.ts +2 -0
- package/dist/bundler/vite-worker.mjs +11 -0
- package/dist/bundler/webpack-worker.mjs +11 -0
- package/dist/constants/defaults.d.ts +0 -1
- package/dist/controls/MaptilerGeolocateControl.d.ts +1 -1
- package/dist/controls/MaptilerLogoControl.d.ts +1 -2
- package/dist/controls/MaptilerNavigationControl.d.ts +3 -4
- package/dist/controls/Minimap.d.ts +3 -3
- package/dist/eslint.mjs +4 -4
- package/dist/index.d.ts +5 -80
- package/dist/mapstyle.d.ts +4 -3
- package/dist/maptiler-sdk.css +1 -1
- package/dist/maptiler-sdk.mjs +3500 -3443
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/tools.d.ts +6 -7
- package/dist/utils/defaultWorkerUrl.d.ts +17 -0
- package/package.json +20 -3
- package/dist/MLAdapters/AttributionControl.d.ts +0 -5
- package/dist/MLAdapters/BoxZoomHandler.d.ts +0 -7
- package/dist/MLAdapters/CanvasSource.d.ts +0 -5
- package/dist/MLAdapters/CooperativeGesturesHandler.d.ts +0 -5
- package/dist/MLAdapters/FullscreenControl.d.ts +0 -5
- package/dist/MLAdapters/GeoJSONSource.d.ts +0 -5
- package/dist/MLAdapters/GeolocateControl.d.ts +0 -5
- package/dist/MLAdapters/ImageSource.d.ts +0 -5
- package/dist/MLAdapters/KeyboardHandler.d.ts +0 -5
- package/dist/MLAdapters/LogoControl.d.ts +0 -5
- package/dist/MLAdapters/MapMouseEvent.d.ts +0 -5
- package/dist/MLAdapters/MapTouchEvent.d.ts +0 -5
- package/dist/MLAdapters/MapWheelEvent.d.ts +0 -5
- package/dist/MLAdapters/Marker.d.ts +0 -5
- package/dist/MLAdapters/NavigationControl.d.ts +0 -5
- package/dist/MLAdapters/Popup.d.ts +0 -5
- package/dist/MLAdapters/RasterDEMTileSource.d.ts +0 -5
- package/dist/MLAdapters/RasterTileSource.d.ts +0 -5
- package/dist/MLAdapters/ScaleControl.d.ts +0 -5
- package/dist/MLAdapters/ScrollZoomHandler.d.ts +0 -5
- package/dist/MLAdapters/Style.d.ts +0 -5
- package/dist/MLAdapters/TerrainControl.d.ts +0 -5
- package/dist/MLAdapters/TwoFingersTouchPitchHandler.d.ts +0 -5
- package/dist/MLAdapters/VectorTileSource.d.ts +0 -5
- package/dist/MLAdapters/VideoSource.d.ts +0 -5
- package/dist/ml-types.d.ts +0 -638
package/README.md
CHANGED
|
@@ -47,7 +47,72 @@ In addition, the MapTiler SDK JS provides well-documented and easy-to-use wrappe
|
|
|
47
47
|
npm install --save @maptiler/sdk
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
⚠️ Please keep in mind that if you use any additional [MapTiler modules](https://docs.maptiler.com/sdk-js/modules/), you must update them to a version that supports MapTiler SDK JS
|
|
50
|
+
⚠️ Please keep in mind that if you use any additional [MapTiler modules](https://docs.maptiler.com/sdk-js/modules/), you must update them to a version that supports MapTiler SDK JS v5.
|
|
51
|
+
|
|
52
|
+
### Setting up the map worker with a bundler
|
|
53
|
+
|
|
54
|
+
Since MapLibre GL JS v6, the map runs its background worker from separate files that most bundlers don't pick up on their own.
|
|
55
|
+
|
|
56
|
+
By default, the SDK installed from npm loads the worker from the MapTiler CDN (`https://cdn.maptiler.com/maptiler-sdk-js/v<VERSION>/`), which works with any bundler. If your site uses a Content Security Policy, it needs `worker-src 'self' blob: https://cdn.maptiler.com`.
|
|
57
|
+
|
|
58
|
+
To bundle the worker with your app instead (e.g. for offline or intranet use, or a stricter CSP), import the helper for your bundler once, before creating a map:
|
|
59
|
+
|
|
60
|
+
**Vite**
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import "@maptiler/sdk/vite-worker";
|
|
64
|
+
import { Map } from "@maptiler/sdk";
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
For the Vite dev server, also exclude the helper from dependency pre-bundling:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
// vite.config.ts
|
|
71
|
+
import { defineConfig } from "vite";
|
|
72
|
+
|
|
73
|
+
export default defineConfig({
|
|
74
|
+
optimizeDeps: { exclude: ["@maptiler/sdk/vite-worker"] },
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**webpack 5 / rspack**
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import "@maptiler/sdk/webpack-worker";
|
|
82
|
+
import { Map } from "@maptiler/sdk";
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Next.js** (Turbopack and webpack)
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
// next.config.mjs (or `require("@maptiler/sdk/next")` in next.config.js)
|
|
89
|
+
import { withMaptilerWorker } from "@maptiler/sdk/next";
|
|
90
|
+
|
|
91
|
+
export default withMaptilerWorker({
|
|
92
|
+
// your Next.js config
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
// the client component creating the map
|
|
98
|
+
"use client";
|
|
99
|
+
import "@maptiler/sdk/next-worker";
|
|
100
|
+
import { Map } from "@maptiler/sdk";
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`withMaptilerWorker` copies the worker files into `public/_maptiler/` on every `next dev` and `next build`, you may want to add that folder to your `.gitignore`.
|
|
104
|
+
|
|
105
|
+
**Other setups**
|
|
106
|
+
|
|
107
|
+
Copy `node_modules/@maptiler/sdk/dist/bundler/maplibre-gl-worker.mjs` into your build output (it is self-contained, and works the same with npm, yarn or pnpm), and set the worker URL before creating a map:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { setWorkerUrl } from "@maptiler/sdk";
|
|
111
|
+
|
|
112
|
+
setWorkerUrl("/path/to/maplibre-gl-worker.mjs");
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### From CDN
|
|
51
116
|
|
|
52
117
|
From CDN and using the UMD bundle, in the `<head></head>` section of your HTML file:
|
|
53
118
|
|
|
@@ -107,37 +172,20 @@ import "@maptiler/sdk/dist/maptiler-sdk.css";
|
|
|
107
172
|
|
|
108
173
|
#### TypeScript
|
|
109
174
|
|
|
110
|
-
The SDK is fully typed,
|
|
111
|
-
|
|
112
|
-
There are mainly two ways to address this issue and access to the complete type definition.
|
|
113
|
-
|
|
114
|
-
1. **With `esModuleInterop`**
|
|
175
|
+
The SDK is fully typed, including the types re-exported from MapLibre GL JS.
|
|
115
176
|
|
|
116
|
-
|
|
177
|
+
The SDK is an ES module whose entry points (such as `@maptiler/sdk/next`) are declared with `package.json` `exports`. TypeScript only reads `exports` with a modern module resolution, so set one of the following in your `tsconfig.json`:
|
|
117
178
|
|
|
118
179
|
```js
|
|
119
180
|
{
|
|
120
181
|
"compilerOptions": {
|
|
121
182
|
// ...
|
|
122
|
-
"
|
|
183
|
+
"moduleResolution": "Bundler", // or "Node16" / "NodeNext"
|
|
123
184
|
}
|
|
124
185
|
}
|
|
125
186
|
```
|
|
126
187
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
Set the following in your `tsconfig.json`:
|
|
130
|
-
|
|
131
|
-
```js
|
|
132
|
-
{
|
|
133
|
-
"compilerOptions": {
|
|
134
|
-
// ...
|
|
135
|
-
"moduleResolution": "Bundler",
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
Note that this second option is not always possible as some frameworks and other dependencies won't let you use the "Bundler" mode.
|
|
188
|
+
With the legacy `"moduleResolution": "Node"` (or `"Node10"`), the main `@maptiler/sdk` types still resolve, but the entry points under `@maptiler/sdk/...` don't get types.
|
|
141
189
|
|
|
142
190
|
### With CDN
|
|
143
191
|
|
|
@@ -163,13 +211,13 @@ The SDK hosted on our CDN is bundled as _[Universal Module Definition](https://g
|
|
|
163
211
|
</style>
|
|
164
212
|
|
|
165
213
|
<!-- Load the SDK CSS -->
|
|
166
|
-
<link rel="stylesheet" href="
|
|
214
|
+
<link rel="stylesheet" href="build/maptiler-sdk.css" />
|
|
167
215
|
</head>
|
|
168
216
|
|
|
169
217
|
<body>
|
|
170
218
|
<div id="map-container"></div>
|
|
171
219
|
|
|
172
|
-
<script src="
|
|
220
|
+
<script src="build/maptiler-sdk.umd.min.js"></script>
|
|
173
221
|
|
|
174
222
|
<script>
|
|
175
223
|
// Add your MapTiler API key to the config
|
|
@@ -190,6 +238,30 @@ The SDK hosted on our CDN is bundled as _[Universal Module Definition](https://g
|
|
|
190
238
|
|
|
191
239
|
Check out the minimalist code samples in the [demos](demos) directory.
|
|
192
240
|
|
|
241
|
+
#### Map worker files and Content Security Policy (CSP)
|
|
242
|
+
|
|
243
|
+
Since MapLibre GL JS v6, the map loads its background worker as two separate files, `maplibre-gl-worker.mjs` and `maplibre-gl-shared.mjs`. The UMD bundle looks for them in the same folder as `maptiler-sdk.umd.min.js`. Our CDN serves them there, so when using the CDN without a CSP, there is nothing to set up.
|
|
244
|
+
|
|
245
|
+
If you **self-host the UMD bundle**, copy both `.mjs` files next to `maptiler-sdk.umd.min.js`. They must be served with a JavaScript content type (e.g. `text/javascript`).
|
|
246
|
+
|
|
247
|
+
If your site uses a **Content Security Policy**, the worker needs to be allowed:
|
|
248
|
+
|
|
249
|
+
- **SDK loaded from our CDN**: since the worker comes from another origin, it is started through a `blob:` URL that then loads the worker from the CDN, so both must be allowed. `blob:` alone is not enough:
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
worker-src 'self' blob: https://cdn.maptiler.com;
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
- **CSP that cannot allow `blob:`**: host `maplibre-gl-worker.mjs` and `maplibre-gl-shared.mjs` on your own origin (in the same folder) and point the SDK to the worker before creating any map. Then `worker-src 'self'` is enough:
|
|
256
|
+
|
|
257
|
+
```html
|
|
258
|
+
<script>
|
|
259
|
+
maptilersdk.setWorkerUrl("/path/to/maplibre-gl-worker.mjs");
|
|
260
|
+
</script>
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
`setWorkerUrl` is also needed if the UMD bundle is not loaded with a regular `<script src="...">` tag (e.g. concatenated into another file or loaded with AMD/RequireJS), since the worker location is then no longer known.
|
|
264
|
+
|
|
193
265
|
<br>
|
|
194
266
|
|
|
195
267
|
## 💡 Related Examples
|
|
@@ -1048,12 +1120,9 @@ Here is a sample of some compatible languages:
|
|
|
1048
1120
|
|
|
1049
1121
|
#### Built-in support for right-to-left languages
|
|
1050
1122
|
|
|
1051
|
-
Languages that are written right-to-left such as Arabic and Hebrew are fully supported by default.
|
|
1052
|
-
|
|
1053
|
-
If you wish to opt of applying the rtl plugin or wish to use a different compatible rtl text plugin, you can pass the `rtlTextPlugin`
|
|
1054
|
-
constructor option as either `false` (disable the rtl plugin) or a url to load a different plugin.
|
|
1123
|
+
Languages that are written right-to-left such as Arabic and Hebrew, as well as complex scripts such as Devanagari, Khmer or Burmese, are fully supported by default. MapLibre shapes them natively, no need to install any plugins!
|
|
1055
1124
|
|
|
1056
|
-
|
|
1125
|
+
If you still need a custom RTL text plugin, `setRTLTextPlugin` is re-exported from MapLibre. Note that it is deprecated by MapLibre and a plugin *replaces* the built-in shaping.
|
|
1057
1126
|
|
|
1058
1127
|
<p align="center">
|
|
1059
1128
|
<img src="images/screenshots/lang-arabic.jpeg" width="48%"></img>
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { EaseToOptions, DoubleClickZoomHandler, DragPanHandler, TwoFingersTouchZoomRotateHandler, FlyToOptions, MapOptions, JumpToOptions, ScrollZoomHandler, BoxZoomHandler, KeyboardHandler, CooperativeGesturesHandler, LngLat, MapDataEvent, PointLike } from '..';
|
|
1
|
+
import { EaseToOptions, DoubleClickZoomHandler, DragPanHandler, TwoFingersTouchZoomRotateHandler, FlyToOptions, MapOptions, JumpToOptions, ScrollZoomHandler, BoxZoomHandler, KeyboardHandler, CooperativeGesturesHandler, LngLat, PointLike } from '..';
|
|
3
2
|
import { Map } from '../Map';
|
|
3
|
+
import { Evented } from 'maplibre-gl';
|
|
4
4
|
import { ImageViewerFitImageToBoundsControl } from '../controls/ImageViewerFitImageToBoundsControl';
|
|
5
5
|
import { lngLatToPxInternalSymbolKey, pxToLngLatInternalSymbolKey } from './symbols';
|
|
6
|
-
declare const Evented: typeof MaplibreGL.Evented;
|
|
7
6
|
export type AllowedConstructorOptions = "container" | "apiKey" | "maxZoom" | "minZoom" | "zoom" | "bearing";
|
|
8
7
|
export type ImageViewerFlyToOptions = Omit<FlyToOptions, "pitch"> & {
|
|
9
8
|
center: [number, number];
|
|
@@ -305,18 +304,18 @@ export default class ImageViewer extends Evented {
|
|
|
305
304
|
* Fly to a given center.
|
|
306
305
|
*
|
|
307
306
|
* @param {ImageViewerFlyToOptions} options - The options for the fly to.
|
|
308
|
-
* @param
|
|
307
|
+
* @param eventData - Additional properties merged into the camera events fired by the map, as in MapLibre.
|
|
309
308
|
* @returns {ImageViewer} The ImageViewer instance.
|
|
310
309
|
*/
|
|
311
|
-
flyTo(options: ImageViewerFlyToOptions, eventData?:
|
|
310
|
+
flyTo(options: ImageViewerFlyToOptions, eventData?: Parameters<Map["flyTo"]>[1]): this;
|
|
312
311
|
/**
|
|
313
312
|
* Jump to a given center.
|
|
314
313
|
*
|
|
315
314
|
* @param {ImageViewerJumpToOptions} options - The options for the jump to.
|
|
316
|
-
* @param
|
|
315
|
+
* @param eventData - Additional properties merged into the camera events fired by the map, as in MapLibre.
|
|
317
316
|
* @returns {ImageViewer} The ImageViewer instance.
|
|
318
317
|
*/
|
|
319
|
-
jumpTo(options: ImageViewerJumpToOptions, eventData?:
|
|
318
|
+
jumpTo(options: ImageViewerJumpToOptions, eventData?: Parameters<Map["jumpTo"]>[1]): this;
|
|
320
319
|
/**
|
|
321
320
|
* Set the zoom level.
|
|
322
321
|
*
|
|
@@ -405,4 +404,3 @@ export default class ImageViewer extends Evented {
|
|
|
405
404
|
[lngLatToPxInternalSymbolKey]: (lngLat: LngLat) => [number, number];
|
|
406
405
|
[pxToLngLatInternalSymbolKey]: (px: [number, number]) => LngLat;
|
|
407
406
|
}
|
|
408
|
-
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Alignment, Subscription, MarkerOptions, PointLike, Popup } from '../index';
|
|
2
|
-
import {
|
|
2
|
+
import { Evented, Event as EventML } from 'maplibre-gl';
|
|
3
3
|
import { default as ImageViewer } from './ImageViewer';
|
|
4
|
-
declare const Evented: typeof MapLibreGL.Evented;
|
|
5
4
|
export type ImageViewerMarkerOptions = MarkerOptions & {};
|
|
6
5
|
export interface ImageViewerMarkerInterface {
|
|
7
6
|
on(event: MarkerEventTypes, listener: (e: ImageViewerMarkerEvent) => void): Subscription;
|
|
@@ -28,7 +27,7 @@ export interface ImageViewerMarkerInterface {
|
|
|
28
27
|
toggleClassName(className: string): void;
|
|
29
28
|
togglePopup(): void;
|
|
30
29
|
}
|
|
31
|
-
export declare class ImageViewerMarker extends Evented {
|
|
30
|
+
export declare class ImageViewerMarker extends Evented<ImageViewerMarkerEventType> {
|
|
32
31
|
private viewer;
|
|
33
32
|
private readonly marker;
|
|
34
33
|
private readonly position;
|
|
@@ -67,7 +66,7 @@ export declare class ImageViewerMarker extends Evented {
|
|
|
67
66
|
* @returns {PointLike} The offset of the ImageViewerMarker.
|
|
68
67
|
* @see [PointLike](https://docs.maptiler.com/sdk-js/api/geography/#pointlike)
|
|
69
68
|
*/
|
|
70
|
-
getOffset():
|
|
69
|
+
getOffset(): import('maplibre-gl').Point;
|
|
71
70
|
/**
|
|
72
71
|
* Gets the pitch alignment of the ImageViewerMarker.
|
|
73
72
|
*
|
|
@@ -81,7 +80,7 @@ export declare class ImageViewerMarker extends Evented {
|
|
|
81
80
|
* @returns {Popup} The popup of the ImageViewerMarker.
|
|
82
81
|
* @see [Popup](https://docs.maptiler.com/sdk-js/api/markers/#popup)
|
|
83
82
|
*/
|
|
84
|
-
getPopup():
|
|
83
|
+
getPopup(): Popup;
|
|
85
84
|
/**
|
|
86
85
|
* Gets the rotation of the ImageViewerMarker.
|
|
87
86
|
*
|
|
@@ -108,7 +107,8 @@ export declare class ImageViewerMarker extends Evented {
|
|
|
108
107
|
* @param {Record<string, any>} data - The data to fire the event with.
|
|
109
108
|
* @returns {ImageViewerMarker} The ImageViewerMarker instance.
|
|
110
109
|
*/
|
|
111
|
-
fire(event:
|
|
110
|
+
fire(event: ImageViewerMarkerEvent): this;
|
|
111
|
+
fire(event: MarkerEventTypes, data?: Record<string, any>): this;
|
|
112
112
|
/**
|
|
113
113
|
* Removes an event listener from the ImageViewerMarker.
|
|
114
114
|
*
|
|
@@ -227,9 +227,9 @@ export declare class ImageViewerMarker extends Evented {
|
|
|
227
227
|
}
|
|
228
228
|
declare const MARKER_EVENT_TYPES: readonly ["dragstart", "drag", "dragend"];
|
|
229
229
|
type MarkerEventTypes = (typeof MARKER_EVENT_TYPES)[number];
|
|
230
|
-
export
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
export type ImageViewerMarkerEventType = Record<MarkerEventTypes, ImageViewerMarkerEvent>;
|
|
231
|
+
export declare class ImageViewerMarkerEvent extends EventML<MarkerEventTypes> {
|
|
232
|
+
target: ImageViewerMarker;
|
|
233
233
|
[key: string]: any;
|
|
234
234
|
constructor(type: MarkerEventTypes, marker: ImageViewerMarker, data: Record<string, any>);
|
|
235
235
|
}
|
package/dist/Map.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Map as MapMLGL, StyleSpecification, MapOptions as MapOptionsML, ControlPosition, StyleSwapOptions, StyleOptions, RequestTransformFunction, LayerSpecification, SourceSpecification, CustomLayerInterface, FilterSpecification, StyleSetterOptions, ProjectionSpecification, FlyToOptions, EaseToOptions, FitBoundsOptions, AnimationOptions, LngLatBoundsLike, LngLatLike, AllPaintProperties, AllLayoutProperties, MapEventType, MapLayerEventType, Listener, Subscription, TerrainSpecification, Event as EventML } from 'maplibre-gl';
|
|
2
2
|
import { ReferenceMapStyle, MapStyleVariant } from '@maptiler/client';
|
|
3
3
|
import { SdkConfig } from './config';
|
|
4
4
|
import { LanguageInfo } from './language';
|
|
@@ -16,6 +16,45 @@ export type LoadWithTerrainEvent = {
|
|
|
16
16
|
exaggeration: number;
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Shape of an event fired by the SDK on top of the MapLibre events,
|
|
21
|
+
* with the properties passed to `fire(type, properties)` merged in.
|
|
22
|
+
*/
|
|
23
|
+
type SDKMapEvent<TType extends string, TProps extends object = object> = EventML<TType> & {
|
|
24
|
+
target: Map;
|
|
25
|
+
} & TProps;
|
|
26
|
+
/**
|
|
27
|
+
* Events fired by the MapTiler SDK `Map` in addition to the MapLibre ones.
|
|
28
|
+
*/
|
|
29
|
+
export type MaptilerMapEventType = {
|
|
30
|
+
/** Fired once the map style and the SDK controls are ready */
|
|
31
|
+
ready: SDKMapEvent<"ready">;
|
|
32
|
+
/** Fired once the map is loaded and the terrain (if any) is ready */
|
|
33
|
+
loadWithTerrain: LoadWithTerrainEvent;
|
|
34
|
+
/** Fired when the WebGL context is lost unexpectedly (i.e. not after `map.remove()`) */
|
|
35
|
+
webglContextLost: SDKMapEvent<"webglContextLost">;
|
|
36
|
+
terrainAnimationStart: SDKMapEvent<"terrainAnimationStart", {
|
|
37
|
+
terrain: TerrainSpecification | null;
|
|
38
|
+
}>;
|
|
39
|
+
terrainAnimationStop: SDKMapEvent<"terrainAnimationStop", {
|
|
40
|
+
terrain: TerrainSpecification | null;
|
|
41
|
+
}>;
|
|
42
|
+
"projection.change": SDKMapEvent<"projection.change", {
|
|
43
|
+
projection: ProjectionSpecification;
|
|
44
|
+
}>;
|
|
45
|
+
"cubemaplayer:animateindone": SDKMapEvent<"cubemaplayer:animateindone", Partial<CubemapLayer>>;
|
|
46
|
+
"cubemaplayer:animateoutdone": SDKMapEvent<"cubemaplayer:animateoutdone", Partial<CubemapLayer>>;
|
|
47
|
+
"cubemaplayer:onremove": SDKMapEvent<"cubemaplayer:onremove", Partial<CubemapLayer>>;
|
|
48
|
+
"radialgradientlayer:animateindone": SDKMapEvent<"radialgradientlayer:animateindone", Partial<RadialGradientLayer>>;
|
|
49
|
+
"radialgradientlayer:animateoutdone": SDKMapEvent<"radialgradientlayer:animateoutdone", Partial<RadialGradientLayer>>;
|
|
50
|
+
"radialgradientlayer:onremove": SDKMapEvent<"radialgradientlayer:onremove", Partial<RadialGradientLayer>>;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* All the events that can be listened to on a MapTiler SDK `Map`: the MapLibre ones plus the SDK ones.
|
|
54
|
+
* Since MapLibre v6.3, `on`/`once`/`off`/`fire` only accept the keys of `MapEventType`,
|
|
55
|
+
* so the SDK `Map` overrides them to accept its own events as well.
|
|
56
|
+
*/
|
|
57
|
+
export type MapEventTypeSDK = MapEventType & MaptilerMapEventType;
|
|
19
58
|
export declare const GeolocationType: {
|
|
20
59
|
POINT: "POINT";
|
|
21
60
|
COUNTRY: "COUNTRY";
|
|
@@ -169,11 +208,6 @@ export type MapOptions = Omit<MapOptionsML, "style" | "maplibreLogo" | "attribut
|
|
|
169
208
|
* Default: Unless this is set explicitly to false, the SDK version will be logged to the console.
|
|
170
209
|
*/
|
|
171
210
|
logSDKVersion?: boolean;
|
|
172
|
-
/**
|
|
173
|
-
* Whether to enable the RTL plugin or import a different one.
|
|
174
|
-
* Default is undefined, which means the plugin is enabled by default.
|
|
175
|
-
*/
|
|
176
|
-
rtlTextPlugin?: boolean | string;
|
|
177
211
|
/**
|
|
178
212
|
* Whether to enable the experimental tile preloading feature.
|
|
179
213
|
* Default is false.
|
|
@@ -202,8 +236,36 @@ export interface ProjectionChangeOptions {
|
|
|
202
236
|
/**
|
|
203
237
|
* The Map class can be instanciated to display a map in a `<div>`
|
|
204
238
|
*/
|
|
205
|
-
export declare class Map extends
|
|
239
|
+
export declare class Map extends MapMLGL {
|
|
206
240
|
readonly telemetry: Telemetry;
|
|
241
|
+
/**
|
|
242
|
+
* Adds a listener for events of a specified type, optionally limited to features in one or more layers.
|
|
243
|
+
* Accepts the MapLibre events as well as the SDK events (see {@link MaptilerMapEventType}).
|
|
244
|
+
*/
|
|
245
|
+
on<T extends keyof MapLayerEventType>(type: T, layerIds: string | string[], listener: (ev: MapLayerEventType[T] & object) => void): Subscription;
|
|
246
|
+
on<T extends keyof MapEventTypeSDK>(type: T, listener: (ev: MapEventTypeSDK[T] & object) => void): Subscription;
|
|
247
|
+
on(type: keyof MapEventTypeSDK, listener: Listener): Subscription;
|
|
248
|
+
/**
|
|
249
|
+
* Adds a listener that will be called only once to a specified event type, optionally limited to features in one or more layers.
|
|
250
|
+
* Accepts the MapLibre events as well as the SDK events (see {@link MaptilerMapEventType}).
|
|
251
|
+
*/
|
|
252
|
+
once<T extends keyof MapLayerEventType>(type: T, layerIds: string | string[], listener: (ev: MapLayerEventType[T] & object) => void): this;
|
|
253
|
+
once<T extends keyof MapLayerEventType>(type: T, layerIds: string | string[]): Promise<MapLayerEventType[T] & object>;
|
|
254
|
+
once<T extends keyof MapEventTypeSDK>(type: T, listener: (ev: MapEventTypeSDK[T] & object) => void): this;
|
|
255
|
+
once<T extends keyof MapEventTypeSDK>(type: T): Promise<MapEventTypeSDK[T] & object>;
|
|
256
|
+
once(type: keyof MapEventTypeSDK, listener?: Listener): this | Promise<any>;
|
|
257
|
+
/**
|
|
258
|
+
* Removes an event listener previously added with {@link Map.on} or {@link Map.once}.
|
|
259
|
+
* Accepts the MapLibre events as well as the SDK events (see {@link MaptilerMapEventType}).
|
|
260
|
+
*/
|
|
261
|
+
off<T extends keyof MapLayerEventType>(type: T, layerIds: string | string[], listener: (ev: MapLayerEventType[T] & object) => void): this;
|
|
262
|
+
off<T extends keyof MapEventTypeSDK>(type: T, listener: (ev: MapEventTypeSDK[T] & object) => void): this;
|
|
263
|
+
off(type: keyof MapEventTypeSDK, listener: Listener): this;
|
|
264
|
+
/**
|
|
265
|
+
* Fires an event. Accepts the MapLibre events as well as the SDK events (see {@link MaptilerMapEventType}).
|
|
266
|
+
*/
|
|
267
|
+
fire(event: MapEventTypeSDK[keyof MapEventTypeSDK]): this;
|
|
268
|
+
fire(type: keyof MapEventTypeSDK, properties?: object): this;
|
|
207
269
|
private space?;
|
|
208
270
|
private halo?;
|
|
209
271
|
getSpace(): CubemapLayer | undefined;
|
|
@@ -399,7 +461,7 @@ export declare class Map extends maplibregl.Map {
|
|
|
399
461
|
* map.setPaintProperty('my-layer', 'fill-color', '#faafee');
|
|
400
462
|
* ```
|
|
401
463
|
*/
|
|
402
|
-
setPaintProperty(layerId: string, name:
|
|
464
|
+
setPaintProperty<K extends keyof AllPaintProperties>(layerId: string, name: K, value: AllPaintProperties[K], options?: StyleSetterOptions): this;
|
|
403
465
|
/**
|
|
404
466
|
* Sets the value of a layout property in the specified style layer.
|
|
405
467
|
* Layout properties define how the layer is styled.
|
|
@@ -413,7 +475,7 @@ export declare class Map extends maplibregl.Map {
|
|
|
413
475
|
* @param options - Options object.
|
|
414
476
|
* @returns `this`
|
|
415
477
|
*/
|
|
416
|
-
setLayoutProperty(layerId: string, name:
|
|
478
|
+
setLayoutProperty<K extends keyof AllLayoutProperties>(layerId: string, name: K, value: AllLayoutProperties[K], options?: StyleSetterOptions): this;
|
|
417
479
|
/**
|
|
418
480
|
* Sets the value of the style's glyphs property.
|
|
419
481
|
*
|
|
@@ -530,7 +592,7 @@ export declare class Map extends maplibregl.Map {
|
|
|
530
592
|
* Sets the projection to a {@linkcode ProjectionSpecification}.
|
|
531
593
|
* @param projection - the projection specification to set
|
|
532
594
|
*/
|
|
533
|
-
setProjection(projection:
|
|
595
|
+
setProjection(projection: ProjectionSpecification): this;
|
|
534
596
|
/**
|
|
535
597
|
* Forget the persisted projection - from both constructor option and result of any `map.setProjection(..., { persist: true })` calls.
|
|
536
598
|
*/
|
|
@@ -684,3 +746,4 @@ export declare class Map extends maplibregl.Map {
|
|
|
684
746
|
*/
|
|
685
747
|
private resolveCameraPosition;
|
|
686
748
|
}
|
|
749
|
+
export {};
|