@maptiler/sdk 5.0.0-rc.3 → 5.0.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/README.md +140 -8
- package/dist/ImageViewer/ImageViewer.d.ts +2 -1
- package/dist/ImageViewer/events.d.ts +14 -6
- package/dist/ImageViewer/index.d.ts +1 -1
- package/dist/Map.d.ts +27 -8
- package/dist/index.d.ts +1 -1
- package/dist/maptiler-sdk.mjs +472 -478
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/utils/defaultWorkerUrl.d.ts +1 -1
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -121,6 +121,15 @@ From CDN and using the UMD bundle, in the `<head></head>` section of your HTML f
|
|
|
121
121
|
<link href="https://cdn.maptiler.com/maptiler-sdk-js/<VERSION>/maptiler-sdk.css" rel="stylesheet" />
|
|
122
122
|
```
|
|
123
123
|
|
|
124
|
+
Or from CDN and using the ES module bundle, importing the SDK from a module script:
|
|
125
|
+
|
|
126
|
+
```html
|
|
127
|
+
<link href="https://cdn.maptiler.com/maptiler-sdk-js/<VERSION>/maptiler-sdk.css" rel="stylesheet" />
|
|
128
|
+
<script type="module">
|
|
129
|
+
import { config, Map } from "https://cdn.maptiler.com/maptiler-sdk-js/<VERSION>/maptiler-sdk.min.mjs";
|
|
130
|
+
</script>
|
|
131
|
+
```
|
|
132
|
+
|
|
124
133
|
<br>
|
|
125
134
|
|
|
126
135
|
## 🚀 Basic Usage
|
|
@@ -189,7 +198,7 @@ With the legacy `"moduleResolution": "Node"` (or `"Node10"`), the main `@maptile
|
|
|
189
198
|
|
|
190
199
|
### With CDN
|
|
191
200
|
|
|
192
|
-
The SDK hosted on our CDN is bundled as _[Universal Module Definition](https://github.com/umdjs/umd)_ (UMD)
|
|
201
|
+
The SDK hosted on our CDN is bundled both as _[Universal Module Definition](https://github.com/umdjs/umd)_ (UMD), `maptiler-sdk.umd.min.js`, and as an ES module, `maptiler-sdk.min.mjs`. Both are standalone and contain all their dependencies. The CDN also serves the style sheet (CSS).
|
|
193
202
|
|
|
194
203
|
**Recommended for:** simple map integration example and demos
|
|
195
204
|
|
|
@@ -236,13 +245,29 @@ The SDK hosted on our CDN is bundled as _[Universal Module Definition](https://g
|
|
|
236
245
|
</html>
|
|
237
246
|
```
|
|
238
247
|
|
|
248
|
+
With the ES module bundle, the SDK is imported from a module script instead of being exposed as the `maptilersdk` global:
|
|
249
|
+
|
|
250
|
+
```html
|
|
251
|
+
<script type="module">
|
|
252
|
+
import { config, Map, MapStyle } from "https://cdn.maptiler.com/maptiler-sdk-js/<VERSION>/maptiler-sdk.min.mjs";
|
|
253
|
+
|
|
254
|
+
config.apiKey = "YOUR_API_KEY";
|
|
255
|
+
|
|
256
|
+
const map = new Map({
|
|
257
|
+
container: "map-container",
|
|
258
|
+
style: MapStyle.STREETS_DARK,
|
|
259
|
+
hash: true,
|
|
260
|
+
});
|
|
261
|
+
</script>
|
|
262
|
+
```
|
|
263
|
+
|
|
239
264
|
Check out the minimalist code samples in the [demos](demos) directory.
|
|
240
265
|
|
|
241
266
|
#### Map worker files and Content Security Policy (CSP)
|
|
242
267
|
|
|
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
|
|
268
|
+
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 and ES module bundles look for them in the same folder as `maptiler-sdk.umd.min.js` and `maptiler-sdk.min.mjs`. Our CDN serves them there, so when using the CDN without a CSP, there is nothing to set up.
|
|
244
269
|
|
|
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`).
|
|
270
|
+
If you **self-host the UMD or ES module bundle**, copy both `.mjs` files next to `maptiler-sdk.umd.min.js` or `maptiler-sdk.min.mjs`. They must be served with a JavaScript content type (e.g. `text/javascript`).
|
|
246
271
|
|
|
247
272
|
If your site uses a **Content Security Policy**, the worker needs to be allowed:
|
|
248
273
|
|
|
@@ -260,6 +285,8 @@ If your site uses a **Content Security Policy**, the worker needs to be allowed:
|
|
|
260
285
|
</script>
|
|
261
286
|
```
|
|
262
287
|
|
|
288
|
+
With the ES module bundle, import `setWorkerUrl` from it and call it the same way.
|
|
289
|
+
|
|
263
290
|
`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
291
|
|
|
265
292
|
<br>
|
|
@@ -274,6 +301,110 @@ Check out more than 200 [examples and tutorials](https://docs.maptiler.com/sdk-j
|
|
|
274
301
|
|
|
275
302
|
<br>
|
|
276
303
|
|
|
304
|
+
## 🗂️ In-repo demos
|
|
305
|
+
|
|
306
|
+
Runnable demos of the SDK features, kept in `demos/`. They're separate from the docs examples linked above.
|
|
307
|
+
|
|
308
|
+
### Run the demos
|
|
309
|
+
|
|
310
|
+
1. Create a `.env.local` file at the root of the repo (git ignores it) with your MapTiler API key: `VITE_MAPTILER_API_KEY=YOUR_KEY`.
|
|
311
|
+
2. Run `npm run dev`.
|
|
312
|
+
3. Open the printed URL. It lists every demo.
|
|
313
|
+
|
|
314
|
+
Instead of `.env.local`, you can add `?key=YOUR_KEY` to a demo URL once, and the browser stores the key for all demos. If several keys are set, the demos use the first of: the key in `.env.local`, the key stored in the browser, the `key` URL parameter.
|
|
315
|
+
|
|
316
|
+
### Kinds of demos
|
|
317
|
+
|
|
318
|
+
- **Examples** (`demos/examples/<topic>/<name>/`): short, single-use code with minimal dependencies, e.g. "put a marker on the page and style it".
|
|
319
|
+
- **Showcases** (`demos/showcases/<name>/`): more involved, with more comments and inline docs, closer to a guide. May use external dependencies, e.g. a UI library.
|
|
320
|
+
- **Playgrounds** (`demos/playgrounds/<name>/`): for comparing feature versions, testing or developing features, and recording code "gotchas". May use external dependencies and lots of UI code. Internal: listed on the `npm run dev` page, but not in the list below.
|
|
321
|
+
|
|
322
|
+
### Add or change a demo
|
|
323
|
+
|
|
324
|
+
Each demo is a folder with an `index.html`, a `main.ts` and a `meta.json`:
|
|
325
|
+
|
|
326
|
+
```json
|
|
327
|
+
{
|
|
328
|
+
"title": "Styled marker",
|
|
329
|
+
"description": "Puts a marker on the map and sets its shape and colors.",
|
|
330
|
+
"type": "example",
|
|
331
|
+
"topics": ["markers"],
|
|
332
|
+
"createdWith": "5.0.0-rc.4",
|
|
333
|
+
"lastCheckedWith": "5.0.0-rc.4",
|
|
334
|
+
"lastCheckedOn": "2026-10-30"
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
- `type` is `example`, `showcase` or `playground`, matching the folder. An example's first topic matches its `<topic>` folder. Playgrounds stay out of the index below, and their `topics` can be empty.
|
|
339
|
+
- `createdWith` is the SDK version the demo was created with.
|
|
340
|
+
- `lastCheckedWith` and `lastCheckedOn` record the last time someone ran the demo and saw it working. They stay `null` until then.
|
|
341
|
+
|
|
342
|
+
Values likely to change go in variables right after the imports of `main.ts`, with the same names in every demo, so they can be updated with grep or a script, e.g. `MAP_STYLE`.
|
|
343
|
+
|
|
344
|
+
Build any controls a demo needs (buttons, dropdowns, sliders, readouts) with [lil-gui](https://lil-gui.georgealways.com), using `createGui()` from `demos/shared/gui.ts`, rather than hand-written HTML. The exception is UI that is the subject of the demo, such as the custom map controls of the controls examples.
|
|
345
|
+
|
|
346
|
+
Run `npm run demos:index` after adding or changing a demo. It validates the metadata and regenerates the index below. CI fails if the index is out of date.
|
|
347
|
+
|
|
348
|
+
### Topics
|
|
349
|
+
|
|
350
|
+
Use only these labels in `topics`. Add a label here before using it.
|
|
351
|
+
|
|
352
|
+
<!-- demo-topics:start -->
|
|
353
|
+
- `3d`
|
|
354
|
+
- `animation`
|
|
355
|
+
- `color-ramps`
|
|
356
|
+
- `controls`
|
|
357
|
+
- `errors`
|
|
358
|
+
- `events`
|
|
359
|
+
- `getting-started`
|
|
360
|
+
- `halo`
|
|
361
|
+
- `image-viewer`
|
|
362
|
+
- `language`
|
|
363
|
+
- `markers`
|
|
364
|
+
- `performance`
|
|
365
|
+
- `requests`
|
|
366
|
+
- `routes`
|
|
367
|
+
- `sky`
|
|
368
|
+
- `space`
|
|
369
|
+
- `styles`
|
|
370
|
+
<!-- demo-topics:end -->
|
|
371
|
+
|
|
372
|
+
### Index
|
|
373
|
+
|
|
374
|
+
<!-- demos-index:start -->
|
|
375
|
+
#### Examples
|
|
376
|
+
|
|
377
|
+
| Demo | Description | Topics | Created with | Last checked |
|
|
378
|
+
| --- | --- | --- | --- | --- |
|
|
379
|
+
| [Available color ramps](./demos/examples/color-ramps/available-ramps) | Displays every built-in color ramp, plus rescaled and resampled variants. | `color-ramps` | 3.2.4 | Not yet |
|
|
380
|
+
| [Custom controls: declarative](./demos/examples/controls/declarative) | Builds custom map controls from HTML attributes. | `controls` | 3.5.1-rc1 | Not yet |
|
|
381
|
+
| [Custom controls: programmatic](./demos/examples/controls/programmatic) | Builds custom map controls from code. | `controls` | 3.8.0-rc.9 | Not yet |
|
|
382
|
+
| [Handling WebGL errors](./demos/examples/errors/handling-webgl-errors) | Reacts to a lost WebGL context and shows a warning. | `errors` | 3.2.4 | Not yet |
|
|
383
|
+
| [Ready event](./demos/examples/events/ready-event) | Uses the `ready` event to know when the map can be changed safely. | `events` | 3.2.4 | Not yet |
|
|
384
|
+
| [Simple map](./demos/examples/getting-started/simple) | A map with the Streets v2 style. | `getting-started` | 5.0.0-rc.4 | Not yet |
|
|
385
|
+
| [Image viewer](./demos/examples/image-viewer/image-viewer) | Displays a tiled, non-georeferenced image with markers. | `image-viewer` `markers` | 3.8.0-rc.9 | Not yet |
|
|
386
|
+
| [Language changes](./demos/examples/language/language-changes) | Switches the map language at runtime. | `language` | 3.5.1-rc1 | Not yet |
|
|
387
|
+
| [Marker altitude](./demos/examples/markers/altitude) | Raises two draggable markers to 1,300 m above sea level over the terrain, with ground lines (experimental). | `markers` | 5.0.0-beta.m-r.1 | Not yet |
|
|
388
|
+
| [Styled marker](./demos/examples/markers/styled-marker) | Puts a marker on the map and sets its shape and colors. | `markers` | 5.0.0-rc.4 | Not yet |
|
|
389
|
+
| [Marker UI states](./demos/examples/markers/ui-states) | Markers that change their look on hover, focus, press and drag. | `markers` | 5.0.0-beta.m-r.1 | Not yet |
|
|
390
|
+
| [Tile preloading: bounds](./demos/examples/performance/tile-preloading-bounds) | Preloads the tiles of a region with `experimental_preloadTilesForBounds`, then jumps there. Toggle preloading off to compare. | `performance` | 4.1.0 | Not yet |
|
|
391
|
+
| [Tile preloading: flyTo](./demos/examples/performance/tile-preloading-flyto) | Preloads the tiles along a `flyTo` path with `experimental_preload` before the flight starts. Toggle preloading off to compare. | `performance` | 4.1.0 | Not yet |
|
|
392
|
+
| [Transform request](./demos/examples/requests/transform-request) | Changes outgoing map requests with `transformRequest`. | `requests` | 3.2.4 | Not yet |
|
|
393
|
+
| [Sky: day](./demos/examples/sky/day) | Configures the sky on a daytime outdoor style. | `sky` | 3.2.4 | Not yet |
|
|
394
|
+
| [Sky: night](./demos/examples/sky/night) | Configures the sky on a dark outdoor style. | `sky` | 3.2.4 | Not yet |
|
|
395
|
+
| [Space & halo: simple](./demos/examples/space/orbiting-globe) | A globe turning against a starry space background, with the default halo. | `space` `halo` | 5.0.0-rc.4 | Not yet |
|
|
396
|
+
|
|
397
|
+
#### Showcases
|
|
398
|
+
|
|
399
|
+
| Demo | Description | Topics | Created with | Last checked |
|
|
400
|
+
| --- | --- | --- | --- | --- |
|
|
401
|
+
| [Animated route around Madeira](./demos/showcases/animated-routes) | Animates the camera along a Madeira route with `AnimatedRouteLayer`, with stops and photos. | `animation` `routes` | 3.11.0 | Not yet |
|
|
402
|
+
| [Marker animation in the Sahara](./demos/showcases/marker-animation) | Drives two rally car markers around the Erg Chebbi dunes with a single `MaptilerAnimation`, with playback controls. | `animation` `markers` | 5.0.0-rc.4 | Not yet |
|
|
403
|
+
| [Space & halo: transitions](./demos/showcases/spacebox-and-halo) | Switches between every space preset, custom cubemap images, space colors and halo gradients on a globe. | `space` `halo` | 3.5.1-rc1 | Not yet |
|
|
404
|
+
<!-- demos-index:end -->
|
|
405
|
+
|
|
406
|
+
<br>
|
|
407
|
+
|
|
277
408
|
## 📘 API Reference
|
|
278
409
|
|
|
279
410
|
In addition to the details and examples provided in this readme, check out the [complete API documentation](https://docs.maptiler.com/sdk-js/api/)
|
|
@@ -998,7 +1129,7 @@ map.on("load", () => {
|
|
|
998
1129
|
|
|
999
1130
|
Note: if `space.color` or `space.<faces | path | preset>` are not explicitly set in the call to `setSpace`, then the previous value will remain for this field.
|
|
1000
1131
|
|
|
1001
|
-
|
|
1132
|
+
See [`demos/examples/space/orbiting-globe`](./demos/examples/space/orbiting-globe) for a simple example, and [`demos/showcases/spacebox-and-halo`](./demos/showcases/spacebox-and-halo) for every preset and option.
|
|
1002
1133
|
|
|
1003
1134
|
### `ImageViewer`
|
|
1004
1135
|
|
|
@@ -1565,6 +1696,8 @@ marker.setGroundLine(true); // dashed line from the marker down to the ground
|
|
|
1565
1696
|
|
|
1566
1697
|
Style the ground line with your own CSS on the `maptiler-marker-groundline` class, or add a class of your own with `setGroundLine(true, { className: "my-line" })`.
|
|
1567
1698
|
|
|
1699
|
+
See [`demos/examples/markers/altitude`](./demos/examples/markers/altitude) for an example.
|
|
1700
|
+
|
|
1568
1701
|
#### The MapLibre marker
|
|
1569
1702
|
|
|
1570
1703
|
Compared with the MapLibre marker:
|
|
@@ -1580,14 +1713,13 @@ import { MarkerMLGL } from "@maptiler/sdk";
|
|
|
1580
1713
|
new MarkerMLGL({ color: "#f00" }).setLngLat([8.54, 47.37]).addTo(map);
|
|
1581
1714
|
```
|
|
1582
1715
|
|
|
1583
|
-
See `demos/
|
|
1716
|
+
See [`demos/examples/markers/styled-marker`](./demos/examples/markers/styled-marker) for an example, and `demos/playgrounds/markers*` for every option.
|
|
1584
1717
|
|
|
1585
1718
|
### Camera routes and animations
|
|
1586
1719
|
|
|
1587
1720
|
The SDK comes with several classes to help with animations, particularly route animations.
|
|
1588
1721
|
|
|
1589
|
-
See `demos/
|
|
1590
|
-
See `demos/12-maptiler-animation.html` for examples.
|
|
1722
|
+
See [`demos/showcases/animated-routes`](./demos/showcases/animated-routes) and [`demos/showcases/marker-animation`](./demos/showcases/marker-animation) for examples.
|
|
1591
1723
|
|
|
1592
1724
|
#### 🧩 `MaptilerAnimation`
|
|
1593
1725
|
|
|
@@ -1734,7 +1866,7 @@ animatedRoute.play();
|
|
|
1734
1866
|
animatedRoute.pause();
|
|
1735
1867
|
```
|
|
1736
1868
|
|
|
1737
|
-
For a full example of how to use this, look at [the
|
|
1869
|
+
For a full example of how to use this, look at [the showcase](./demos/showcases/animated-routes)
|
|
1738
1870
|
|
|
1739
1871
|
### Vector Layer Helpers
|
|
1740
1872
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EaseToOptions, DoubleClickZoomHandler, DragPanHandler, TwoFingersTouchZoomRotateHandler, FlyToOptions, MapOptions, JumpToOptions, ScrollZoomHandler, BoxZoomHandler, KeyboardHandler, CooperativeGesturesHandler, LngLat, PointLike } from '..';
|
|
2
2
|
import { Map } from '../Map';
|
|
3
|
+
import { ImageViewerEventType } from './events';
|
|
3
4
|
import { Evented } from 'maplibre-gl';
|
|
4
5
|
import { ImageViewerFitImageToBoundsControl } from '../controls/ImageViewerFitImageToBoundsControl';
|
|
5
6
|
import { lngLatToPxInternalSymbolKey, pxToLngLatInternalSymbolKey } from './symbols';
|
|
@@ -49,7 +50,7 @@ export type ImageMetadata = {
|
|
|
49
50
|
maxzoom: number;
|
|
50
51
|
tileSize: number;
|
|
51
52
|
};
|
|
52
|
-
export default class ImageViewer extends Evented {
|
|
53
|
+
export default class ImageViewer extends Evented<ImageViewerEventType> {
|
|
53
54
|
/**
|
|
54
55
|
* The UUID of the image.
|
|
55
56
|
*
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { Map } from '../Map';
|
|
2
2
|
import { default as ImageViewer } from './ImageViewer';
|
|
3
|
-
import { LngLat } from 'maplibre-gl';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import { Event as EventML, LngLat } from 'maplibre-gl';
|
|
4
|
+
type ImageViewerOriginalEvent = MouseEvent | TouchEvent | WheelEvent | WebGLContextEvent | null;
|
|
5
|
+
export declare class ImageViewerEvent extends EventML<ImageViewerEventTypes> {
|
|
6
|
+
target: ImageViewer;
|
|
7
|
+
originalEvent: ImageViewerOriginalEvent;
|
|
8
8
|
[key: string]: any;
|
|
9
9
|
imageX: number;
|
|
10
10
|
imageY: number;
|
|
11
11
|
isOutOfBounds: boolean;
|
|
12
|
-
constructor(type:
|
|
12
|
+
constructor(type: ImageViewerEventTypes, viewer: ImageViewer, originalEvent?: ImageViewerOriginalEvent, data?: Record<string, any>);
|
|
13
13
|
}
|
|
14
|
+
/** Fired when the viewer fails to load its image. */
|
|
15
|
+
export type ImageViewerInitErrorEvent = EventML<"imagevieweriniterror"> & {
|
|
16
|
+
error: Error;
|
|
17
|
+
};
|
|
18
|
+
/** Event payloads keyed by event type — every event is an {@link ImageViewerEvent}, apart from the init error. */
|
|
19
|
+
export type ImageViewerEventType = Record<Exclude<ImageViewerEventTypes, "imagevieweriniterror">, ImageViewerEvent> & {
|
|
20
|
+
imagevieweriniterror: ImageViewerInitErrorEvent;
|
|
21
|
+
};
|
|
14
22
|
declare const BASE_MAP_EVENT_TYPES: readonly ["idle", "render", "load", "remove", "idle"];
|
|
15
23
|
declare const ERROR_EVENTS: readonly ["error"];
|
|
16
24
|
declare const RESIZE_EVENTS: readonly ["resize"];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as ImageViewer } from './ImageViewer';
|
|
2
2
|
export { ImageViewerMarker, ImageViewerMarkerEvent, type ImageViewerMarkerOptions } from './ImageViewerMarker';
|
|
3
|
-
export type { ImageViewerEventTypes } from './events';
|
|
3
|
+
export type { ImageViewerEventTypes, ImageViewerEventType, ImageViewerInitErrorEvent } from './events';
|
|
4
4
|
export type { ImageViewerConstructorOptions, ImageViewerFlyToOptions, ImageViewerJumpToOptions, ImageMetadata } from './ImageViewer';
|
|
5
5
|
export { ImageViewerEvent } from './events';
|
package/dist/Map.d.ts
CHANGED
|
@@ -56,6 +56,25 @@ export type MaptilerMapEventType = {
|
|
|
56
56
|
* so the SDK `Map` overrides them to accept its own events as well.
|
|
57
57
|
*/
|
|
58
58
|
export type MapEventTypeSDK = MapEventType & MaptilerMapEventType;
|
|
59
|
+
/**
|
|
60
|
+
* An event as an SDK `Map` listener receives it. MapLibre types its events' target as its
|
|
61
|
+
* own `Map`, which lacks the SDK members, but the target is always the SDK `Map` that fired it.
|
|
62
|
+
*
|
|
63
|
+
* The target is intersected in, rather than remapped over every event, so the SDK `Map`'s
|
|
64
|
+
* `on`/`once`/`off` stay assignable to MapLibre's — the SDK `Map` is passed to MapLibre controls and layers.
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* const onClick = (e: MapEventSDK<"click">) => console.log(e.lngLat, e.target.getSpace());
|
|
68
|
+
* map.on("click", onClick);
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export type MapEventSDK<T extends keyof MapEventTypeSDK> = MapEventTypeSDK[T] & object & {
|
|
72
|
+
target: Map;
|
|
73
|
+
};
|
|
74
|
+
/** A layer event as an SDK `Map` listener receives it — see {@link MapEventSDK}. */
|
|
75
|
+
export type MapLayerEventSDK<T extends keyof MapLayerEventType> = MapLayerEventType[T] & object & {
|
|
76
|
+
target: Map;
|
|
77
|
+
};
|
|
59
78
|
export declare const GeolocationType: {
|
|
60
79
|
POINT: "POINT";
|
|
61
80
|
COUNTRY: "COUNTRY";
|
|
@@ -268,24 +287,24 @@ export declare class Map extends MapMLGL {
|
|
|
268
287
|
* Adds a listener for events of a specified type, optionally limited to features in one or more layers.
|
|
269
288
|
* Accepts the MapLibre events as well as the SDK events (see {@link MaptilerMapEventType}).
|
|
270
289
|
*/
|
|
271
|
-
on<T extends keyof MapLayerEventType>(type: T, layerIds: string | string[], listener: (ev:
|
|
272
|
-
on<T extends keyof MapEventTypeSDK>(type: T, listener: (ev:
|
|
290
|
+
on<T extends keyof MapLayerEventType>(type: T, layerIds: string | string[], listener: (ev: MapLayerEventSDK<T>) => void): Subscription;
|
|
291
|
+
on<T extends keyof MapEventTypeSDK>(type: T, listener: (ev: MapEventSDK<T>) => void): Subscription;
|
|
273
292
|
on(type: keyof MapEventTypeSDK, listener: Listener): Subscription;
|
|
274
293
|
/**
|
|
275
294
|
* Adds a listener that will be called only once to a specified event type, optionally limited to features in one or more layers.
|
|
276
295
|
* Accepts the MapLibre events as well as the SDK events (see {@link MaptilerMapEventType}).
|
|
277
296
|
*/
|
|
278
|
-
once<T extends keyof MapLayerEventType>(type: T, layerIds: string | string[], listener: (ev:
|
|
279
|
-
once<T extends keyof MapLayerEventType>(type: T, layerIds: string | string[]): Promise<
|
|
280
|
-
once<T extends keyof MapEventTypeSDK>(type: T, listener: (ev:
|
|
281
|
-
once<T extends keyof MapEventTypeSDK>(type: T): Promise<
|
|
297
|
+
once<T extends keyof MapLayerEventType>(type: T, layerIds: string | string[], listener: (ev: MapLayerEventSDK<T>) => void): this;
|
|
298
|
+
once<T extends keyof MapLayerEventType>(type: T, layerIds: string | string[]): Promise<MapLayerEventSDK<T>>;
|
|
299
|
+
once<T extends keyof MapEventTypeSDK>(type: T, listener: (ev: MapEventSDK<T>) => void): this;
|
|
300
|
+
once<T extends keyof MapEventTypeSDK>(type: T): Promise<MapEventSDK<T>>;
|
|
282
301
|
once(type: keyof MapEventTypeSDK, listener?: Listener): this | Promise<any>;
|
|
283
302
|
/**
|
|
284
303
|
* Removes an event listener previously added with {@link Map.on} or {@link Map.once}.
|
|
285
304
|
* Accepts the MapLibre events as well as the SDK events (see {@link MaptilerMapEventType}).
|
|
286
305
|
*/
|
|
287
|
-
off<T extends keyof MapLayerEventType>(type: T, layerIds: string | string[], listener: (ev:
|
|
288
|
-
off<T extends keyof MapEventTypeSDK>(type: T, listener: (ev:
|
|
306
|
+
off<T extends keyof MapLayerEventType>(type: T, layerIds: string | string[], listener: (ev: MapLayerEventSDK<T>) => void): this;
|
|
307
|
+
off<T extends keyof MapEventTypeSDK>(type: T, listener: (ev: MapEventSDK<T>) => void): this;
|
|
289
308
|
off(type: keyof MapEventTypeSDK, listener: Listener): this;
|
|
290
309
|
/**
|
|
291
310
|
* Fires an event. Accepts the MapLibre events as well as the SDK events (see {@link MaptilerMapEventType}).
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { getVersion as getMapLibreVersion, Map as MapMLGL, Marker as MarkerMLGL,
|
|
|
10
10
|
export * from './Marker';
|
|
11
11
|
export { Marker } from './Marker';
|
|
12
12
|
export { Popup, Style, CanvasSource, GeoJSONSource, ImageSource, RasterTileSource, RasterDEMTileSource, VectorTileSource, VideoSource, NavigationControl, GeolocateControl, AttributionControl, LogoControl, ScaleControl, FullscreenControl, TerrainControl, BoxZoomHandler, ScrollZoomHandler, CooperativeGesturesHandler, KeyboardHandler, TwoFingersTouchPitchHandler, MapWheelEvent, MapTouchEvent, MapMouseEvent, } from 'maplibre-gl';
|
|
13
|
-
export { Map, GeolocationType, type AttributionControlOptions, type MapOptions, type LoadWithTerrainEvent, type MaptilerMapEventType, type MapEventTypeSDK } from './Map';
|
|
13
|
+
export { Map, GeolocationType, type AttributionControlOptions, type MapOptions, type LoadWithTerrainEvent, type MaptilerMapEventType, type MapEventTypeSDK, type MapEventSDK, type MapLayerEventSDK, } from './Map';
|
|
14
14
|
export type { CameraPosition, TilePreloadOptions, WithTilePreload, PreloadTilesForBoundsOptions, PreloadTilesForCameraPositionsOptions, PreloadTilesOptions, TilePreloadErrorCallback, TilePreloadProgressCallback, } from './tile-preloading';
|
|
15
15
|
export { type BaseGeocodingOptions, type ByIdGeocodingOptions, type CommonForwardAndReverseGeocodingOptions, type GeocodingOptions, type LanguageGeocodingOptions, type ReverseGeocodingOptions, geocoding, } from './geocoding';
|
|
16
16
|
export * from './controls';
|