maplibre-gl-layers 0.1.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 +112 -0
- package/dist/SpriteLayer.d.ts +256 -0
- package/dist/easing.d.ts +19 -0
- package/dist/index.cjs +24163 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.mjs +24163 -0
- package/dist/index.mjs.map +1 -0
- package/dist/interpolation.d.ts +90 -0
- package/dist/location.d.ts +24 -0
- package/dist/math.d.ts +467 -0
- package/dist/numericInterpolation.d.ts +80 -0
- package/dist/rotationInterpolation.d.ts +44 -0
- package/dist/types.d.ts +351 -0
- package/dist/utils.d.ts +16 -0
- package/images/demo1.png +0 -0
- package/images/demo2.png +0 -0
- package/images/maplibre-gl-layers-120.png +0 -0
- package/package.json +75 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: maplibre-gl-layers
|
|
3
|
+
* version: 0.1.0
|
|
4
|
+
* description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/maplibre-gl-layers.git
|
|
8
|
+
* git.commit.hash: 88b09a93779279947d9c6b1e3a7538d4d197dbcb
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { SpriteNumericInterpolationOptions } from './types';
|
|
12
|
+
import { NumericInterpolationState } from './numericInterpolation';
|
|
13
|
+
/**
|
|
14
|
+
* Normalizes an absolute angle in degrees to the range [0, 360).
|
|
15
|
+
* @param {number} angle - Angle provided by the caller which may fall outside a single revolution.
|
|
16
|
+
* @returns {number} Angle wrapped to [0, 360) with negative zero converted to zero.
|
|
17
|
+
*/
|
|
18
|
+
export declare const normaliseAngleDeg: (angle: number) => number;
|
|
19
|
+
/**
|
|
20
|
+
* Parameters describing the rotation update request.
|
|
21
|
+
* @property {number} currentAngleDeg - Current angle already applied to the sprite in degrees.
|
|
22
|
+
* @property {number} targetAngleDeg - Desired angle in degrees that should be reached.
|
|
23
|
+
* @property {SpriteNumericInterpolationOptions | null} [options] - Optional interpolation configuration.
|
|
24
|
+
*/
|
|
25
|
+
export interface ResolveRotationTargetParams {
|
|
26
|
+
currentAngleDeg: number;
|
|
27
|
+
targetAngleDeg: number;
|
|
28
|
+
options?: SpriteNumericInterpolationOptions | null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Result produced by {@link resolveRotationTarget} when determining the next rotation step.
|
|
32
|
+
* @property {number} nextAngleDeg - Angle that should be applied immediately.
|
|
33
|
+
* @property {NumericInterpolationState | null} interpolationState - Optional state for animating toward the target.
|
|
34
|
+
*/
|
|
35
|
+
export interface ResolveRotationTargetResult {
|
|
36
|
+
readonly nextAngleDeg: number;
|
|
37
|
+
readonly interpolationState: NumericInterpolationState | null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Determines whether a rotation change requires interpolation and, if so, produces the state to drive it.
|
|
41
|
+
* @param {ResolveRotationTargetParams} params - Inputs including current angle, target angle, and options.
|
|
42
|
+
* @returns {ResolveRotationTargetResult} Immediate angle plus optional interpolation state.
|
|
43
|
+
*/
|
|
44
|
+
export declare const resolveRotationTarget: (params: ResolveRotationTargetParams) => ResolveRotationTargetResult;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: maplibre-gl-layers
|
|
3
|
+
* version: 0.1.0
|
|
4
|
+
* description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/maplibre-gl-layers.git
|
|
8
|
+
* git.commit.hash: 88b09a93779279947d9c6b1e3a7538d4d197dbcb
|
|
9
|
+
*/
|
|
10
|
+
|
|
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
|
+
/**
|
|
19
|
+
* Base coordinate for the sprite. All images within the sprite are positioned relative to this location.
|
|
20
|
+
*/
|
|
21
|
+
export interface SpriteLocation {
|
|
22
|
+
/** Longitude in degrees. */
|
|
23
|
+
lng: number;
|
|
24
|
+
/** Latitude in degrees. */
|
|
25
|
+
lat: number;
|
|
26
|
+
/** Elevation or virtual height. Defaults to 0 and is currently unused. */
|
|
27
|
+
z?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Offset describing where to place an image relative to its anchor point.
|
|
31
|
+
* Specifies distance and angle from the anchor, not from the sprite's base coordinate.
|
|
32
|
+
*/
|
|
33
|
+
export interface SpriteImageOffset {
|
|
34
|
+
/**
|
|
35
|
+
* Distance in meters from the image anchor. Zero keeps the image at the anchor point.
|
|
36
|
+
*/
|
|
37
|
+
offsetMeters: number;
|
|
38
|
+
/**
|
|
39
|
+
* Angle describing the offset direction. This is not the image rotation.
|
|
40
|
+
* Billboard mode: Clockwise degrees relative to the screen, 0 deg points upward.
|
|
41
|
+
* Surface mode: Clockwise degrees from geographic north.
|
|
42
|
+
*/
|
|
43
|
+
offsetDeg: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Anchor within the image.
|
|
47
|
+
* The sprite's base coordinate maps to this location; range is -1.0 to 1.0 relative to image size.
|
|
48
|
+
* x: -1.0 at left, 0.0 center, 1.0 right. y: -1.0 bottom, 0.0 center, 1.0 top.
|
|
49
|
+
* Values outside the range are accepted; clamp externally if needed.
|
|
50
|
+
*/
|
|
51
|
+
export interface SpriteAnchor {
|
|
52
|
+
/** Horizontal offset; -1.0 left edge, 1.0 right edge. */
|
|
53
|
+
x: number;
|
|
54
|
+
/** Vertical offset; -1.0 bottom edge, 1.0 top edge. */
|
|
55
|
+
y: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Reference to another image's anchor for positioning.
|
|
59
|
+
*/
|
|
60
|
+
export interface SpriteImageOriginLocation {
|
|
61
|
+
/**
|
|
62
|
+
* Sub-layer identifier.
|
|
63
|
+
*/
|
|
64
|
+
subLayer: number;
|
|
65
|
+
/**
|
|
66
|
+
* Order within the sub-layer; higher values render in front.
|
|
67
|
+
*/
|
|
68
|
+
order: number;
|
|
69
|
+
/**
|
|
70
|
+
* Use the referenced image's anchor-adjusted position when true. Defaults to the pre-anchor base point.
|
|
71
|
+
*/
|
|
72
|
+
useResolvedAnchor?: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Initial attributes that define a sprite image.
|
|
76
|
+
*/
|
|
77
|
+
export interface SpriteImageDefinitionInit {
|
|
78
|
+
/** Image ID to render. */
|
|
79
|
+
imageId: string;
|
|
80
|
+
/** Rendering mode. Defaults to surface. */
|
|
81
|
+
mode?: SpriteMode;
|
|
82
|
+
/** Opacity multiplier. Defaults to 1.0. */
|
|
83
|
+
opacity?: number;
|
|
84
|
+
/** Real-world meters represented by one pixel. Defaults to 1.0. */
|
|
85
|
+
scale?: number;
|
|
86
|
+
/** Anchor within the image. Defaults to [0.0, 0.0]. */
|
|
87
|
+
anchor?: SpriteAnchor;
|
|
88
|
+
/** Offset from the sprite coordinate. Defaults to no offset. */
|
|
89
|
+
offset?: SpriteImageOffset;
|
|
90
|
+
/**
|
|
91
|
+
* Determines which coordinate to anchor against.
|
|
92
|
+
* - Omitted: use the sprite base coordinate.
|
|
93
|
+
* - Provided: use the referenced image's anchor and offset (resolving references recursively).
|
|
94
|
+
*/
|
|
95
|
+
originLocation?: SpriteImageOriginLocation;
|
|
96
|
+
/**
|
|
97
|
+
* Additional rotation in degrees. Defaults to 0.
|
|
98
|
+
* Billboard: clockwise degrees relative to the screen with 0 deg up.
|
|
99
|
+
* Surface: clockwise degrees from geographic north.
|
|
100
|
+
*/
|
|
101
|
+
rotateDeg?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Enables auto-rotation based on movement. Defaults to true in surface mode and false in billboard mode.
|
|
104
|
+
*/
|
|
105
|
+
autoRotation?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Minimum distance in meters before auto-rotation updates. Defaults to 20; <= 0 updates immediately.
|
|
108
|
+
*/
|
|
109
|
+
autoRotationMinDistanceMeters?: number;
|
|
110
|
+
/**
|
|
111
|
+
* Optional interpolation settings for rotateDeg and offsetDeg.
|
|
112
|
+
*/
|
|
113
|
+
rotationInterpolation?: SpriteImageRotationInterpolationOptions;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Update payload for a sprite image. Properties left undefined are ignored.
|
|
117
|
+
*/
|
|
118
|
+
export interface SpriteImageDefinitionUpdate {
|
|
119
|
+
/** Image ID to render. */
|
|
120
|
+
imageId?: string;
|
|
121
|
+
/** Rendering mode. */
|
|
122
|
+
mode?: SpriteMode;
|
|
123
|
+
/** Opacity multiplier. */
|
|
124
|
+
opacity?: number;
|
|
125
|
+
/** Real-world meters represented by one pixel. */
|
|
126
|
+
scale?: number;
|
|
127
|
+
/** Anchor within the image. */
|
|
128
|
+
anchor?: SpriteAnchor;
|
|
129
|
+
/** Offset from the sprite coordinate. */
|
|
130
|
+
offset?: SpriteImageOffset;
|
|
131
|
+
/** Additional rotation in degrees. */
|
|
132
|
+
rotateDeg?: number;
|
|
133
|
+
/** Enables auto-rotation toward the travel direction. */
|
|
134
|
+
autoRotation?: boolean;
|
|
135
|
+
/** Minimum distance in meters before auto-rotation updates. */
|
|
136
|
+
autoRotationMinDistanceMeters?: number;
|
|
137
|
+
/** Optional interpolation settings applied to rotateDeg and offsetDeg. */
|
|
138
|
+
rotationInterpolation?: SpriteImageRotationInterpolationOptions;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Helper for bulk initializing sprite images.
|
|
142
|
+
*/
|
|
143
|
+
export interface SpriteImageDefinitionInitEntry extends SpriteImageDefinitionInit {
|
|
144
|
+
/** Sub-layer identifier. */
|
|
145
|
+
subLayer: number;
|
|
146
|
+
/**
|
|
147
|
+
* Order within the sub-layer; higher values render in front.
|
|
148
|
+
*/
|
|
149
|
+
order: number;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Parameters required to construct a new sprite.
|
|
153
|
+
* @param TTag Tag type.
|
|
154
|
+
*/
|
|
155
|
+
export interface SpriteInit<TTag> {
|
|
156
|
+
/** Whether the sprite starts enabled. Defaults to true. */
|
|
157
|
+
isEnabled?: boolean;
|
|
158
|
+
/** Initial location. */
|
|
159
|
+
location: SpriteLocation;
|
|
160
|
+
/** Array of zero or more images. */
|
|
161
|
+
images: SpriteImageDefinitionInitEntry[];
|
|
162
|
+
/** Optional tag value; null or omission means no tag. */
|
|
163
|
+
tag?: TTag | null;
|
|
164
|
+
}
|
|
165
|
+
/** Sprite image state evaluated at runtime. */
|
|
166
|
+
export interface SpriteImageState {
|
|
167
|
+
readonly subLayer: number;
|
|
168
|
+
readonly order: number;
|
|
169
|
+
readonly imageId: string;
|
|
170
|
+
readonly mode: SpriteMode;
|
|
171
|
+
readonly opacity: number;
|
|
172
|
+
readonly scale: number;
|
|
173
|
+
readonly anchor: Readonly<SpriteAnchor>;
|
|
174
|
+
readonly offset: Readonly<SpriteImageOffset>;
|
|
175
|
+
readonly rotateDeg: number;
|
|
176
|
+
readonly autoRotation: boolean;
|
|
177
|
+
readonly autoRotationMinDistanceMeters: number;
|
|
178
|
+
readonly resolvedBaseRotateDeg: number;
|
|
179
|
+
readonly displayedRotateDeg: number;
|
|
180
|
+
readonly originLocation: Readonly<SpriteImageOriginLocation> | undefined;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Current runtime state of a sprite.
|
|
184
|
+
* @param TTag Tag type.
|
|
185
|
+
*/
|
|
186
|
+
export interface SpriteCurrentState<TTag> {
|
|
187
|
+
/** Sprite identifier. */
|
|
188
|
+
readonly spriteId: string;
|
|
189
|
+
/** Indicates whether the sprite is enabled. */
|
|
190
|
+
readonly isEnabled: boolean;
|
|
191
|
+
/** Current (possibly interpolated) location. */
|
|
192
|
+
readonly currentLocation: Readonly<SpriteLocation>;
|
|
193
|
+
/**
|
|
194
|
+
* Source location during interpolation; undefined when not interpolating.
|
|
195
|
+
* Feedback mode: previous commanded location.
|
|
196
|
+
* Feed-forward mode: current commanded location.
|
|
197
|
+
*/
|
|
198
|
+
readonly fromLocation?: Readonly<SpriteLocation>;
|
|
199
|
+
/**
|
|
200
|
+
* Destination location during interpolation; undefined when not interpolating.
|
|
201
|
+
* Feedback mode: current commanded location.
|
|
202
|
+
* Feed-forward mode: predicted location.
|
|
203
|
+
*/
|
|
204
|
+
readonly toLocation?: Readonly<SpriteLocation>;
|
|
205
|
+
/** Current image states, grouped by sub-layer and order. */
|
|
206
|
+
readonly images: ReadonlyMap<number, ReadonlyMap<number, SpriteImageState>>;
|
|
207
|
+
/** Optional tag value; null indicates no tag. */
|
|
208
|
+
readonly tag: TTag | null;
|
|
209
|
+
}
|
|
210
|
+
/** Defines movement interpolation modes. */
|
|
211
|
+
export type SpriteInterpolationMode = 'feedback' | 'feedforward';
|
|
212
|
+
/** Easing function signature used to map interpolation progress. */
|
|
213
|
+
export type EasingFunction = (progress: number) => number;
|
|
214
|
+
/** Options controlling position interpolation. */
|
|
215
|
+
export interface SpriteInterpolationOptions {
|
|
216
|
+
/** Interpolation mode; defaults to feedback. */
|
|
217
|
+
mode?: SpriteInterpolationMode;
|
|
218
|
+
/** Duration in milliseconds. */
|
|
219
|
+
durationMs: number;
|
|
220
|
+
/** Easing function mapping interpolation progress. Defaults to linear. */
|
|
221
|
+
easing?: EasingFunction;
|
|
222
|
+
}
|
|
223
|
+
/** Options for interpolating numeric values such as angles. */
|
|
224
|
+
export interface SpriteNumericInterpolationOptions {
|
|
225
|
+
/** Duration in milliseconds. */
|
|
226
|
+
durationMs: number;
|
|
227
|
+
/** Easing function mapping interpolation progress. Defaults to linear. */
|
|
228
|
+
easing?: EasingFunction;
|
|
229
|
+
}
|
|
230
|
+
/** Interpolation configuration for rotateDeg and offsetDeg. */
|
|
231
|
+
export interface SpriteImageRotationInterpolationOptions {
|
|
232
|
+
/** Interpolation settings for rotateDeg; null disables interpolation. */
|
|
233
|
+
rotateDeg?: SpriteNumericInterpolationOptions | null;
|
|
234
|
+
/** Interpolation settings for offset.offsetDeg; null disables interpolation. */
|
|
235
|
+
offsetDeg?: SpriteNumericInterpolationOptions | null;
|
|
236
|
+
}
|
|
237
|
+
/** Base structure for sprite updates. */
|
|
238
|
+
export interface SpriteUpdateEntryBase<TTag> {
|
|
239
|
+
isEnabled?: boolean;
|
|
240
|
+
location?: SpriteLocation;
|
|
241
|
+
interpolation?: SpriteInterpolationOptions | null;
|
|
242
|
+
tag?: TTag | null;
|
|
243
|
+
}
|
|
244
|
+
/** Update entry describing a sprite image modification. */
|
|
245
|
+
export interface SpriteImageDefinitionUpdateEntry {
|
|
246
|
+
subLayer: number;
|
|
247
|
+
order: number;
|
|
248
|
+
image: SpriteImageDefinitionUpdate | null;
|
|
249
|
+
}
|
|
250
|
+
/** Sprite update entry with optional image list. */
|
|
251
|
+
export interface SpriteUpdateEntry<TTag> extends SpriteUpdateEntryBase<TTag> {
|
|
252
|
+
images?: SpriteImageDefinitionUpdateEntry[];
|
|
253
|
+
}
|
|
254
|
+
/** Entry consumed by updateBulk to target a specific sprite. */
|
|
255
|
+
export interface SpriteUpdateBulkEntry<T> extends SpriteUpdateEntry<T> {
|
|
256
|
+
spriteId: string;
|
|
257
|
+
}
|
|
258
|
+
/** Callback-based helper for mutating sprite state. */
|
|
259
|
+
export interface SpriteUpdaterEntry<TTag> extends SpriteUpdateEntryBase<TTag> {
|
|
260
|
+
readonly getImageIndexMap: () => ReadonlyMap<number, ReadonlySet<number>>;
|
|
261
|
+
readonly addImage: (subLayer: number, order: number, imageInit: SpriteImageDefinitionInit) => boolean;
|
|
262
|
+
readonly updateImage: (subLayer: number, order: number, imageUpdate: SpriteImageDefinitionUpdate) => boolean;
|
|
263
|
+
readonly removeImage: (subLayer: number, order: number) => boolean;
|
|
264
|
+
}
|
|
265
|
+
/** Represents a point in screen space. */
|
|
266
|
+
export interface SpriteScreenPoint {
|
|
267
|
+
readonly x: number;
|
|
268
|
+
readonly y: number;
|
|
269
|
+
}
|
|
270
|
+
/** Event dispatched when a sprite is clicked or tapped. */
|
|
271
|
+
export interface SpriteLayerClickEvent<T> {
|
|
272
|
+
readonly type: 'spriteclick';
|
|
273
|
+
readonly sprite: SpriteCurrentState<T>;
|
|
274
|
+
readonly image: SpriteImageState;
|
|
275
|
+
readonly screenPoint: SpriteScreenPoint;
|
|
276
|
+
readonly originalEvent: MouseEvent | PointerEvent | TouchEvent;
|
|
277
|
+
}
|
|
278
|
+
/** Map of events emitted by SpriteLayer. */
|
|
279
|
+
export interface SpriteLayerEventMap<T> {
|
|
280
|
+
readonly spriteclick: SpriteLayerClickEvent<T>;
|
|
281
|
+
}
|
|
282
|
+
/** Event listener callback. */
|
|
283
|
+
export type SpriteLayerEventListener<T, K extends keyof SpriteLayerEventMap<T>> = (event: SpriteLayerEventMap<T>[K]) => void;
|
|
284
|
+
/** Options controlling zoom-to-pixel scaling. */
|
|
285
|
+
export interface SpriteScalingOptions {
|
|
286
|
+
metersPerPixel?: number;
|
|
287
|
+
zoomMin?: number;
|
|
288
|
+
zoomMax?: number;
|
|
289
|
+
scaleMin?: number;
|
|
290
|
+
scaleMax?: number;
|
|
291
|
+
spriteMinPixel?: number;
|
|
292
|
+
spriteMaxPixel?: number;
|
|
293
|
+
}
|
|
294
|
+
/** Options accepted when creating a SpriteLayer. */
|
|
295
|
+
export interface SpriteLayerOptions {
|
|
296
|
+
id?: string;
|
|
297
|
+
spriteScaling?: SpriteScalingOptions;
|
|
298
|
+
}
|
|
299
|
+
/** Horizontal alignment options for text glyphs. */
|
|
300
|
+
export type SpriteTextGlyphHorizontalAlign = 'left' | 'center' | 'right';
|
|
301
|
+
/** Padding in pixels applied when rendering text glyphs. */
|
|
302
|
+
export type SpriteTextGlyphPaddingPixel = number | {
|
|
303
|
+
top?: number;
|
|
304
|
+
right?: number;
|
|
305
|
+
bottom?: number;
|
|
306
|
+
left?: number;
|
|
307
|
+
};
|
|
308
|
+
/** Additional size options accepted by registerTextGlyph. */
|
|
309
|
+
export type SpriteTextGlyphDimensions = {
|
|
310
|
+
readonly lineHeightPixel: number;
|
|
311
|
+
readonly maxWidthPixel?: never;
|
|
312
|
+
} | {
|
|
313
|
+
readonly maxWidthPixel: number;
|
|
314
|
+
readonly lineHeightPixel?: never;
|
|
315
|
+
};
|
|
316
|
+
export interface SpriteTextGlyphOptions {
|
|
317
|
+
fontFamily?: string;
|
|
318
|
+
fontSizePixel?: number;
|
|
319
|
+
fontWeight?: string;
|
|
320
|
+
fontStyle?: 'normal' | 'italic';
|
|
321
|
+
color?: string;
|
|
322
|
+
letterSpacingPixel?: number;
|
|
323
|
+
backgroundColor?: string;
|
|
324
|
+
paddingPixel?: SpriteTextGlyphPaddingPixel;
|
|
325
|
+
borderColor?: string;
|
|
326
|
+
borderWidthPixel?: number;
|
|
327
|
+
borderRadiusPixel?: number;
|
|
328
|
+
textAlign?: SpriteTextGlyphHorizontalAlign;
|
|
329
|
+
renderPixelRatio?: number;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* MapLibre layer interface for SpriteLayer.
|
|
333
|
+
* Renders large numbers of sprites and supports high-frequency updates.
|
|
334
|
+
* @param T Sprite tag type.
|
|
335
|
+
*/
|
|
336
|
+
export interface SpriteLayerInterface<T = any> extends CustomLayerInterface {
|
|
337
|
+
readonly registerImage: (imageId: string, image: string | ImageBitmap) => Promise<boolean>;
|
|
338
|
+
readonly registerTextGlyph: (textGlyphId: string, text: string, dimensions: SpriteTextGlyphDimensions, options?: SpriteTextGlyphOptions) => Promise<boolean>;
|
|
339
|
+
readonly unregisterImage: (imageId: string) => boolean;
|
|
340
|
+
readonly addSprite: (spriteId: string, init: SpriteInit<T>) => boolean;
|
|
341
|
+
readonly removeSprite: (spriteId: string) => void;
|
|
342
|
+
readonly getSpriteState: (spriteId: string) => SpriteCurrentState<T> | undefined;
|
|
343
|
+
readonly addSpriteImage: (spriteId: string, subLayer: number, order: number, imageInit: SpriteImageDefinitionInit) => boolean;
|
|
344
|
+
readonly updateSpriteImage: (spriteId: string, subLayer: number, order: number, imageUpdate: SpriteImageDefinitionUpdate) => boolean;
|
|
345
|
+
readonly removeSpriteImage: (spriteId: string, subLayer: number, order: number) => boolean;
|
|
346
|
+
readonly updateSprite: (spriteId: string, update: SpriteUpdateEntry<T>) => boolean;
|
|
347
|
+
readonly updateBulk: (updateBulkList: SpriteUpdateBulkEntry<T>[]) => number;
|
|
348
|
+
readonly updateForEach: (updater: (sprite: SpriteCurrentState<T>, update: SpriteUpdaterEntry<T>) => boolean) => number;
|
|
349
|
+
readonly on: <K extends keyof SpriteLayerEventMap<T>>(type: K, listener: SpriteLayerEventListener<T, K>) => void;
|
|
350
|
+
readonly off: <K extends keyof SpriteLayerEventMap<T>>(type: K, listener: SpriteLayerEventListener<T, K>) => void;
|
|
351
|
+
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: maplibre-gl-layers
|
|
3
|
+
* version: 0.1.0
|
|
4
|
+
* description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/maplibre-gl-layers.git
|
|
8
|
+
* git.commit.hash: 88b09a93779279947d9c6b1e3a7538d4d197dbcb
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Helper that loads an ImageBitmap from a URL.
|
|
13
|
+
* @param url Target image URL.
|
|
14
|
+
* @returns Promise resolving to the ImageBitmap.
|
|
15
|
+
*/
|
|
16
|
+
export declare const loadImageBitmap: (url: string) => Promise<ImageBitmap>;
|
package/images/demo1.png
ADDED
|
Binary file
|
package/images/demo2.png
ADDED
|
Binary file
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"git": {
|
|
3
|
+
"tags": [
|
|
4
|
+
"0.1.0"
|
|
5
|
+
],
|
|
6
|
+
"branches": [
|
|
7
|
+
"main"
|
|
8
|
+
],
|
|
9
|
+
"version": "0.1.0",
|
|
10
|
+
"commit": {
|
|
11
|
+
"hash": "88b09a93779279947d9c6b1e3a7538d4d197dbcb",
|
|
12
|
+
"shortHash": "88b09a9",
|
|
13
|
+
"date": "2025-10-28T09:58:34+09:00Z",
|
|
14
|
+
"message": "Initial commit"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"version": "0.1.0",
|
|
18
|
+
"description": "MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images",
|
|
19
|
+
"author": "Kouji Matsui (@kekyo@mi.kekyo.net)",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/kekyo/maplibre-gl-layers.git"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/kekyo/maplibre-gl-layers#readme",
|
|
26
|
+
"name": "maplibre-gl-layers",
|
|
27
|
+
"keywords": [
|
|
28
|
+
"maplibre",
|
|
29
|
+
"webgl",
|
|
30
|
+
"layer",
|
|
31
|
+
"many-sprites",
|
|
32
|
+
"automatic-interpolation",
|
|
33
|
+
"hud",
|
|
34
|
+
"interaction-events",
|
|
35
|
+
"grouping"
|
|
36
|
+
],
|
|
37
|
+
"type": "module",
|
|
38
|
+
"main": "./dist/index.cjs",
|
|
39
|
+
"module": "./dist/index.mjs",
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"exports": {
|
|
42
|
+
".": {
|
|
43
|
+
"types": "./dist/index.d.ts",
|
|
44
|
+
"import": "./dist/index.mjs",
|
|
45
|
+
"require": "./dist/index.cjs"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"dist",
|
|
50
|
+
"LICENSE",
|
|
51
|
+
"images/maplibre-gl-layers-120.png",
|
|
52
|
+
"images/demo1.png",
|
|
53
|
+
"images/demo2.png"
|
|
54
|
+
],
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "vite build",
|
|
57
|
+
"dev": "echo \"maplibre-gl-layers does not have dev rule.\"",
|
|
58
|
+
"test": "npm run build && vitest run",
|
|
59
|
+
"test:e2e": "npm run build && playwright test",
|
|
60
|
+
"pack": "npm run build && screw-up pack --pack-destination ../artifacts"
|
|
61
|
+
},
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"maplibre-gl": ">=5.0.0"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@playwright/test": ">=1.56.0",
|
|
67
|
+
"@types/node": ">=24.9.0",
|
|
68
|
+
"prettier-max": ">=1.11.0",
|
|
69
|
+
"screw-up": ">=1.13.0",
|
|
70
|
+
"typescript": ">=5.0.0",
|
|
71
|
+
"vite": ">=5.0.0",
|
|
72
|
+
"vite-plugin-dts": ">=4.5.0",
|
|
73
|
+
"vitest": ">=1.6.0"
|
|
74
|
+
}
|
|
75
|
+
}
|