@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
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { LngLat } from '../index';
|
|
2
|
+
import { MaptilerAnimation } from '../MaptilerAnimation';
|
|
3
|
+
import { MarkerTransitionSpec, Vector2 } from './types';
|
|
4
|
+
import { LifecycleAnimationValue } from './marker-animation-presets';
|
|
5
|
+
/** Bridges a transitionable property's real value to/from the flat numeric props {@link MaptilerAnimation} interpolates between. */
|
|
6
|
+
export type TransitionValueCodec<T> = {
|
|
7
|
+
toNumeric(value: T): Record<string, number>;
|
|
8
|
+
fromNumeric(props: Record<string, number>): T;
|
|
9
|
+
};
|
|
10
|
+
export declare const scaleTransitionCodec: TransitionValueCodec<Vector2>;
|
|
11
|
+
export declare const rotationTransitionCodec: TransitionValueCodec<number>;
|
|
12
|
+
export declare const opacityTransitionCodec: TransitionValueCodec<number>;
|
|
13
|
+
/** Bridges an `enter`/`exit` preset's combined opacity/scale/lift state to the numeric props {@link MaptilerAnimation} interpolates between. */
|
|
14
|
+
export declare const lifecycleTransitionCodec: TransitionValueCodec<LifecycleAnimationValue>;
|
|
15
|
+
export declare const positionTransitionCodec: TransitionValueCodec<LngLat>;
|
|
16
|
+
export declare const colorTransitionCodec: TransitionValueCodec<string | undefined>;
|
|
17
|
+
export type PropertyTransitionHandlers<T> = {
|
|
18
|
+
codec: TransitionValueCodec<T>;
|
|
19
|
+
onUpdate: (value: T) => void;
|
|
20
|
+
onStart: () => void;
|
|
21
|
+
onEnd: (value: T) => void;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Eases `from` to `to` over `spec`'s duration/easing/delay via a one-shot
|
|
25
|
+
* {@link MaptilerAnimation}, calling `onUpdate` every frame and `onEnd` once
|
|
26
|
+
* with the exact target value. The returned animation is already playing;
|
|
27
|
+
* callers own its lifetime — `.destroy()` it to cancel.
|
|
28
|
+
*/
|
|
29
|
+
export declare function runPropertyTransition<T>(from: T, to: T, spec: MarkerTransitionSpec, handlers: PropertyTransitionHandlers<T>): MaptilerAnimation;
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
import { Event as EventML, LngLatLike, MarkerEventType, MarkerOptions } from 'maplibre-gl';
|
|
2
|
+
import { EasingFunctionName } from '../MaptilerAnimation/types';
|
|
3
|
+
import { Marker } from './Marker';
|
|
4
|
+
import { MapTilerMarkerIcon } from './marker-icons';
|
|
5
|
+
/** Visual shape of the marker body. */
|
|
6
|
+
export type MapTilerMarkerShape = "circle" | "square" | "bubble-circle" | "bubble-square" | "maptiler" | "maptiler-full";
|
|
7
|
+
/** T-shirt size for the marker. */
|
|
8
|
+
export type MapTilerMarkerSize = "xs" | "s" | "m" | "l";
|
|
9
|
+
/** Drop-shadow intensity applied beneath the marker. */
|
|
10
|
+
export type MapTilerMarkerShadow = "none" | "soft" | "medium" | "strong";
|
|
11
|
+
export type { MapTilerMarkerIcon } from './marker-icons';
|
|
12
|
+
/** Behaviour when this marker spatially overlaps another. */
|
|
13
|
+
export declare const CollisionBehaviour: {
|
|
14
|
+
/** No collision detection — marker is always shown. */
|
|
15
|
+
readonly ALWAYS_SHOW: "always-show";
|
|
16
|
+
/** Marker is hidden when it collides with a higher-priority marker. */
|
|
17
|
+
readonly HIDE_BY_PRIORITY: "hide-by-priority";
|
|
18
|
+
/** Marker is minimised to a simple point/circle when colliding with a higher-priority marker. */
|
|
19
|
+
readonly MINIMIZE_BY_PRIORITY: "minimize-by-priority";
|
|
20
|
+
};
|
|
21
|
+
export type CollisionBehaviour = (typeof CollisionBehaviour)[keyof typeof CollisionBehaviour];
|
|
22
|
+
export type Vector2 = [number, number];
|
|
23
|
+
/**
|
|
24
|
+
* Kind of spatial collision between two markers.
|
|
25
|
+
* - `overlap` — the markers' boxes intersect.
|
|
26
|
+
* - `proximity` — the boxes are within the configured proximity padding
|
|
27
|
+
* (a superset of `overlap`).
|
|
28
|
+
*/
|
|
29
|
+
export type MarkerCollisionKind = "overlap" | "proximity";
|
|
30
|
+
/**
|
|
31
|
+
* Payload of the `markeroverlap` / `markerproximity` events.
|
|
32
|
+
*
|
|
33
|
+
* Emitted on state change only: a marker fires when counterparts *enter* or
|
|
34
|
+
* *exit* collision with it, never for collisions that persist unchanged
|
|
35
|
+
* between passes.
|
|
36
|
+
*/
|
|
37
|
+
export type MarkerCollisionEventData = {
|
|
38
|
+
kind: MarkerCollisionKind;
|
|
39
|
+
/** Markers that started colliding with this marker in this pass. */
|
|
40
|
+
entered: Marker[];
|
|
41
|
+
/** Markers that stopped colliding with this marker in this pass (may already be removed from the map). */
|
|
42
|
+
exited: Marker[];
|
|
43
|
+
/** All markers currently colliding with this marker. */
|
|
44
|
+
current: Marker[];
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Sets of mutually-colliding markers from the latest detection pass —
|
|
48
|
+
* connected components of the pairwise collision graph, with no
|
|
49
|
+
* winner/loser resolution applied.
|
|
50
|
+
*/
|
|
51
|
+
export type MarkerCollisionGroups = {
|
|
52
|
+
overlap: Marker[][];
|
|
53
|
+
proximity: Marker[][];
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* How precisely marker collision boxes track rotation.
|
|
57
|
+
* - `high` (default) — rotated markers are tested with their actual rotated
|
|
58
|
+
* box (separating-axis test), so collisions match the rendered footprint.
|
|
59
|
+
* - `low` — rotated markers are tested with the upright box enclosing the
|
|
60
|
+
* rotated one. Cheaper per pair, but over-reports collisions for elongated
|
|
61
|
+
* markers at strong rotations (never misses a real one).
|
|
62
|
+
*/
|
|
63
|
+
export type MarkerCollisionAccuracy = "low" | "high";
|
|
64
|
+
/** Per-map configuration of the marker collision engine. */
|
|
65
|
+
export type MarkerCollisionOptions = {
|
|
66
|
+
/** Distance in CSS px within which two markers count as "in proximity". Overlap always uses 0. */
|
|
67
|
+
proximityPadding?: number;
|
|
68
|
+
/** Collision box accuracy for rotated markers. Defaults to `high`. */
|
|
69
|
+
accuracy?: MarkerCollisionAccuracy;
|
|
70
|
+
/**
|
|
71
|
+
* Default collision behaviour for every marker on the map. A marker's own
|
|
72
|
+
* `collisionBehaviour` option overrides it. Defaults to `always-show`
|
|
73
|
+
* (nothing is ever hidden until a behaviour is opted into).
|
|
74
|
+
*/
|
|
75
|
+
behaviour?: CollisionBehaviour;
|
|
76
|
+
/**
|
|
77
|
+
* Duration in milliseconds of the hide/show/minimize fade transition
|
|
78
|
+
* markers go through under collision behaviours. Defaults to `150`.
|
|
79
|
+
*/
|
|
80
|
+
transitionDuration?: number;
|
|
81
|
+
/**
|
|
82
|
+
* CSS easing function for the fade transition (e.g. `"ease"`,
|
|
83
|
+
* `"ease-in-out"`, `"linear"`, or a `cubic-bezier(...)` expression).
|
|
84
|
+
* Defaults to `"ease"`.
|
|
85
|
+
*/
|
|
86
|
+
transitionEasing?: string;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* How the collision engine is currently displaying a marker.
|
|
90
|
+
* - `visible` — displayed normally.
|
|
91
|
+
* - `hidden` — hidden because it lost to a higher-priority marker
|
|
92
|
+
* (`hide-by-priority`), or sits outside the viewport (off-screen markers
|
|
93
|
+
* are excluded from collision processing and hidden regardless of
|
|
94
|
+
* behaviour).
|
|
95
|
+
* - `minimized` — displayed as its minimized variant (`minimize-by-priority`).
|
|
96
|
+
*/
|
|
97
|
+
export type MarkerCollisionDisplayState = "visible" | "hidden" | "minimized";
|
|
98
|
+
/**
|
|
99
|
+
* Visual overrides applied while a `minimize-by-priority` marker is
|
|
100
|
+
* minimized. Merged over the default minimized appearance (`{ size: "xs" }`,
|
|
101
|
+
* which renders the marker as a small dot in its own colours). The marker's
|
|
102
|
+
* regular values are restored when it un-minimizes.
|
|
103
|
+
*
|
|
104
|
+
* Only affects markers built by the SVG system — markers constructed with a
|
|
105
|
+
* custom `element` minimize to a plain dot, of which only the colour fields
|
|
106
|
+
* apply (consumed as CSS custom properties).
|
|
107
|
+
*/
|
|
108
|
+
export type MarkerMinimizedOptions = Pick<MapTilerMarkerBaseOptions, "shape" | "size" | "innerColor" | "outerColor" | "contentColor" | "outline" | "outlineColor" | "shadow" | "opacity">;
|
|
109
|
+
/**
|
|
110
|
+
* MapLibre-style expression that resolves to a numeric priority.
|
|
111
|
+
* Evaluated by the collision engine, not applied directly to the DOM.
|
|
112
|
+
*/
|
|
113
|
+
export type MarkerPriorityExpression = unknown[];
|
|
114
|
+
/**
|
|
115
|
+
* What {@link Marker.setAltitude}'s meters are measured from.
|
|
116
|
+
* - `ground` (default) — above the terrain surface under the marker's
|
|
117
|
+
* lngLat, via `map.queryTerrainElevation()`. Falls back to the flat
|
|
118
|
+
* mercator plane (sea level) when terrain isn't enabled/loaded — so this
|
|
119
|
+
* is a safe default whether or not the map has terrain.
|
|
120
|
+
* - `sea` — above sea level / the flat mercator plane outright, ignoring
|
|
121
|
+
* terrain entirely, even when it's enabled.
|
|
122
|
+
* @experimental
|
|
123
|
+
*/
|
|
124
|
+
export type AltitudeReference = "ground" | "sea";
|
|
125
|
+
/**
|
|
126
|
+
* Options for {@link Marker.setAltitude}.
|
|
127
|
+
* @experimental
|
|
128
|
+
*/
|
|
129
|
+
export type SetAltitudeOptions = {
|
|
130
|
+
/** What the altitude is measured from. Defaults to `"ground"`. */
|
|
131
|
+
relativeTo?: AltitudeReference;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Configures the optional dashed line from a marker down (or up) to its ground point. Off by default — see {@link Marker.setGroundLine}.
|
|
135
|
+
* @experimental
|
|
136
|
+
*/
|
|
137
|
+
export type GroundLineOptions = {
|
|
138
|
+
/**
|
|
139
|
+
* Extra class applied to the ground-line element alongside the default
|
|
140
|
+
* `maptiler-marker-groundline`. Style colour/width/dashing from your own
|
|
141
|
+
* stylesheet using either selector — the line carries no inline colour so
|
|
142
|
+
* your CSS always wins (see the `:where()`-scoped default in the SDK
|
|
143
|
+
* stylesheet, kept at zero specificity for exactly this reason).
|
|
144
|
+
*/
|
|
145
|
+
className?: string;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Predefined `enter` animation types.
|
|
149
|
+
* - `fade` — opacity only.
|
|
150
|
+
* - `grow` — uniform scale from nothing, plus fade.
|
|
151
|
+
* - `pop` — uniform scale from nothing with a springy overshoot, plus fade.
|
|
152
|
+
* - `drop` — slides straight down into place, plus fade.
|
|
153
|
+
* - `bounce` — slides down into place with a bounce-settle, fully opaque throughout.
|
|
154
|
+
*
|
|
155
|
+
* See `marker-animation-presets.ts` for each preset's exact motion/easing config.
|
|
156
|
+
*/
|
|
157
|
+
export type EnterAnimationPreset = "grow" | "drop" | "pop" | "bounce" | "fade";
|
|
158
|
+
/**
|
|
159
|
+
* Predefined `exit` animation types.
|
|
160
|
+
* - `fade` — opacity only.
|
|
161
|
+
* - `shrink` — uniform scale to nothing, fully opaque throughout.
|
|
162
|
+
* - `pop` — scale to nothing combined with a fade, springy overshoot.
|
|
163
|
+
* - `explode` — scales up (2x) while fading out.
|
|
164
|
+
*
|
|
165
|
+
* See `marker-animation-presets.ts` for each preset's exact motion/easing config.
|
|
166
|
+
*/
|
|
167
|
+
export type ExitAnimationPreset = "shrink" | "fade" | "pop" | "explode";
|
|
168
|
+
/**
|
|
169
|
+
* Predefined `idle` animation types — each loops a single channel out and
|
|
170
|
+
* back to rest once per iteration, peaking at the midpoint (`delta` `0.5`).
|
|
171
|
+
* - `pulsescale` — scales up and back down, ~1 cycle/second by default.
|
|
172
|
+
* - `pulseopacity` — dims and back to full opacity, ~1 cycle/second by default.
|
|
173
|
+
* - `ring` — a rotational shake (several alternating wiggles) clustered around the midpoint, every few seconds by default.
|
|
174
|
+
* - `bounce` — a vertical hop clustered around the midpoint, every few seconds by default.
|
|
175
|
+
*
|
|
176
|
+
* See `marker-animation-presets.ts` for each preset's exact keyframe config.
|
|
177
|
+
*/
|
|
178
|
+
export type IdleAnimationPreset = "pulsescale" | "ring" | "pulseopacity" | "bounce";
|
|
179
|
+
/** Fields shared by every enter/exit/idle animation spec, whether preset-based or {@link MarkerCustomAnimationOptions}. */
|
|
180
|
+
export type MarkerAnimationBase = {
|
|
181
|
+
/** Overrides the preset's default easing. Defaults to `"Linear"`. Also applies to a `custom` animation's `alpha`. */
|
|
182
|
+
easing?: EasingFunctionName;
|
|
183
|
+
/** Duration in milliseconds. Defaults to `1000`. */
|
|
184
|
+
duration?: number;
|
|
185
|
+
/** Delay before the animation starts, in milliseconds. Defaults to `0`. */
|
|
186
|
+
delay?: number;
|
|
187
|
+
};
|
|
188
|
+
/** Configures a marker's `enter`/`exit`/`idle` animation via a predefined preset. */
|
|
189
|
+
export type MarkerPresetAnimationOptions<Preset extends string> = MarkerAnimationBase & {
|
|
190
|
+
/** Predefined animation type. */
|
|
191
|
+
preset: Preset;
|
|
192
|
+
custom?: never;
|
|
193
|
+
/**
|
|
194
|
+
* Scales the preset's motion from rest (`0`) up to its full designed
|
|
195
|
+
* displacement (`1`, the default) — values beyond `1` exaggerate it.
|
|
196
|
+
* Has no effect on presets with no independent "how far" axis.
|
|
197
|
+
*/
|
|
198
|
+
magnitude?: number;
|
|
199
|
+
};
|
|
200
|
+
/** Configures a marker's `enter`/`exit`/`idle` animation via a custom per-frame callback instead of a preset. */
|
|
201
|
+
export type MarkerCustomAnimationOptions = MarkerAnimationBase & {
|
|
202
|
+
preset?: never;
|
|
203
|
+
magnitude?: never;
|
|
204
|
+
/**
|
|
205
|
+
* Called every frame with the already-eased progress (`0`–`1`, `easing`
|
|
206
|
+
* already applied) and the marker being animated. For `enter`, `0` is the
|
|
207
|
+
* starting (hidden) state and `1` is fully shown; for `exit`, `0` is fully
|
|
208
|
+
* shown and `1` is the end (hidden) state; for `idle`, `alpha` resets to
|
|
209
|
+
* `0` at the start of every loop iteration.
|
|
210
|
+
*/
|
|
211
|
+
custom: (alpha: number, marker: Marker) => void;
|
|
212
|
+
};
|
|
213
|
+
/** Configures a marker's `enter` or `exit` lifecycle animation. */
|
|
214
|
+
export type MarkerAnimationOptions<Preset extends string = EnterAnimationPreset | ExitAnimationPreset> = MarkerPresetAnimationOptions<Preset> | MarkerCustomAnimationOptions;
|
|
215
|
+
/** Configures a marker's `idle` lifecycle animation. */
|
|
216
|
+
export type MarkerIdleAnimationOptions = MarkerAnimationOptions<IdleAnimationPreset> & {
|
|
217
|
+
/** Number of loop iterations. Omit, or pass `Infinity`, to loop continuously. */
|
|
218
|
+
iterations?: number;
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Lifecycle animations played as a marker enters, idles on, and exits the map.
|
|
222
|
+
*/
|
|
223
|
+
export type MapTilerMarkerAnimations = {
|
|
224
|
+
/** Played once the marker is added to a map. */
|
|
225
|
+
enter?: MarkerAnimationOptions<EnterAnimationPreset>;
|
|
226
|
+
/**
|
|
227
|
+
* Played when `remove()` is called. The marker stays on the map, still
|
|
228
|
+
* receiving updates, until this animation finishes.
|
|
229
|
+
*/
|
|
230
|
+
exit?: MarkerAnimationOptions<ExitAnimationPreset>;
|
|
231
|
+
/**
|
|
232
|
+
* Looped while the marker sits on the map, after `enter` finishes (or
|
|
233
|
+
* immediately, if no `enter` is configured).
|
|
234
|
+
*/
|
|
235
|
+
idle?: MarkerIdleAnimationOptions;
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Event fired by a marker's lifecycle animations — `enter`/`exit` fire
|
|
239
|
+
* `start`/`end` once each; `idle` additionally fires `iteration` once per loop.
|
|
240
|
+
*/
|
|
241
|
+
export type MarkerLifecycleAnimationEventData = {
|
|
242
|
+
type: "enteranimationstart" | "enteranimationend" | "exitanimationstart" | "exitanimationend" | "idleanimationstart" | "idleanimationiteration" | "idleanimationend";
|
|
243
|
+
target: Marker;
|
|
244
|
+
/** The preset configured for the phase that fired this event, or `"custom"` for a {@link MarkerCustomAnimationOptions} animation. */
|
|
245
|
+
preset: EnterAnimationPreset | ExitAnimationPreset | IdleAnimationPreset | "custom";
|
|
246
|
+
};
|
|
247
|
+
/** Marker properties that can be eased from their old value to a new one instead of snapping. */
|
|
248
|
+
export type MarkerTransitionProperty = "position" | "scale" | "rotation" | "outerColor" | "innerColor" | "contentColor" | "outlineColor";
|
|
249
|
+
/**
|
|
250
|
+
* Configures how a transitionable property eases to a newly-set value.
|
|
251
|
+
* `[duration, easing?, delay?]`, all in milliseconds except `easing`.
|
|
252
|
+
* `easing` is any {@link EasingFunctionName}, defaulting to `"Linear"` when omitted.
|
|
253
|
+
* Defaults to no delay when omitted.
|
|
254
|
+
*/
|
|
255
|
+
export type MarkerTransitionSpec = [duration: number, easing?: EasingFunctionName, delay?: number];
|
|
256
|
+
/** Per-property transition configuration, keyed by {@link MarkerTransitionProperty}. */
|
|
257
|
+
export type MapTilerMarkerTransitions = Partial<Record<MarkerTransitionProperty, MarkerTransitionSpec>>;
|
|
258
|
+
/**
|
|
259
|
+
* Event fired by a marker's `transitionstart` / `transitionend` — the same
|
|
260
|
+
* shape as MapLibre's own marker events (`type`, `target`), plus `props`.
|
|
261
|
+
*/
|
|
262
|
+
export type MarkerTransitionEventData = {
|
|
263
|
+
type: "transitionstart" | "transitionend";
|
|
264
|
+
target: Marker;
|
|
265
|
+
/**
|
|
266
|
+
* The property being transitioned, keyed to its value at the time of the
|
|
267
|
+
* event — the value it's easing from on `transitionstart`, the value it
|
|
268
|
+
* reached on `transitionend`.
|
|
269
|
+
*/
|
|
270
|
+
props: Partial<Record<MarkerTransitionProperty, unknown>>;
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Marker content driven by a built-in icon, drawn in the content colour and
|
|
274
|
+
* sized to the marker (16 / 12 / 8 px for `l` / `m` / `s`; `xs` shows no content).
|
|
275
|
+
*/
|
|
276
|
+
export type MarkerContentTypeIcon = {
|
|
277
|
+
/** Name of a built-in icon. */
|
|
278
|
+
icon: MapTilerMarkerIcon;
|
|
279
|
+
url?: never;
|
|
280
|
+
template?: never;
|
|
281
|
+
templateParams?: never;
|
|
282
|
+
element?: never;
|
|
283
|
+
};
|
|
284
|
+
/** Marker content driven by an image or SVG URL. */
|
|
285
|
+
export type MarkerContentTypeImageUrl = {
|
|
286
|
+
/** URL of an image or SVG to render as marker content. */
|
|
287
|
+
url: string;
|
|
288
|
+
icon?: never;
|
|
289
|
+
template?: never;
|
|
290
|
+
templateParams?: never;
|
|
291
|
+
element?: never;
|
|
292
|
+
};
|
|
293
|
+
/** Marker content driven by a named template and its parameters. */
|
|
294
|
+
export type MarkerContentTypeTemplate = {
|
|
295
|
+
/** Identifier for a registered template factory function. */
|
|
296
|
+
template: string;
|
|
297
|
+
/** Parameters forwarded to the template config function. */
|
|
298
|
+
templateParams?: Record<string, number | string>;
|
|
299
|
+
icon?: never;
|
|
300
|
+
url?: never;
|
|
301
|
+
element?: never;
|
|
302
|
+
};
|
|
303
|
+
/**
|
|
304
|
+
* Marker content driven by an existing DOM or SVG element.
|
|
305
|
+
* Useful when content is managed by a rendering engine such as React.
|
|
306
|
+
*/
|
|
307
|
+
export type MarkerContentTypeElement = {
|
|
308
|
+
/** An HTML or SVG element to use as marker content. */
|
|
309
|
+
element: HTMLElement | SVGElement;
|
|
310
|
+
icon?: never;
|
|
311
|
+
url?: never;
|
|
312
|
+
template?: never;
|
|
313
|
+
templateParams?: never;
|
|
314
|
+
};
|
|
315
|
+
/** Marker with no explicit content — uses the default marker appearance. */
|
|
316
|
+
export type MarkerContentTypeNone = {
|
|
317
|
+
icon?: never;
|
|
318
|
+
url?: never;
|
|
319
|
+
template?: never;
|
|
320
|
+
templateParams?: never;
|
|
321
|
+
element?: never;
|
|
322
|
+
};
|
|
323
|
+
export type MarkerContent = MarkerContentTypeNone | MarkerContentTypeIcon | MarkerContentTypeImageUrl | MarkerContentTypeTemplate | MarkerContentTypeElement;
|
|
324
|
+
/** UI "state" types that can restyle a marker. */
|
|
325
|
+
export type MapTilerMarkerUIStateName = "hover" | "focus" | "active" | "dragging";
|
|
326
|
+
/** Property overrides applied while a UI state is active. Keys are any settable marker property (e.g. `shape`, `opacity`, `scale`). */
|
|
327
|
+
export type UIStateSpec = Partial<MapTilerMarkerElementProps>;
|
|
328
|
+
/** Per-state property overrides, keyed by UI state name. */
|
|
329
|
+
export type MapTilerMarkerUIStates = Partial<Record<MapTilerMarkerUIStateName, UIStateSpec>>;
|
|
330
|
+
export type MapTilerMarkerBaseOptions = Omit<MarkerOptions, "scale" | "opacity" | "opacityWhenCovered" | "color"> & {
|
|
331
|
+
/** Position of the marker. Can also be set later with `setLngLat()`. */
|
|
332
|
+
lngLat?: LngLatLike;
|
|
333
|
+
/** Visual shape of the marker body. Defaults to `"maptiler"`. */
|
|
334
|
+
shape?: MapTilerMarkerShape;
|
|
335
|
+
/** Size of the marker. */
|
|
336
|
+
size?: MapTilerMarkerSize;
|
|
337
|
+
/**
|
|
338
|
+
* Fill colour of the inner area of the marker. Defaults to a colour chosen
|
|
339
|
+
* for the current map style, re-resolved whenever the style changes.
|
|
340
|
+
* Setting it explicitly makes the colour static.
|
|
341
|
+
*/
|
|
342
|
+
innerColor?: string;
|
|
343
|
+
/** Fill colour of the outer area (body/border) of the marker. Defaults to the current map style's colour, like `innerColor`. */
|
|
344
|
+
outerColor?: string;
|
|
345
|
+
/** Colour applied to the marker content (icon, text, etc.). Defaults to the current map style's colour, like `innerColor`. */
|
|
346
|
+
contentColor?: string;
|
|
347
|
+
/** Outline width in pixels. Pass `true` to use the default width. */
|
|
348
|
+
outline?: true | number;
|
|
349
|
+
/** Colour of the marker outline. Defaults to the current map style's colour, like `innerColor`. */
|
|
350
|
+
outlineColor?: string;
|
|
351
|
+
/** Drop-shadow intensity. Defaults per size: `"strong"` at `l`, `"medium"` at `m`, `"soft"` at `s` and `xs`; use `"none"` to disable. */
|
|
352
|
+
shadow?: MapTilerMarkerShadow;
|
|
353
|
+
opacity?: number;
|
|
354
|
+
opacityWhenCovered?: number;
|
|
355
|
+
/**
|
|
356
|
+
* Optional marker name, added as a CSS class on the marker element.
|
|
357
|
+
* Must be safe for use as a CSS class name.
|
|
358
|
+
*/
|
|
359
|
+
name?: string;
|
|
360
|
+
/** Applied to the `title` attribute of the marker's root element (native tooltip). */
|
|
361
|
+
title?: string;
|
|
362
|
+
/** Text content rendered inside the marker body. */
|
|
363
|
+
content?: string;
|
|
364
|
+
/** HTML attributes applied directly to the marker's root element. */
|
|
365
|
+
htmlAttributes?: Record<string, number | string>;
|
|
366
|
+
/** 2-D scale of the marker as `[x, y]`. Defaults to `[1, 1]`. */
|
|
367
|
+
scale?: Vector2;
|
|
368
|
+
/** Initial visibility of the marker. Defaults to `true`. TODO: not implemented yet. */
|
|
369
|
+
visible?: boolean;
|
|
370
|
+
/** Rendering priority used for collision detection. Accepts a numeric value or a MapLibre-style expression. */
|
|
371
|
+
priority?: number | MarkerPriorityExpression;
|
|
372
|
+
/** Lifecycle animations played as the marker enters, idles on, and exits the map. */
|
|
373
|
+
animations?: MapTilerMarkerAnimations;
|
|
374
|
+
/**
|
|
375
|
+
* Per-property easing applied when a transitionable property (`position`,
|
|
376
|
+
* `scale`, `rotation`, or a colour) is next set, instead of the change
|
|
377
|
+
* snapping immediately. See {@link setTransitionForProperty}.
|
|
378
|
+
*/
|
|
379
|
+
transitions?: MapTilerMarkerTransitions;
|
|
380
|
+
/** Arbitrary user-defined data attached to the marker instance. */
|
|
381
|
+
userData?: Record<string, unknown>;
|
|
382
|
+
/** Behaviour when this marker spatially overlaps another. Overrides the map-level default (see `MarkerCollisionOptions`). */
|
|
383
|
+
collisionBehaviour?: CollisionBehaviour;
|
|
384
|
+
/**
|
|
385
|
+
* Visual overrides applied while the marker is minimized by the
|
|
386
|
+
* `minimize-by-priority` collision behaviour. Merged over the default
|
|
387
|
+
* minimized appearance (`{ size: "xs" }`).
|
|
388
|
+
*/
|
|
389
|
+
minimizedOptions?: MarkerMinimizedOptions;
|
|
390
|
+
/** When `true`, renders a debug overlay showing the marker's bounding box and center point. */
|
|
391
|
+
debug?: boolean;
|
|
392
|
+
/**
|
|
393
|
+
* Collision detection radius in pixels.
|
|
394
|
+
* `0` means the marker's bounding box is used.
|
|
395
|
+
*/
|
|
396
|
+
collisionRadius?: number;
|
|
397
|
+
/**
|
|
398
|
+
* Per-state property overrides applied while the marker is hovered,
|
|
399
|
+
* focused, active (pointer down), or being dragged.
|
|
400
|
+
*/
|
|
401
|
+
states?: MapTilerMarkerUIStates;
|
|
402
|
+
};
|
|
403
|
+
/**
|
|
404
|
+
* Subset of {@link MapTilerMarkerBaseOptions} that applies when an external
|
|
405
|
+
* DOM/SVG element is supplied as marker content. SVG-only layout fields
|
|
406
|
+
* (`shape`, `size`) are omitted because they only affect SVG generation.
|
|
407
|
+
* Color/shadow options are retained — they are applied as CSS custom properties
|
|
408
|
+
* on the supplied element and can be consumed by its styles.
|
|
409
|
+
*/
|
|
410
|
+
export type MapTilerMarkerBehaviourOptions = Omit<MapTilerMarkerBaseOptions, "shape" | "size">;
|
|
411
|
+
/** Options for a marker whose content is a pre-built DOM/SVG element. */
|
|
412
|
+
export type MapTilerMarkerElementOptions = MapTilerMarkerBehaviourOptions & MarkerContentTypeElement;
|
|
413
|
+
/** Options for a marker whose content is generated from the built-in SVG system. */
|
|
414
|
+
export type MapTilerMarkerSVGOptions = MapTilerMarkerBaseOptions & Exclude<MarkerContent, MarkerContentTypeElement>;
|
|
415
|
+
type MapTilerMarkerElementPropKeys = "shape" | "outerColor" | "innerColor" | "contentColor" | "outline" | "outlineColor" | "shadow" | "opacity" | "title" | "content" | "htmlAttributes" | "rotation" | "scale" | "size" | "debug" | "priority";
|
|
416
|
+
export type MapTilerMarkerElementProps = Pick<MapTilerMarkerBaseOptions, MapTilerMarkerElementPropKeys>;
|
|
417
|
+
export type MapTilerMarkerOptions = MapTilerMarkerBaseOptions & MarkerContent;
|
|
418
|
+
/**
|
|
419
|
+
* Batch of property updates waiting to be flushed to the DOM.
|
|
420
|
+
* A key being present (even with an `undefined` value) means "apply this
|
|
421
|
+
* property" — e.g. `{ shadow: undefined }` resets the shadow to its default.
|
|
422
|
+
*/
|
|
423
|
+
export type PendingMarkerUpdates = Partial<MapTilerMarkerElementProps>;
|
|
424
|
+
/** Options for `map.removeMarker()` and `map.removeMarkers()`. */
|
|
425
|
+
export type RemoveMarkerOptions = {
|
|
426
|
+
/** Removes the markers straight away, without playing their `exit` animation. Defaults to `false`. */
|
|
427
|
+
immediate?: boolean;
|
|
428
|
+
};
|
|
429
|
+
/**
|
|
430
|
+
* Shape of an event fired by the SDK `Marker` on top of the MapLibre events,
|
|
431
|
+
* with the properties passed to `fire(type, properties)` merged in.
|
|
432
|
+
*/
|
|
433
|
+
type SDKMarkerEvent<TType extends string, TProps extends object = object> = EventML<TType> & {
|
|
434
|
+
target: Marker;
|
|
435
|
+
} & TProps;
|
|
436
|
+
type LifecycleAnimationEvent<TType extends MarkerLifecycleAnimationEventData["type"]> = SDKMarkerEvent<TType, Pick<MarkerLifecycleAnimationEventData, "preset">>;
|
|
437
|
+
/**
|
|
438
|
+
* Events fired by the MapTiler SDK `Marker` in addition to the MapLibre ones.
|
|
439
|
+
*/
|
|
440
|
+
export type MaptilerMarkerEventType = {
|
|
441
|
+
markeroverlap: SDKMarkerEvent<"markeroverlap", MarkerCollisionEventData>;
|
|
442
|
+
markerproximity: SDKMarkerEvent<"markerproximity", MarkerCollisionEventData>;
|
|
443
|
+
transitionstart: SDKMarkerEvent<"transitionstart", Pick<MarkerTransitionEventData, "props">>;
|
|
444
|
+
transitionend: SDKMarkerEvent<"transitionend", Pick<MarkerTransitionEventData, "props">>;
|
|
445
|
+
enteranimationstart: LifecycleAnimationEvent<"enteranimationstart">;
|
|
446
|
+
enteranimationend: LifecycleAnimationEvent<"enteranimationend">;
|
|
447
|
+
exitanimationstart: LifecycleAnimationEvent<"exitanimationstart">;
|
|
448
|
+
exitanimationend: LifecycleAnimationEvent<"exitanimationend">;
|
|
449
|
+
idleanimationstart: LifecycleAnimationEvent<"idleanimationstart">;
|
|
450
|
+
idleanimationiteration: LifecycleAnimationEvent<"idleanimationiteration">;
|
|
451
|
+
idleanimationend: LifecycleAnimationEvent<"idleanimationend">;
|
|
452
|
+
};
|
|
453
|
+
/**
|
|
454
|
+
* All the events that can be listened to on a MapTiler SDK `Marker`: the MapLibre ones plus the SDK ones.
|
|
455
|
+
* MapLibre's `on`/`once`/`off` only accept the keys of `MarkerEventType`,
|
|
456
|
+
* so the SDK `Marker` overrides them to accept its own events as well.
|
|
457
|
+
*/
|
|
458
|
+
export type MarkerEventTypeSDK = MarkerEventType & MaptilerMarkerEventType;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type * from 'maplibre-gl';
|
|
2
|
+
export type { Marker as MLMarker } from 'maplibre-gl';
|
|
2
3
|
/**
|
|
3
4
|
* Get the version of MapTiler SDK, this is declared in the vite config
|
|
4
5
|
* to avoid importing the entire package.json
|
|
@@ -6,8 +7,10 @@ export type * from 'maplibre-gl';
|
|
|
6
7
|
export declare function getVersion(): string;
|
|
7
8
|
export { setRTLTextPlugin, getRTLTextPluginStatus, LngLat, LngLatBounds, MercatorCoordinate, Evented, AJAXError, clearPrewarmedResources, Hash, Point, EdgeInsets, DragRotateHandler, DragPanHandler, TwoFingersTouchZoomRotateHandler, DoubleClickZoomHandler, TwoFingersTouchZoomHandler, TwoFingersTouchRotateHandler, getWorkerCount, setWorkerCount, getMaxParallelImageRequests, setMaxParallelImageRequests, getWorkerUrl, setWorkerUrl, addSourceType, importScriptInWorkers, addProtocol, removeProtocol, } from 'maplibre-gl';
|
|
8
9
|
export { getVersion as getMapLibreVersion, Map as MapMLGL, Marker as MarkerMLGL, Popup as PopupMLGL, Style as StyleMLGL, CanvasSource as CanvasSourceMLGL, GeoJSONSource as GeoJSONSourceMLGL, ImageSource as ImageSourceMLGL, RasterTileSource as RasterTileSourceMLGL, RasterDEMTileSource as RasterDEMTileSourceMLGL, VectorTileSource as VectorTileSourceMLGL, VideoSource as VideoSourceMLGL, NavigationControl as NavigationControMLGL, GeolocateControl as GeolocateControlMLGL, AttributionControl as AttributionControlMLGL, LogoControl as LogoControlMLGL, ScaleControl as ScaleControlMLGL, FullscreenControl as FullscreenControlMLGL, TerrainControl as TerrainControMLGL, BoxZoomHandler as BoxZoomHandlerMLGL, ScrollZoomHandler as ScrollZoomHandlerMLGL, CooperativeGesturesHandler as CooperativeGesturesHandlerMLGL, KeyboardHandler as KeyboardHandlerMLGL, TwoFingersTouchPitchHandler as TwoFingersTouchPitchHandlerMLGL, MapWheelEvent as MapWheelEventMLGL, MapTouchEvent as MapTouchEventMLGL, MapMouseEvent as MapMouseEventMLGL, config as configMLGL, } from 'maplibre-gl';
|
|
9
|
-
export
|
|
10
|
-
export {
|
|
10
|
+
export * from './Marker';
|
|
11
|
+
export { Marker } from './Marker';
|
|
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, type MapEventSDK, type MapLayerEventSDK, } from './Map';
|
|
11
14
|
export type { CameraPosition, TilePreloadOptions, WithTilePreload, PreloadTilesForBoundsOptions, PreloadTilesForCameraPositionsOptions, PreloadTilesOptions, TilePreloadErrorCallback, TilePreloadProgressCallback, } from './tile-preloading';
|
|
12
15
|
export { type BaseGeocodingOptions, type ByIdGeocodingOptions, type CommonForwardAndReverseGeocodingOptions, type GeocodingOptions, type LanguageGeocodingOptions, type ReverseGeocodingOptions, geocoding, } from './geocoding';
|
|
13
16
|
export * from './controls';
|
package/dist/mapstyle.d.ts
CHANGED
|
@@ -16,4 +16,11 @@ type StyleValidationReport = {
|
|
|
16
16
|
styleObject: StyleSpecification | null;
|
|
17
17
|
};
|
|
18
18
|
export declare function convertStringToStyleSpecification(str: string): StyleValidationReport;
|
|
19
|
+
/**
|
|
20
|
+
* Derives the MapTiler style id (e.g. `"streets-v4-dark"`) from a style input,
|
|
21
|
+
* without expanding or fetching it.
|
|
22
|
+
* Returns `undefined` for custom `StyleSpecification`s and URLs that don't
|
|
23
|
+
* follow the MapTiler Cloud `/maps/<id>/style.json` shape.
|
|
24
|
+
*/
|
|
25
|
+
export declare function styleToStyleId(style: string | ReferenceMapStyle | MapStyleVariant | StyleSpecification | null | undefined): string | undefined;
|
|
19
26
|
export {};
|