maplibre-gl-layers 0.16.0 → 0.17.0
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 +2 -2
- package/dist/SpriteLayer.d.ts +3 -3
- package/dist/config.d.ts +2 -2
- package/dist/const.d.ts +26 -2
- package/dist/default.d.ts +2 -2
- package/dist/gl/atlas.d.ts +2 -2
- package/dist/gl/hitTest.d.ts +2 -2
- package/dist/gl/shader.d.ts +3 -4
- package/dist/gl/text.d.ts +2 -2
- package/dist/host/calculationHost.d.ts +2 -2
- package/dist/host/mapLibreProjectionHost.d.ts +2 -2
- package/dist/host/projectionHost.d.ts +2 -2
- package/dist/host/runtime.d.ts +2 -2
- package/dist/host/wasmCalculationHost.d.ts +2 -2
- package/dist/host/wasmHost.d.ts +3 -3
- package/dist/host/wasmProjectionHost.d.ts +2 -2
- package/dist/index.cjs +604 -499
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +604 -499
- package/dist/index.mjs.map +1 -1
- package/dist/internalTypes.d.ts +56 -83
- package/dist/interpolation/degreeInterpolation.d.ts +18 -19
- package/dist/interpolation/distanceInterpolation.d.ts +6 -7
- package/dist/interpolation/easing.d.ts +9 -7
- package/dist/interpolation/interpolation.d.ts +10 -12
- package/dist/interpolation/interpolationChannels.d.ts +4 -3
- package/dist/interpolation/rotationInterpolation.d.ts +10 -10
- package/dist/types.d.ts +137 -137
- package/dist/utils/color.d.ts +3 -8
- package/dist/utils/image.d.ts +2 -2
- package/dist/utils/looseQuadTree.d.ts +2 -2
- package/dist/utils/math.d.ts +68 -75
- package/dist/utils/utils.d.ts +2 -2
- package/dist/wasm/config.json.d.ts +2 -2
- package/package.json +6 -6
package/dist/types.d.ts
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: maplibre-gl-layers
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.17.0
|
|
4
4
|
* description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/maplibre-gl-layers.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 9fe9aa30db6602d13643e32c94af39ae2b26b082
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { CustomLayerInterface } from 'maplibre-gl';
|
|
12
|
-
/**
|
|
13
|
-
* Sprite rendering modes.
|
|
14
|
-
* Billboard: Image always faces the viewport, suited for HUD-style elements.
|
|
15
|
-
* Surface: Image lies parallel to the map surface, suited for dynamic markers on the map.
|
|
16
|
-
*/
|
|
17
|
-
export type SpriteMode = 'billboard' | 'surface';
|
|
18
12
|
/**
|
|
19
13
|
* Base coordinate for the sprite. All images within the sprite are positioned relative to this location.
|
|
20
14
|
*/
|
|
@@ -80,77 +74,118 @@ export interface SpriteImageOriginLocation {
|
|
|
80
74
|
*/
|
|
81
75
|
useResolvedAnchor?: boolean;
|
|
82
76
|
}
|
|
83
|
-
/**
|
|
84
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Linear easing definition.
|
|
79
|
+
*/
|
|
85
80
|
export interface SpriteEasingLinear {
|
|
86
|
-
type: 'linear';
|
|
81
|
+
readonly type: 'linear';
|
|
87
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Ease easing definition.
|
|
85
|
+
*/
|
|
88
86
|
export interface SpriteEasingEase {
|
|
89
|
-
type: 'ease';
|
|
87
|
+
readonly type: 'ease';
|
|
90
88
|
/** Power applied to the easing curve. Defaults to 3. */
|
|
91
89
|
power?: number;
|
|
92
90
|
/** Direction of the easing curve. Defaults to in-out. */
|
|
93
91
|
mode?: 'in' | 'out' | 'in-out';
|
|
94
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Exponential easing definition.
|
|
95
|
+
*/
|
|
95
96
|
export interface SpriteEasingExponential {
|
|
96
|
-
type: 'exponential';
|
|
97
|
+
readonly type: 'exponential';
|
|
97
98
|
/** Growth rate used by the exponential curve. Defaults to 5. */
|
|
98
99
|
exponent?: number;
|
|
99
100
|
/** Direction of the exponential curve. Defaults to in-out. */
|
|
100
101
|
mode?: 'in' | 'out' | 'in-out';
|
|
101
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Quadratic easing definition.
|
|
105
|
+
*/
|
|
102
106
|
export interface SpriteEasingQuadratic {
|
|
103
|
-
type: 'quadratic';
|
|
107
|
+
readonly type: 'quadratic';
|
|
104
108
|
/** Direction of the quadratic curve. Defaults to in-out. */
|
|
105
109
|
mode?: 'in' | 'out' | 'in-out';
|
|
106
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Cubic easing definition.
|
|
113
|
+
*/
|
|
107
114
|
export interface SpriteEasingCubic {
|
|
108
|
-
type: 'cubic';
|
|
115
|
+
readonly type: 'cubic';
|
|
109
116
|
/** Direction of the cubic curve. Defaults to in-out. */
|
|
110
117
|
mode?: 'in' | 'out' | 'in-out';
|
|
111
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Sine easing definition.
|
|
121
|
+
*/
|
|
112
122
|
export interface SpriteEasingSine {
|
|
113
|
-
type: 'sine';
|
|
123
|
+
readonly type: 'sine';
|
|
114
124
|
/** Direction of the sine ease. Defaults to in-out. */
|
|
115
125
|
mode?: 'in' | 'out' | 'in-out';
|
|
116
126
|
/** Multiplier applied to the sine amplitude. Defaults to 1. */
|
|
117
127
|
amplitude?: number;
|
|
118
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Bounce easing definition.
|
|
131
|
+
*/
|
|
119
132
|
export interface SpriteEasingBounce {
|
|
120
|
-
type: 'bounce';
|
|
133
|
+
readonly type: 'bounce';
|
|
121
134
|
/** Number of visible bounces before settling. Defaults to 3. */
|
|
122
135
|
bounces?: number;
|
|
123
136
|
/** Decay factor applied per bounce; range (0, 1]. Defaults to 0.5. */
|
|
124
137
|
decay?: number;
|
|
125
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Back easing definition.
|
|
141
|
+
*/
|
|
126
142
|
export interface SpriteEasingBack {
|
|
127
|
-
type: 'back';
|
|
143
|
+
readonly type: 'back';
|
|
128
144
|
/** Overshoot factor controlling how far past the target the curve goes. Defaults to 1.70158. */
|
|
129
145
|
overshoot?: number;
|
|
130
146
|
}
|
|
131
|
-
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
147
|
+
/**
|
|
148
|
+
* Union of supported easing parameters.
|
|
149
|
+
*/
|
|
150
|
+
export type SpriteEasingParam = SpriteEasingLinear | SpriteEasingEase | SpriteEasingExponential | SpriteEasingQuadratic | SpriteEasingCubic | SpriteEasingSine | SpriteEasingBounce | SpriteEasingBack;
|
|
151
|
+
/**
|
|
152
|
+
* Easing types.
|
|
153
|
+
*/
|
|
154
|
+
export type SpriteEasingType = SpriteEasingParam['type'];
|
|
155
|
+
/**
|
|
156
|
+
* Defines interpolation modes.
|
|
157
|
+
*/
|
|
158
|
+
export type SpriteInterpolationMode = 'feedback' | 'feedforward';
|
|
159
|
+
/**
|
|
160
|
+
* Options for interpolating values.
|
|
161
|
+
*/
|
|
135
162
|
export interface SpriteInterpolationOptions {
|
|
136
|
-
/** Interpolation mode; defaults to feedback
|
|
163
|
+
/** Interpolation mode; defaults to `feedback`. */
|
|
137
164
|
mode?: SpriteInterpolationMode;
|
|
138
165
|
/** Duration in milliseconds. */
|
|
139
166
|
durationMs: number;
|
|
140
|
-
/** Easing definition. Defaults to linear
|
|
141
|
-
easing?:
|
|
167
|
+
/** Easing definition. Defaults to `linear`. */
|
|
168
|
+
easing?: SpriteEasingParam;
|
|
142
169
|
}
|
|
143
|
-
/**
|
|
170
|
+
/**
|
|
171
|
+
* Interpolation configuration.
|
|
172
|
+
*/
|
|
144
173
|
export interface SpriteImageInterpolationOptions {
|
|
145
|
-
/** Interpolation settings for rotateDeg; null
|
|
174
|
+
/** Interpolation settings for rotateDeg; `null` will disable interpolation. */
|
|
146
175
|
rotateDeg?: SpriteInterpolationOptions | null;
|
|
147
|
-
/** Interpolation settings for offset.offsetDeg; null
|
|
176
|
+
/** Interpolation settings for offset.offsetDeg; `null` will disable interpolation. */
|
|
148
177
|
offsetDeg?: SpriteInterpolationOptions | null;
|
|
149
|
-
/** Interpolation settings for offset.offsetMeters; null
|
|
178
|
+
/** Interpolation settings for offset.offsetMeters; `null` will disable interpolation. */
|
|
150
179
|
offsetMeters?: SpriteInterpolationOptions | null;
|
|
151
|
-
/** Interpolation settings for opacity; null
|
|
180
|
+
/** Interpolation settings for opacity; `null` will disable interpolation. */
|
|
152
181
|
opacity?: SpriteInterpolationOptions | null;
|
|
153
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Sprite rendering modes.
|
|
185
|
+
* Billboard: Image always faces the viewport, suited for HUD-style elements.
|
|
186
|
+
* Surface: Image lies parallel to the map surface, suited for dynamic markers on the map.
|
|
187
|
+
*/
|
|
188
|
+
export type SpriteMode = 'billboard' | 'surface';
|
|
154
189
|
/**
|
|
155
190
|
* Initial attributes that define a sprite image.
|
|
156
191
|
*/
|
|
@@ -173,7 +208,7 @@ export interface SpriteImageDefinitionInit {
|
|
|
173
208
|
leaderLine?: SpriteImageLineAttribute;
|
|
174
209
|
/**
|
|
175
210
|
* Determines which coordinate to anchor against.
|
|
176
|
-
* - Omitted: use the sprite base coordinate.
|
|
211
|
+
* - Omitted: use "the sprite" base coordinate.
|
|
177
212
|
* - Provided: use the referenced image's anchor and offset (resolving references recursively).
|
|
178
213
|
*/
|
|
179
214
|
originLocation?: SpriteImageOriginLocation;
|
|
@@ -260,6 +295,10 @@ export interface SpriteInit<TTag> {
|
|
|
260
295
|
* Default interpolation settings applied to initial location updates until overridden.
|
|
261
296
|
*/
|
|
262
297
|
interpolation?: SpriteInterpolationOptions;
|
|
298
|
+
/**
|
|
299
|
+
* Multiplier applied to every image opacity belonging to the sprite. Defaults to 1.0.
|
|
300
|
+
*/
|
|
301
|
+
opacityMultiplier?: number;
|
|
263
302
|
/** Array of zero or more images. */
|
|
264
303
|
images: SpriteImageDefinitionInitEntry[];
|
|
265
304
|
/** Optional tag value; null or omission means no tag. */
|
|
@@ -282,15 +321,15 @@ export interface SpriteInitEntry<TTag> extends SpriteInit<TTag> {
|
|
|
282
321
|
export type SpriteInitCollection<TTag> = Record<string, SpriteInit<TTag>> | readonly SpriteInitEntry<TTag>[];
|
|
283
322
|
/**
|
|
284
323
|
* Interpolated values.
|
|
285
|
-
* @param
|
|
324
|
+
* @param TValue - Value type.
|
|
286
325
|
*/
|
|
287
|
-
export interface SpriteInterpolatedValues<
|
|
326
|
+
export interface SpriteInterpolatedValues<TValue> {
|
|
288
327
|
/** Current time value. */
|
|
289
|
-
readonly current:
|
|
328
|
+
readonly current: TValue;
|
|
290
329
|
/** Requested value. */
|
|
291
|
-
readonly from:
|
|
330
|
+
readonly from: TValue | undefined;
|
|
292
331
|
/** Will be reached value. */
|
|
293
|
-
readonly to:
|
|
332
|
+
readonly to: TValue | undefined;
|
|
294
333
|
/** Marks whether the value was invalidated due to visibility changes. */
|
|
295
334
|
readonly invalidated: boolean | undefined;
|
|
296
335
|
}
|
|
@@ -314,23 +353,6 @@ export interface SpriteImageLineAttributeState {
|
|
|
314
353
|
}
|
|
315
354
|
/**
|
|
316
355
|
* Sprite image state evaluated at runtime.
|
|
317
|
-
*
|
|
318
|
-
* @property {number} subLayer - Sub-layer index the image belongs to.
|
|
319
|
-
* @property {number} order - Ordering slot within the sub-layer.
|
|
320
|
-
* @property {string} imageId - Identifier of the registered image or glyph.
|
|
321
|
-
* @property {SpriteMode} mode - Rendering mode applied to the image.
|
|
322
|
-
* @property {SpriteInterpolatedValues<number>} opacity - Opacity multiplier applied when rendering, with interpolation metadata.
|
|
323
|
-
* @property {number} scale - Scale factor converting pixels to meters.
|
|
324
|
-
* @property {Readonly<SpriteAnchor>} anchor - Anchor coordinates resolved for the image.
|
|
325
|
-
* @property {SpriteImageInterpolatedOffset} offset - Offset applied relative to the anchor point, with interpolation metadata.
|
|
326
|
-
* @property {SpriteImageLineAttributeState | undefined} border - Border line attribute.
|
|
327
|
-
* @property {SpriteImageLineAttributeState | undefined} leaderLine - Leader line attribute.
|
|
328
|
-
* @property {SpriteInterpolatedValues<number>} rotateDeg - Additional rotation in degrees plus interpolation metadata.
|
|
329
|
-
* @property {boolean} autoRotation - Indicates whether auto-rotation is active.
|
|
330
|
-
* @property {number} autoRotationMinDistanceMeters - Minimum travel distance before auto-rotation updates.
|
|
331
|
-
* @property {number} resolvedBaseRotateDeg - Internal base rotation resolved for the current frame.
|
|
332
|
-
* @property {number} displayedRotateDeg - Rotation value actually used for rendering.
|
|
333
|
-
* @property {Readonly<SpriteImageOriginLocation> | undefined} originLocation - Optional reference to another image used for anchoring.
|
|
334
356
|
*/
|
|
335
357
|
export interface SpriteImageState {
|
|
336
358
|
/** Sub-layer index the image belongs to. */
|
|
@@ -379,6 +401,8 @@ export interface SpriteCurrentState<TTag> {
|
|
|
379
401
|
readonly spriteId: string;
|
|
380
402
|
/** Indicates whether the sprite is enabled. */
|
|
381
403
|
readonly isEnabled: boolean;
|
|
404
|
+
/** Multiplier applied to every image opacity. */
|
|
405
|
+
readonly opacityMultiplier: number;
|
|
382
406
|
/**
|
|
383
407
|
* Pseudo LOD threshold for the sprite. When the camera distance exceeds this value,
|
|
384
408
|
* the sprite's images become invisible.
|
|
@@ -398,10 +422,6 @@ export interface SpriteCurrentState<TTag> {
|
|
|
398
422
|
* Base structure for sprite updates.
|
|
399
423
|
*
|
|
400
424
|
* @template TTag Tag type stored on the sprite.
|
|
401
|
-
* @property {boolean | undefined} isEnabled - Optional toggle to enable or disable the sprite.
|
|
402
|
-
* @property {SpriteLocation | undefined} location - Optional target location for the sprite.
|
|
403
|
-
* @property {SpriteLocationInterpolationOptions | null | undefined} interpolation - Optional location interpolation settings; `null` disables interpolation.
|
|
404
|
-
* @property {TTag | null | undefined} tag - Optional tag value to replace the current one; `null` clears the tag.
|
|
405
425
|
*/
|
|
406
426
|
export interface SpriteUpdateEntryBase<TTag> {
|
|
407
427
|
/** Optional toggle to enable or disable the sprite. */
|
|
@@ -417,13 +437,13 @@ export interface SpriteUpdateEntryBase<TTag> {
|
|
|
417
437
|
* `null` to clear the current threshold, or leave `undefined` to keep the existing value.
|
|
418
438
|
*/
|
|
419
439
|
visibilityDistanceMeters?: number | null;
|
|
440
|
+
/**
|
|
441
|
+
* Optional multiplier applied to every image opacity. When omitted the previous multiplier is preserved.
|
|
442
|
+
*/
|
|
443
|
+
opacityMultiplier?: number;
|
|
420
444
|
}
|
|
421
445
|
/**
|
|
422
446
|
* Update entry describing a sprite image modification.
|
|
423
|
-
*
|
|
424
|
-
* @property {number} subLayer - Target sub-layer that contains the image.
|
|
425
|
-
* @property {number} order - Order slot within the sub-layer.
|
|
426
|
-
* @property {SpriteImageDefinitionUpdate | null} image - Update payload, or `null` to remove the image.
|
|
427
447
|
*/
|
|
428
448
|
export interface SpriteImageDefinitionUpdateEntry {
|
|
429
449
|
/** Target sub-layer that contains the image. */
|
|
@@ -437,7 +457,6 @@ export interface SpriteImageDefinitionUpdateEntry {
|
|
|
437
457
|
* Sprite update entry with optional image list.
|
|
438
458
|
*
|
|
439
459
|
* @template TTag Tag type stored on the sprite.
|
|
440
|
-
* @property {SpriteImageDefinitionUpdateEntry[] | undefined} images - Optional set of image updates.
|
|
441
460
|
*/
|
|
442
461
|
export interface SpriteUpdateEntry<TTag> extends SpriteUpdateEntryBase<TTag> {
|
|
443
462
|
/** Optional set of image updates. */
|
|
@@ -447,19 +466,35 @@ export interface SpriteUpdateEntry<TTag> extends SpriteUpdateEntryBase<TTag> {
|
|
|
447
466
|
* Callback-based helper for mutating sprite state.
|
|
448
467
|
*
|
|
449
468
|
* @template TTag Tag type stored on the sprite.
|
|
450
|
-
* @property {() => ReadonlyMap<number, ReadonlySet<number>>} getImageIndexMap - Retrieves the current image layout.
|
|
451
|
-
* @property {(subLayer: number, order: number, imageInit: SpriteImageDefinitionInit) => boolean} addImage - Adds an image definition.
|
|
452
|
-
* @property {(subLayer: number, order: number, imageUpdate: SpriteImageDefinitionUpdate) => boolean} updateImage - Applies image updates.
|
|
453
|
-
* @property {(subLayer: number, order: number) => boolean} removeImage - Removes an image slot.
|
|
454
469
|
*/
|
|
455
470
|
export interface SpriteUpdaterEntry<TTag> extends SpriteUpdateEntryBase<TTag> {
|
|
456
|
-
/**
|
|
471
|
+
/**
|
|
472
|
+
* Retrieves the current image layout.
|
|
473
|
+
* @returns Structured image index (order sets each sub layers).
|
|
474
|
+
*/
|
|
457
475
|
readonly getImageIndexMap: () => ReadonlyMap<number, ReadonlySet<number>>;
|
|
458
|
-
/**
|
|
476
|
+
/**
|
|
477
|
+
* Adds an image definition.
|
|
478
|
+
* @param subLayer - Sub layer index.
|
|
479
|
+
* @param order - Order index.
|
|
480
|
+
* @param imageInit - Image initializer.
|
|
481
|
+
* @returns True if added.
|
|
482
|
+
*/
|
|
459
483
|
readonly addImage: (subLayer: number, order: number, imageInit: SpriteImageDefinitionInit) => boolean;
|
|
460
|
-
/**
|
|
484
|
+
/**
|
|
485
|
+
* Applies image updates.
|
|
486
|
+
* @param subLayer - Sub layer index.
|
|
487
|
+
* @param order - Order index.
|
|
488
|
+
* @param imageUpdate - Image updater.
|
|
489
|
+
* @returns True if updated.
|
|
490
|
+
*/
|
|
461
491
|
readonly updateImage: (subLayer: number, order: number, imageUpdate: SpriteImageDefinitionUpdate) => boolean;
|
|
462
|
-
/**
|
|
492
|
+
/**
|
|
493
|
+
* Removes an image slot.
|
|
494
|
+
* @param subLayer - Sub layer index.
|
|
495
|
+
* @param order - Order index.
|
|
496
|
+
* @returns True if removed.
|
|
497
|
+
*/
|
|
463
498
|
readonly removeImage: (subLayer: number, order: number) => boolean;
|
|
464
499
|
}
|
|
465
500
|
/**
|
|
@@ -502,9 +537,6 @@ export interface SpriteMutateCallbacks<TTag, TSourceItem extends SpriteMutateSou
|
|
|
502
537
|
}
|
|
503
538
|
/**
|
|
504
539
|
* Represents a point on anonymous-unit space.
|
|
505
|
-
*
|
|
506
|
-
* @property {number} x - Horizontal (X axis) coordinate.
|
|
507
|
-
* @property {number} y - Vertical (Y axis) coordinate.
|
|
508
540
|
*/
|
|
509
541
|
export interface SpritePoint {
|
|
510
542
|
/** Horizontal (X axis) coordinate. */
|
|
@@ -519,18 +551,13 @@ export type SpriteScreenPoint = SpritePoint;
|
|
|
519
551
|
/**
|
|
520
552
|
* Event dispatched when a sprite is clicked or tapped.
|
|
521
553
|
*
|
|
522
|
-
* @template
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
* @property {SpriteImageState} image - Sprite image that received the interaction.
|
|
526
|
-
* @property {SpriteScreenPoint} screenPoint - Screen position of the interaction.
|
|
527
|
-
* @property {MouseEvent | PointerEvent | TouchEvent} originalEvent - Original DOM event.
|
|
528
|
-
*/
|
|
529
|
-
export interface SpriteLayerClickEvent<T> {
|
|
554
|
+
* @template TTag Tag type stored on sprites.
|
|
555
|
+
*/
|
|
556
|
+
export interface SpriteLayerClickEvent<TTag> {
|
|
530
557
|
/** Discriminated event type. */
|
|
531
558
|
readonly type: 'spriteclick';
|
|
532
559
|
/** Snapshot of the sprite that was hit, or `undefined` when it no longer exists. */
|
|
533
|
-
readonly sprite: SpriteCurrentState<
|
|
560
|
+
readonly sprite: SpriteCurrentState<TTag> | undefined;
|
|
534
561
|
/** Sprite image that received the interaction, or `undefined` when missing. */
|
|
535
562
|
readonly image: SpriteImageState | undefined;
|
|
536
563
|
/** Screen position of the interaction. */
|
|
@@ -541,18 +568,13 @@ export interface SpriteLayerClickEvent<T> {
|
|
|
541
568
|
/**
|
|
542
569
|
* Event dispatched when a sprite is hovered by a pointing device.
|
|
543
570
|
*
|
|
544
|
-
* @template
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
* @property {SpriteImageState} image - Sprite image that received the interaction.
|
|
548
|
-
* @property {SpriteScreenPoint} screenPoint - Screen position of the interaction.
|
|
549
|
-
* @property {MouseEvent | PointerEvent} originalEvent - Original hover-capable DOM event.
|
|
550
|
-
*/
|
|
551
|
-
export interface SpriteLayerHoverEvent<T> {
|
|
571
|
+
* @template TTag Tag type stored on sprites.
|
|
572
|
+
*/
|
|
573
|
+
export interface SpriteLayerHoverEvent<TTag> {
|
|
552
574
|
/** Discriminated event type. */
|
|
553
575
|
readonly type: 'spritehover';
|
|
554
576
|
/** Snapshot of the sprite that was hit, or `undefined` when it no longer exists. */
|
|
555
|
-
readonly sprite: SpriteCurrentState<
|
|
577
|
+
readonly sprite: SpriteCurrentState<TTag> | undefined;
|
|
556
578
|
/** Sprite image that received the interaction, or `undefined` when missing. */
|
|
557
579
|
readonly image: SpriteImageState | undefined;
|
|
558
580
|
/** Screen position of the interaction. */
|
|
@@ -563,35 +585,25 @@ export interface SpriteLayerHoverEvent<T> {
|
|
|
563
585
|
/**
|
|
564
586
|
* Map of events emitted by SpriteLayer.
|
|
565
587
|
*
|
|
566
|
-
* @template
|
|
567
|
-
* @property {SpriteLayerClickEvent<T>} spriteclick - Event fired when a sprite image is clicked.
|
|
568
|
-
* @property {SpriteLayerHoverEvent<T>} spritehover - Event fired when a sprite image is hovered.
|
|
588
|
+
* @template TTag Tag type stored on sprites.
|
|
569
589
|
*/
|
|
570
|
-
export interface SpriteLayerEventMap<
|
|
590
|
+
export interface SpriteLayerEventMap<TTag> {
|
|
571
591
|
/** Event fired when a sprite image is clicked. */
|
|
572
|
-
readonly spriteclick: SpriteLayerClickEvent<
|
|
592
|
+
readonly spriteclick: SpriteLayerClickEvent<TTag>;
|
|
573
593
|
/** Event fired when a sprite image is hovered. */
|
|
574
|
-
readonly spritehover: SpriteLayerHoverEvent<
|
|
594
|
+
readonly spritehover: SpriteLayerHoverEvent<TTag>;
|
|
575
595
|
}
|
|
576
596
|
/**
|
|
577
597
|
* Event listener callback.
|
|
578
598
|
*
|
|
579
|
-
* @template
|
|
599
|
+
* @template TTag Tag type stored on sprites.
|
|
580
600
|
* @template K Event key from {@link SpriteLayerEventMap}.
|
|
581
|
-
* @param {SpriteLayerEventMap<
|
|
601
|
+
* @param {SpriteLayerEventMap<TTag>[K]} event - Event payload dispatched by SpriteLayer.
|
|
582
602
|
* @returns {void}
|
|
583
603
|
*/
|
|
584
|
-
export type SpriteLayerEventListener<
|
|
604
|
+
export type SpriteLayerEventListener<TTag, K extends keyof SpriteLayerEventMap<TTag>> = (event: SpriteLayerEventMap<TTag>[K]) => void;
|
|
585
605
|
/**
|
|
586
606
|
* Options controlling zoom-to-pixel scaling.
|
|
587
|
-
*
|
|
588
|
-
* @property {number | undefined} metersPerPixel - Overrides the baseline meters-per-pixel ratio.
|
|
589
|
-
* @property {number | undefined} zoomMin - Minimum zoom level before scaling adjustments apply.
|
|
590
|
-
* @property {number | undefined} zoomMax - Maximum zoom level before scaling adjustments apply.
|
|
591
|
-
* @property {number | undefined} scaleMin - Lower limit for scale clamping.
|
|
592
|
-
* @property {number | undefined} scaleMax - Upper limit for scale clamping.
|
|
593
|
-
* @property {number | undefined} spriteMinPixel - Minimum on-screen pixel size for sprites (0 disables the lower clamp).
|
|
594
|
-
* @property {number | undefined} spriteMaxPixel - Maximum on-screen pixel size for sprites (0 disables the upper clamp).
|
|
595
607
|
*/
|
|
596
608
|
export interface SpriteScalingOptions {
|
|
597
609
|
/**
|
|
@@ -622,29 +634,24 @@ export type SpriteTextureMinFilter = 'nearest' | 'linear' | 'nearest-mipmap-near
|
|
|
622
634
|
export type SpriteTextureMagFilter = 'nearest' | 'linear';
|
|
623
635
|
/**
|
|
624
636
|
* Texture filtering configuration.
|
|
625
|
-
*
|
|
626
|
-
* @property {SpriteTextureMinFilter | undefined} minFilter - Minification filter to apply (defaults to `linear`).
|
|
627
|
-
* @property {SpriteTextureMagFilter | undefined} magFilter - Magnification filter to apply (defaults to `linear`).
|
|
628
|
-
* @property {boolean | undefined} generateMipmaps - Generates mipmaps during upload when true (defaults to `false`).
|
|
629
|
-
* @property {number | undefined} maxAnisotropy - Desired anisotropy factor (>= 1) when EXT_texture_filter_anisotropic is available.
|
|
630
637
|
*/
|
|
631
638
|
export interface SpriteTextureFilteringOptions {
|
|
639
|
+
/** Minification filter to apply (defaults to `linear`). */
|
|
632
640
|
minFilter?: SpriteTextureMinFilter;
|
|
641
|
+
/** Magnification filter to apply (defaults to `linear`). */
|
|
633
642
|
magFilter?: SpriteTextureMagFilter;
|
|
643
|
+
/** Generates mipmaps during upload when true (defaults to `false`). */
|
|
634
644
|
generateMipmaps?: boolean;
|
|
645
|
+
/** Desired anisotropy factor (>= 1) when EXT_texture_filter_anisotropic is available. */
|
|
635
646
|
maxAnisotropy?: number;
|
|
636
647
|
}
|
|
637
648
|
/**
|
|
638
649
|
* Options accepted when creating a SpriteLayer.
|
|
639
|
-
*
|
|
640
|
-
* @property {string | undefined} id - Optional layer identifier supplied to MapLibre.
|
|
641
|
-
* @property {SpriteScalingOptions | undefined} spriteScaling - Optional scaling controls. Default is UNLIMITED_SPRITE_SCALING_OPTIONS.
|
|
642
|
-
* @property {SpriteTextureFilteringOptions | undefined} textureFiltering - Optional texture filtering overrides.
|
|
643
650
|
*/
|
|
644
651
|
export interface SpriteLayerOptions {
|
|
645
652
|
/** Optional layer identifier supplied to MapLibre. */
|
|
646
653
|
id?: string;
|
|
647
|
-
/** Optional scaling controls. */
|
|
654
|
+
/** Optional scaling controls. Default is UNLIMITED_SPRITE_SCALING_OPTIONS. */
|
|
648
655
|
spriteScaling?: SpriteScalingOptions;
|
|
649
656
|
/** Optional texture filtering configuration. */
|
|
650
657
|
textureFiltering?: SpriteTextureFilteringOptions;
|
|
@@ -676,18 +683,26 @@ export interface SpriteImageRegisterOptions {
|
|
|
676
683
|
/** SVG-specific configuration. */
|
|
677
684
|
readonly svg?: SpriteImageSvgOptions;
|
|
678
685
|
}
|
|
679
|
-
/**
|
|
686
|
+
/**
|
|
687
|
+
* Horizontal alignment options for text glyphs.
|
|
688
|
+
*/
|
|
680
689
|
export type SpriteTextGlyphHorizontalAlign = 'left' | 'center' | 'right';
|
|
681
|
-
/**
|
|
690
|
+
/**
|
|
691
|
+
* Padding in pixels applied when rendering text glyphs.
|
|
692
|
+
*/
|
|
682
693
|
export type SpriteTextGlyphPaddingPixel = number | {
|
|
683
694
|
top?: number;
|
|
684
695
|
right?: number;
|
|
685
696
|
bottom?: number;
|
|
686
697
|
left?: number;
|
|
687
698
|
};
|
|
688
|
-
/**
|
|
699
|
+
/**
|
|
700
|
+
* Border sides that can be rendered for a text glyph outline.
|
|
701
|
+
*/
|
|
689
702
|
export type SpriteTextGlyphBorderSide = 'top' | 'right' | 'bottom' | 'left';
|
|
690
|
-
/**
|
|
703
|
+
/**
|
|
704
|
+
* Additional size options accepted by registerTextGlyph.
|
|
705
|
+
*/
|
|
691
706
|
export type SpriteTextGlyphDimensions = {
|
|
692
707
|
readonly lineHeightPixel: number;
|
|
693
708
|
readonly maxWidthPixel?: never;
|
|
@@ -697,21 +712,6 @@ export type SpriteTextGlyphDimensions = {
|
|
|
697
712
|
};
|
|
698
713
|
/**
|
|
699
714
|
* Text glyph appearance options.
|
|
700
|
-
*
|
|
701
|
-
* @property {string | undefined} fontFamily - Font family name.
|
|
702
|
-
* @property {string | undefined} fontWeight - CSS font-weight value.
|
|
703
|
-
* @property {'normal' | 'italic' | undefined} fontStyle - CSS font-style value.
|
|
704
|
-
* @property {string | undefined} color - Text fill color.
|
|
705
|
-
* @property {number | undefined} letterSpacingPixel - Letter spacing in pixels.
|
|
706
|
-
* @property {string | undefined} backgroundColor - Background color applied behind the text.
|
|
707
|
-
* @property {SpriteTextGlyphPaddingPixel | undefined} paddingPixel - Padding around the glyph.
|
|
708
|
-
* @property {string | undefined} borderColor - Outline color.
|
|
709
|
-
* @property {number | undefined} borderWidthPixel - Outline width in pixels.
|
|
710
|
-
* @property {SpriteTextGlyphBorderSide[] | undefined} borderSides - Border sides to draw (defaults to all four).
|
|
711
|
-
* @property {number | undefined} borderRadiusPixel - Border radius in pixels.
|
|
712
|
-
* @property {SpriteTextGlyphHorizontalAlign | undefined} textAlign - Horizontal alignment of multiline text.
|
|
713
|
-
* @property {number | undefined} fontSizePixelHint - It is not specified normally. Preferred font size in pixels before dimension constraints are enforced.
|
|
714
|
-
* @property {number | undefined} renderPixelRatio - Canvas pixel ratio multiplier (defaults to 1) applied before the glyph is resampled to its logical size.
|
|
715
715
|
*/
|
|
716
716
|
export interface SpriteTextGlyphOptions {
|
|
717
717
|
/** Font family name. */
|
package/dist/utils/color.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: maplibre-gl-layers
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.17.0
|
|
4
4
|
* description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/maplibre-gl-layers.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 9fe9aa30db6602d13643e32c94af39ae2b26b082
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
* Minimal CSS color parser used for resolving sprite border colors.
|
|
13
|
-
*/
|
|
14
|
-
export type RgbaColor = readonly [number, number, number, number];
|
|
11
|
+
import { RgbaColor } from '../internalTypes';
|
|
15
12
|
/**
|
|
16
13
|
* Parses a CSS color string into normalized RGBA values.
|
|
17
14
|
* Falls back to the supplied default when parsing fails.
|
|
@@ -21,5 +18,3 @@ export type RgbaColor = readonly [number, number, number, number];
|
|
|
21
18
|
* @returns Parsed RGBA tuple.
|
|
22
19
|
*/
|
|
23
20
|
export declare const parseCssColorToRgba: (color: string | undefined, fallback: RgbaColor) => RgbaColor;
|
|
24
|
-
export declare const DEFAULT_BORDER_COLOR = "red";
|
|
25
|
-
export declare const DEFAULT_BORDER_COLOR_RGBA: RgbaColor;
|
package/dist/utils/image.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: maplibre-gl-layers
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.17.0
|
|
4
4
|
* description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/maplibre-gl-layers.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 9fe9aa30db6602d13643e32c94af39ae2b26b082
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { SpriteImageRegisterOptions } from '../types';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: maplibre-gl-layers
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.17.0
|
|
4
4
|
* description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/maplibre-gl-layers.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 9fe9aa30db6602d13643e32c94af39ae2b26b082
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export interface Rect {
|