@maptiler/sdk 5.0.0-rc.2 → 5.0.0-rc.4
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 +178 -1
- 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/ImageViewer/monkeyPatchML.d.ts +1 -1
- package/dist/Map.d.ts +109 -9
- package/dist/Marker/Marker.d.ts +397 -0
- package/dist/Marker/MarkerManager.d.ts +137 -0
- package/dist/Marker/altitude-math.d.ts +24 -0
- package/dist/Marker/collision-helpers.d.ts +160 -0
- package/dist/Marker/index.d.ts +2 -0
- package/dist/Marker/marker-adaptive-colors.d.ts +35 -0
- package/dist/Marker/marker-animation-presets.d.ts +60 -0
- package/dist/Marker/marker-constants.d.ts +111 -0
- package/dist/Marker/marker-content-registry.d.ts +17 -0
- package/dist/Marker/marker-dom-utils.d.ts +66 -0
- package/dist/Marker/marker-icons.d.ts +31 -0
- package/dist/Marker/marker-state-helpers.d.ts +2 -0
- package/dist/Marker/marker-svg-config.d.ts +84 -0
- package/dist/Marker/marker-symbols.d.ts +12 -0
- package/dist/Marker/marker-text-fit.d.ts +20 -0
- package/dist/Marker/marker-transitions.d.ts +29 -0
- package/dist/Marker/types.d.ts +458 -0
- package/dist/index.d.ts +5 -2
- package/dist/mapstyle.d.ts +7 -0
- package/dist/maptiler-sdk.css +108 -1
- package/dist/maptiler-sdk.d.ts +1 -1
- package/dist/maptiler-sdk.mjs +16830 -14506
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/utils/object.d.ts +1 -0
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -1406,6 +1406,182 @@ When defining a new _ramp_, the colors can be an RGB array (`[number, number, nu
|
|
|
1406
1406
|
|
|
1407
1407
|
Many methods are available on color ramps, such as getting the `<canvas>` element of it, rescaling it, flipping it or [resampling it in a non-linear way](colorramp.md). Read more on [our reference page](https://docs.maptiler.com/sdk-js/api/color-ramp/) and have a look at our [examples](https://docs.maptiler.com/sdk-js/examples/?q=colorramp) to see how they work.
|
|
1408
1408
|
|
|
1409
|
+
### Markers
|
|
1410
|
+
|
|
1411
|
+
The SDK's `Marker` is designed for MapTiler maps. It is built on the MapLibre marker and adds built-in shapes and sizes, colours that follow the active MapTiler style, collision handling, interaction states, transitions and animations.
|
|
1412
|
+
|
|
1413
|
+
#### Adding markers
|
|
1414
|
+
|
|
1415
|
+
Create a marker, give it a position, and add it through the map. Markers added this way take part in collision handling and follow the style's colours:
|
|
1416
|
+
|
|
1417
|
+
```ts
|
|
1418
|
+
import { Map, Marker } from "@maptiler/sdk";
|
|
1419
|
+
|
|
1420
|
+
const marker = new Marker({ lngLat: [8.54, 47.37], shape: "bubble-circle", size: "m", content: "A1" });
|
|
1421
|
+
map.addMarker(marker);
|
|
1422
|
+
|
|
1423
|
+
// or straight from options
|
|
1424
|
+
map.addMarker({ lngLat: [8.55, 47.38], shape: "circle" });
|
|
1425
|
+
map.addMarkers([
|
|
1426
|
+
{ lngLat: [8.53, 47.36], shape: "square" },
|
|
1427
|
+
new Marker({ shape: "circle" }).setLngLat([8.56, 47.39]),
|
|
1428
|
+
]);
|
|
1429
|
+
|
|
1430
|
+
map.getMarker(marker.id);
|
|
1431
|
+
map.getMarkers();
|
|
1432
|
+
map.removeMarker(marker.id);
|
|
1433
|
+
map.removeMarkers(); // all markers, or pass a list of ids
|
|
1434
|
+
```
|
|
1435
|
+
|
|
1436
|
+
Removing a marker plays its exit animation first, if it has one (see [Animations](#animations)). Pass `{ immediate: true }` to `removeMarker()` or `removeMarkers()` to remove markers straight away.
|
|
1437
|
+
|
|
1438
|
+
> [!WARNING]
|
|
1439
|
+
> `marker.addTo(map)` is deprecated. It now delegates to `map.addMarker(marker)` and logs a one-time warning. Use `map.addMarker()` instead.
|
|
1440
|
+
|
|
1441
|
+
#### Appearance
|
|
1442
|
+
|
|
1443
|
+
```ts
|
|
1444
|
+
const marker = new Marker({
|
|
1445
|
+
shape: "maptiler", // "circle" | "square" | "bubble-circle" | "bubble-square" | "maptiler" | "maptiler-full"
|
|
1446
|
+
size: "l", // "xs" | "s" | "m" | "l"
|
|
1447
|
+
shadow: "soft", // "none" | "soft" | "medium" | "strong"
|
|
1448
|
+
content: "42", // text shown inside the marker
|
|
1449
|
+
outline: true,
|
|
1450
|
+
scale: [1.2, 1.2],
|
|
1451
|
+
title: "Zurich", // native tooltip
|
|
1452
|
+
});
|
|
1453
|
+
```
|
|
1454
|
+
|
|
1455
|
+
The appearance options have matching setters and getters, such as `setShape()`, `setSize()` or `getContent()`.
|
|
1456
|
+
|
|
1457
|
+
Unless you set them, the marker's colours (`innerColor`, `outerColor`, `contentColor` and `outlineColor`) are picked for the current MapTiler style and update when the style changes. A colour you set explicitly stays fixed, and setting it back to `undefined` returns it to the style's colour:
|
|
1458
|
+
|
|
1459
|
+
```ts
|
|
1460
|
+
marker.setInnerColor("#ff5a1f");
|
|
1461
|
+
marker.setInnerColor(undefined); // back to the style's colour
|
|
1462
|
+
```
|
|
1463
|
+
|
|
1464
|
+
Instead of text, a marker can show an image, or any HTML or SVG element, for example one managed by React:
|
|
1465
|
+
|
|
1466
|
+
```ts
|
|
1467
|
+
new Marker({ url: "https://example.com/icon.svg" });
|
|
1468
|
+
new Marker({ element: myElement });
|
|
1469
|
+
```
|
|
1470
|
+
|
|
1471
|
+
With `element`, the shape and size options do not apply. The colour and shadow options are set on the element as CSS custom properties, so its own styles can use them.
|
|
1472
|
+
|
|
1473
|
+
#### Collisions
|
|
1474
|
+
|
|
1475
|
+
By default, markers are always shown even when they overlap. To declutter the map, choose what happens when markers collide. Where markers overlap, the one with the higher `priority` wins:
|
|
1476
|
+
|
|
1477
|
+
```ts
|
|
1478
|
+
// default for every marker on the map
|
|
1479
|
+
map.setMarkerCollisionOptions({ behaviour: "hide-by-priority" });
|
|
1480
|
+
|
|
1481
|
+
// or per marker
|
|
1482
|
+
new Marker({ priority: 10, collisionBehaviour: "minimize-by-priority" });
|
|
1483
|
+
```
|
|
1484
|
+
|
|
1485
|
+
- `always-show`: never hidden (the default)
|
|
1486
|
+
- `hide-by-priority`: hidden behind a higher-priority marker
|
|
1487
|
+
- `minimize-by-priority`: shrinks to a small dot behind a higher-priority marker. `minimizedOptions` changes how the minimized marker looks.
|
|
1488
|
+
|
|
1489
|
+
`setMarkerCollisionOptions()` also sets the `proximityPadding` used for `markerproximity` events and the duration and easing of the hide and show fade. `marker.getCollisionDisplayState()` returns `"visible"`, `"hidden"` or `"minimized"`.
|
|
1490
|
+
|
|
1491
|
+
Markers fire `markeroverlap` and `markerproximity` when other markers start or stop colliding with them:
|
|
1492
|
+
|
|
1493
|
+
```ts
|
|
1494
|
+
marker.on("markeroverlap", ({ entered, exited, current }) => {
|
|
1495
|
+
console.log(`${current.length} markers overlap this one`);
|
|
1496
|
+
});
|
|
1497
|
+
```
|
|
1498
|
+
|
|
1499
|
+
#### Interaction states
|
|
1500
|
+
|
|
1501
|
+
Change a marker's look while it is hovered, focused, pressed or dragged. The marker returns to its own values when the state ends:
|
|
1502
|
+
|
|
1503
|
+
```ts
|
|
1504
|
+
const marker = new Marker({
|
|
1505
|
+
draggable: true,
|
|
1506
|
+
states: {
|
|
1507
|
+
hover: { scale: [1.2, 1.2] },
|
|
1508
|
+
active: { shadow: "strong" },
|
|
1509
|
+
dragging: { opacity: 0.6 },
|
|
1510
|
+
},
|
|
1511
|
+
});
|
|
1512
|
+
|
|
1513
|
+
marker.setUIState("focus", { outline: 3 });
|
|
1514
|
+
```
|
|
1515
|
+
|
|
1516
|
+
#### Transitions
|
|
1517
|
+
|
|
1518
|
+
Ease a property to its new value instead of jumping to it. `position`, `scale`, `rotation` and the four colours can be transitioned, each with `[duration, easing?, delay?]`:
|
|
1519
|
+
|
|
1520
|
+
```ts
|
|
1521
|
+
const marker = new Marker({
|
|
1522
|
+
transitions: {
|
|
1523
|
+
position: [600, "QuadraticInOut"],
|
|
1524
|
+
innerColor: [300],
|
|
1525
|
+
},
|
|
1526
|
+
});
|
|
1527
|
+
|
|
1528
|
+
marker.setLngLat([8.6, 47.4]); // glides to the new position
|
|
1529
|
+
marker.setTransitionForProperty("scale", [200, "CubicOut"]);
|
|
1530
|
+
```
|
|
1531
|
+
|
|
1532
|
+
The `transitionstart` and `transitionend` events report the property being transitioned.
|
|
1533
|
+
|
|
1534
|
+
#### Animations
|
|
1535
|
+
|
|
1536
|
+
Play an animation when a marker is added, loop one while it is on the map, and play another when it is removed:
|
|
1537
|
+
|
|
1538
|
+
```ts
|
|
1539
|
+
const marker = new Marker({
|
|
1540
|
+
animations: {
|
|
1541
|
+
enter: { preset: "drop" }, // "grow" | "drop" | "pop" | "bounce" | "fade"
|
|
1542
|
+
idle: { preset: "pulsescale", iterations: 3 }, // "pulsescale" | "pulseopacity" | "ring" | "bounce"
|
|
1543
|
+
exit: { preset: "fade", duration: 300 }, // "shrink" | "fade" | "pop" | "explode"
|
|
1544
|
+
},
|
|
1545
|
+
});
|
|
1546
|
+
|
|
1547
|
+
map.addMarker(marker); // plays "drop"
|
|
1548
|
+
map.removeMarker(marker.id); // plays "fade", then removes the marker
|
|
1549
|
+
map.removeMarker(marker.id, { immediate: true }); // removes it without the exit animation
|
|
1550
|
+
```
|
|
1551
|
+
|
|
1552
|
+
Each animation also accepts `duration`, `delay`, `easing` and `magnitude`. Instead of a preset, `custom` takes a function called every frame with the animation's progress (`0` to `1`) and the marker. Animations fire events such as `enteranimationstart`, `idleanimationiteration` and `exitanimationend`.
|
|
1553
|
+
|
|
1554
|
+
#### Altitude (experimental)
|
|
1555
|
+
|
|
1556
|
+
Raise a marker above the ground. The marker is placed in 3D, so it stays in the right place as the camera moves, with terrain and under globe projection:
|
|
1557
|
+
|
|
1558
|
+
```ts
|
|
1559
|
+
marker.setAltitude(500); // 500 m above the terrain under the marker
|
|
1560
|
+
marker.setAltitude(1200, { relativeTo: "sea" }); // 1200 m above sea level
|
|
1561
|
+
marker.setAltitude(false); // back on the map surface
|
|
1562
|
+
|
|
1563
|
+
marker.setGroundLine(true); // dashed line from the marker down to the ground
|
|
1564
|
+
```
|
|
1565
|
+
|
|
1566
|
+
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
|
+
|
|
1568
|
+
#### The MapLibre marker
|
|
1569
|
+
|
|
1570
|
+
Compared with the MapLibre marker:
|
|
1571
|
+
- The `color` option is removed. Use `innerColor`, `outerColor`, `contentColor` and `outlineColor`.
|
|
1572
|
+
- `scale` is a 2D vector, `[x, y]`.
|
|
1573
|
+
- `setRotation()` rotates the marker's shape rather than its container.
|
|
1574
|
+
|
|
1575
|
+
The plain MapLibre marker is still available as `MarkerMLGL`:
|
|
1576
|
+
|
|
1577
|
+
```ts
|
|
1578
|
+
import { MarkerMLGL } from "@maptiler/sdk";
|
|
1579
|
+
|
|
1580
|
+
new MarkerMLGL({ color: "#f00" }).setLngLat([8.54, 47.37]).addTo(map);
|
|
1581
|
+
```
|
|
1582
|
+
|
|
1583
|
+
See `demos/16-maptiler-markers.html` to `demos/20-marker-altitude.html` for examples.
|
|
1584
|
+
|
|
1409
1585
|
### Camera routes and animations
|
|
1410
1586
|
|
|
1411
1587
|
The SDK comes with several classes to help with animations, particularly route animations.
|
|
@@ -1438,7 +1614,8 @@ const marker = new Marker().setLngLat(
|
|
|
1438
1614
|
-7.449346225791231,
|
|
1439
1615
|
39.399728941536836,
|
|
1440
1616
|
)
|
|
1441
|
-
)
|
|
1617
|
+
);
|
|
1618
|
+
map.addMarker(marker);
|
|
1442
1619
|
|
|
1443
1620
|
// TimeUpdate is fired every frame
|
|
1444
1621
|
animation.addEventListener(AnimationEventTypes.TimeUpdate, (e) => {
|
|
@@ -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';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LngLat, Marker, Point, PositionAnchor, TransformConstrainFunction } from '../index';
|
|
1
|
+
import { LngLat, MarkerMLGL as Marker, Point, PositionAnchor, TransformConstrainFunction } from '../index';
|
|
2
2
|
export declare function unprojectFromWorldCoordinates(worldSize: number, point: Point): LngLat;
|
|
3
3
|
export declare const overpanningUnderzoomingTransformConstrain: TransformConstrainFunction;
|
|
4
4
|
export declare const anchorTranslate: Record<PositionAnchor, string>;
|
package/dist/Map.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { Telemetry } from './Telemetry';
|
|
|
8
8
|
import { CubemapDefinition, CubemapLayer, CubemapLayerConstructorOptions } from './custom-layers/CubemapLayer';
|
|
9
9
|
import { GradientDefinition, RadialGradientLayer, RadialGradientLayerConstructorOptions } from './custom-layers/RadialGradientLayer';
|
|
10
10
|
import { StyleSpecificationWithMetaData } from './custom-layers/extractCustomLayerStyle';
|
|
11
|
+
import { MapTilerMarkerOptions, Marker, MarkerCollisionOptions, RemoveMarkerOptions } from '.';
|
|
11
12
|
export type LoadWithTerrainEvent = {
|
|
12
13
|
type: "loadWithTerrain";
|
|
13
14
|
target: Map;
|
|
@@ -55,6 +56,25 @@ export type MaptilerMapEventType = {
|
|
|
55
56
|
* so the SDK `Map` overrides them to accept its own events as well.
|
|
56
57
|
*/
|
|
57
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
|
+
};
|
|
58
78
|
export declare const GeolocationType: {
|
|
59
79
|
POINT: "POINT";
|
|
60
80
|
COUNTRY: "COUNTRY";
|
|
@@ -64,6 +84,11 @@ export declare const GeolocationType: {
|
|
|
64
84
|
* if falls back to the default Mercator
|
|
65
85
|
*/
|
|
66
86
|
export type ProjectionTypes = "mercator" | "globe" | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Default zoom at/above which a `"globe"` projection request switches to flat mercator — see
|
|
89
|
+
* {@link MapOptions.globeMercatorSwitchZoom}.
|
|
90
|
+
*/
|
|
91
|
+
export declare const DEFAULT_GLOBE_MERCATOR_SWITCH_ZOOM = 11;
|
|
67
92
|
/**
|
|
68
93
|
* The {@link AttributionControl} options object
|
|
69
94
|
*/
|
|
@@ -196,6 +221,26 @@ export type MapOptions = Omit<MapOptionsML, "style" | "maplibreLogo" | "attribut
|
|
|
196
221
|
* If not provided, the style takes precedence. If provided, overwrite the style.
|
|
197
222
|
*/
|
|
198
223
|
projection?: ProjectionTypes;
|
|
224
|
+
/**
|
|
225
|
+
* MapLibre's plain `type: "globe"` already resolves to
|
|
226
|
+
* `["interpolate", ["linear"], ["zoom"], 11, "vertical-perspective", 12, "mercator"]` —
|
|
227
|
+
* vertical-perspective below zoom 11, linearly blended into flat mercator between 11 and 12.
|
|
228
|
+
* That blend is a MapLibre bug for anything that places objects via its per-projection model
|
|
229
|
+
* matrix (marker altitude, `maptiler-3d-js`): the matrix isn't well-defined mid-blend, only
|
|
230
|
+
* once it's settled fully at one end, so objects placed while zooming through 11-12 jump
|
|
231
|
+
* around.
|
|
232
|
+
*
|
|
233
|
+
* Whenever a projection change resolves to `"globe"` (constructor option, `setProjection`, or
|
|
234
|
+
* the {@link MaptilerProjectionControl}), the SDK requests
|
|
235
|
+
* `{ type: ["step", ["zoom"], "vertical-perspective", globeMercatorSwitchZoom, "mercator"] }`
|
|
236
|
+
* instead of the literal string — spherical below this zoom, flat mercator at and above it,
|
|
237
|
+
* snapping instantly at the threshold instead of blending across that zoom band.
|
|
238
|
+
*
|
|
239
|
+
* Set to `false` to request MapLibre's own `"globe"` literally instead, blend bug and all.
|
|
240
|
+
*
|
|
241
|
+
* Default: `11`
|
|
242
|
+
*/
|
|
243
|
+
globeMercatorSwitchZoom?: number | false;
|
|
199
244
|
/**
|
|
200
245
|
* Turn on/off spacebox.
|
|
201
246
|
*
|
|
@@ -242,24 +287,24 @@ export declare class Map extends MapMLGL {
|
|
|
242
287
|
* Adds a listener for events of a specified type, optionally limited to features in one or more layers.
|
|
243
288
|
* Accepts the MapLibre events as well as the SDK events (see {@link MaptilerMapEventType}).
|
|
244
289
|
*/
|
|
245
|
-
on<T extends keyof MapLayerEventType>(type: T, layerIds: string | string[], listener: (ev:
|
|
246
|
-
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;
|
|
247
292
|
on(type: keyof MapEventTypeSDK, listener: Listener): Subscription;
|
|
248
293
|
/**
|
|
249
294
|
* Adds a listener that will be called only once to a specified event type, optionally limited to features in one or more layers.
|
|
250
295
|
* Accepts the MapLibre events as well as the SDK events (see {@link MaptilerMapEventType}).
|
|
251
296
|
*/
|
|
252
|
-
once<T extends keyof MapLayerEventType>(type: T, layerIds: string | string[], listener: (ev:
|
|
253
|
-
once<T extends keyof MapLayerEventType>(type: T, layerIds: string | string[]): Promise<
|
|
254
|
-
once<T extends keyof MapEventTypeSDK>(type: T, listener: (ev:
|
|
255
|
-
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>>;
|
|
256
301
|
once(type: keyof MapEventTypeSDK, listener?: Listener): this | Promise<any>;
|
|
257
302
|
/**
|
|
258
303
|
* Removes an event listener previously added with {@link Map.on} or {@link Map.once}.
|
|
259
304
|
* Accepts the MapLibre events as well as the SDK events (see {@link MaptilerMapEventType}).
|
|
260
305
|
*/
|
|
261
|
-
off<T extends keyof MapLayerEventType>(type: T, layerIds: string | string[], listener: (ev:
|
|
262
|
-
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;
|
|
263
308
|
off(type: keyof MapEventTypeSDK, listener: Listener): this;
|
|
264
309
|
/**
|
|
265
310
|
* Fires an event. Accepts the MapLibre events as well as the SDK events (see {@link MaptilerMapEventType}).
|
|
@@ -323,6 +368,7 @@ export declare class Map extends MapMLGL {
|
|
|
323
368
|
private terrainAnimationDuration;
|
|
324
369
|
private monitoredStyleUrls;
|
|
325
370
|
private styleInProcess;
|
|
371
|
+
private currentStyleId?;
|
|
326
372
|
private curentProjection;
|
|
327
373
|
private originalLabelStyle;
|
|
328
374
|
private isStyleLocalized;
|
|
@@ -372,6 +418,13 @@ export declare class Map extends MapMLGL {
|
|
|
372
418
|
*/
|
|
373
419
|
setStyle(style: null | ReferenceMapStyle | MapStyleVariant | StyleSpecification | StyleSpecificationWithMetaData | string, options?: StyleSwapOptions & StyleOptions): this;
|
|
374
420
|
private spaceboxLoadingState;
|
|
421
|
+
/**
|
|
422
|
+
* Returns the id of the current MapTiler style (e.g. `"streets-v4-dark"`),
|
|
423
|
+
* derived from the value passed to the constructor or `setStyle`.
|
|
424
|
+
* `undefined` when the style is a custom `StyleSpecification` or a URL that
|
|
425
|
+
* doesn't follow the MapTiler Cloud `/maps/<id>/style.json` shape.
|
|
426
|
+
*/
|
|
427
|
+
getStyleId(): string | undefined;
|
|
375
428
|
/**
|
|
376
429
|
* Adds a [MapLibre style layer](https://maplibre.org/maplibre-style-spec/layers)
|
|
377
430
|
* to the map's style.
|
|
@@ -423,6 +476,49 @@ export declare class Map extends MapMLGL {
|
|
|
423
476
|
* ```
|
|
424
477
|
*/
|
|
425
478
|
removeLayer(id: string): this;
|
|
479
|
+
/**
|
|
480
|
+
* Adds a marker to the map, registering it for collision handling and style-aware colours.
|
|
481
|
+
* Plays the marker's `enter` animation, if it has one.
|
|
482
|
+
* @param markerOrMarkerConfig - A `Marker`, or the options to create one from.
|
|
483
|
+
*/
|
|
484
|
+
addMarker(markerOrMarkerConfig: Marker | MapTilerMarkerOptions): this;
|
|
485
|
+
/**
|
|
486
|
+
* Removes a marker from the map, playing its `exit` animation first, if it has one.
|
|
487
|
+
* @param id - Id of the marker to remove.
|
|
488
|
+
* @param options.immediate - Removes the marker straight away, without its `exit` animation.
|
|
489
|
+
*/
|
|
490
|
+
removeMarker(id: string, options?: RemoveMarkerOptions): this;
|
|
491
|
+
/**
|
|
492
|
+
* Adds several markers to the map. See {@link Map.addMarker}.
|
|
493
|
+
* @param markers - `Marker`s, or the options to create them from.
|
|
494
|
+
*/
|
|
495
|
+
addMarkers(markers: (Marker | MapTilerMarkerOptions)[]): this;
|
|
496
|
+
/**
|
|
497
|
+
* Removes several markers from the map, playing their `exit` animations first, if they have them.
|
|
498
|
+
* @param markerIds - Ids of the markers to remove. Removes every marker when omitted.
|
|
499
|
+
* @param options.immediate - Removes the markers straight away, without their `exit` animations.
|
|
500
|
+
*/
|
|
501
|
+
removeMarkers(markerIds?: string[], options?: RemoveMarkerOptions): this;
|
|
502
|
+
/** Returns every marker added to the map. */
|
|
503
|
+
getMarkers(): Marker[];
|
|
504
|
+
/** Returns the marker with the given id, or `undefined` if it isn't on the map. */
|
|
505
|
+
getMarker(id: string): Marker | undefined;
|
|
506
|
+
/**
|
|
507
|
+
* Configures marker collision detection for this map.
|
|
508
|
+
* @param options.proximityPadding - Distance in CSS px within which two
|
|
509
|
+
* markers count as "in proximity". Overlap always uses 0.
|
|
510
|
+
* @param options.accuracy - `high` (default) tests rotated markers with
|
|
511
|
+
* their actual rotated box; `low` uses the upright box enclosing it,
|
|
512
|
+
* which is cheaper per pair but over-reports collisions for rotated
|
|
513
|
+
* markers (it never misses a real one).
|
|
514
|
+
* @param options.behaviour - Default collision behaviour applied to every
|
|
515
|
+
* marker on this map (`always-show` | `hide-by-priority` |
|
|
516
|
+
* `minimize-by-priority`). A marker's own `collisionBehaviour` option
|
|
517
|
+
* overrides it. Defaults to `always-show`.
|
|
518
|
+
* @param options.transitionDuration - Duration in ms of the hide/show/minimize fade. Defaults to `150`.
|
|
519
|
+
* @param options.transitionEasing - CSS easing function for the fade. Defaults to `"ease"`.
|
|
520
|
+
*/
|
|
521
|
+
setMarkerCollisionOptions(options: MarkerCollisionOptions): this;
|
|
426
522
|
/**
|
|
427
523
|
* Sets the zoom extent for the specified style layer. The zoom extent includes the
|
|
428
524
|
* [minimum zoom level](https://maplibre.org/maplibre-style-spec/layers/#minzoom)
|
|
@@ -571,7 +667,11 @@ export declare class Map extends MapMLGL {
|
|
|
571
667
|
*/
|
|
572
668
|
getProjection(): ProjectionSpecification;
|
|
573
669
|
/**
|
|
574
|
-
* Returns whether a globe projection is currently
|
|
670
|
+
* Returns whether a globe-family projection is currently configured — `"globe"`,
|
|
671
|
+
* `"vertical-perspective"`, or the `globeMercatorSwitchZoom` step expression this class
|
|
672
|
+
* requests for `"globe"` (see {@link MapOptions.globeMercatorSwitchZoom}). This reflects the
|
|
673
|
+
* configured projection, not the instantaneous rendered state — under the step expression it
|
|
674
|
+
* stays `true` even after zooming past the switch threshold into flat mercator rendering.
|
|
575
675
|
*/
|
|
576
676
|
isGlobeProjection(): boolean;
|
|
577
677
|
/**
|