@maptiler/sdk 3.4.0-rc3 → 3.4.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/.husky/pre-commit +2 -2
- package/README.md +133 -155
- package/dist/eslint.mjs +133 -0
- package/dist/maptiler-sdk.mjs +3788 -2749
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/src/Map.d.ts +22 -3
- package/dist/src/Telemetry.d.ts +1 -20
- package/dist/src/controls/Minimap.d.ts +1 -1
- package/dist/src/custom-layers/CubemapLayer/CubemapLayer.d.ts +216 -0
- package/dist/src/custom-layers/CubemapLayer/constants.d.ts +3 -0
- package/dist/src/custom-layers/CubemapLayer/index.d.ts +2 -0
- package/dist/src/custom-layers/CubemapLayer/loadCubemapTexture.d.ts +41 -0
- package/dist/src/custom-layers/CubemapLayer/types.d.ts +67 -0
- package/dist/src/custom-layers/RadialGradientLayer/RadialGradientLayer.d.ts +128 -0
- package/dist/src/custom-layers/RadialGradientLayer/index.d.ts +2 -0
- package/dist/src/custom-layers/RadialGradientLayer/types.d.ts +50 -0
- package/dist/src/custom-layers/extractCustomLayerStyle.d.ts +17 -0
- package/dist/src/custom-layers/index.d.ts +5 -0
- package/dist/src/helpers/index.d.ts +2 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/utils/geo-utils.d.ts +6 -0
- package/dist/src/utils/index.d.ts +0 -3
- package/dist/src/utils/math-utils.d.ts +8 -0
- package/dist/src/utils/webgl-utils.d.ts +49 -0
- package/eslint.config.mjs +5 -5
- package/package.json +20 -17
- package/tsconfig.json +12 -7
- package/typedoc.json +2 -3
- package/dist/playwright.config.d.ts +0 -9
- package/dist/src/custom-layers/AnimatedRouteLayer.d.ts +0 -291
- package/dist/src/utils/MaptilerAnimation/AnimationManager.d.ts +0 -41
- package/dist/src/utils/MaptilerAnimation/MaptilerAnimation.d.ts +0 -238
- package/dist/src/utils/MaptilerAnimation/animation-helpers.d.ts +0 -182
- package/dist/src/utils/MaptilerAnimation/easing.d.ts +0 -3
- package/dist/src/utils/MaptilerAnimation/index.d.ts +0 -7
- package/dist/src/utils/MaptilerAnimation/types.d.ts +0 -57
- package/dist/src/utils/array.d.ts +0 -1
- package/dist/vite.config-e2e.d.ts +0 -2
- package/dist/vite.config-test.d.ts +0 -2
- package/dist/vite.config-umd.d.ts +0 -2
- package/dist/vitest-setup-tests.d.ts +0 -1
- package/e2e/global.d.ts +0 -12
- package/e2e/public/animated-route.geojson +0 -82
- package/e2e/public/animatedRouteLayer.html +0 -24
- package/e2e/public/mapLoad.html +0 -24
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-0-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-1-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-10-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-11-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-12-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-13-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-14-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-15-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-16-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-17-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-18-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-19-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-2-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-3-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-4-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-5-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-6-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-7-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-8-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-9-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/mapLoad-chromium-darwin.png +0 -0
- package/e2e/tests/AnimatedRouteLayer.test.ts +0 -45
- package/e2e/tests/consts.ts +0 -0
- package/e2e/tests/expected-results/animatedRouteLayer-1.json +0 -202
- package/e2e/tests/helpers/fetchGeojson.ts +0 -21
- package/e2e/tests/helpers/getMapInstanceForFixture.ts +0 -86
- package/e2e/tests/map-load.test.ts +0 -14
- package/e2e/tests/mocks/maptiler-style.json +0 -27
- package/e2e/tests/mocks/tile.png +0 -0
- package/e2e/tsconfig.json +0 -10
- package/playwright.config.ts +0 -82
- package/tsconfig.tsbuildinfo +0 -1
- package/vite.config-dev.ts +0 -34
- package/vite.config-e2e.ts +0 -13
- package/vite.config-es.ts +0 -53
- package/vite.config-test.ts +0 -17
- package/vite.config-umd.ts +0 -35
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import { AnimationEventCallback, AnimationEventTypes, EasingFunctionName, Keyframe } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Configuration options for creating an animation.
|
|
4
|
-
*
|
|
5
|
-
* @interface MaptilerAnimationOptions
|
|
6
|
-
* @property {Keyframe[]} keyframes - The keyframes that define the animation states at various points in time.
|
|
7
|
-
* @property {number} duration - The total duration of the animation in milliseconds.
|
|
8
|
-
* @property {number} iterations - The number of times the animation should repeat. Use 0 for no repeat, or Infinity for an infinite loop.
|
|
9
|
-
* @property {delay} [delay] - Optional. The delay before the animation starts, in milliseconds. Defaults to 0 if not specified.
|
|
10
|
-
* @property {boolean} [manualMode] - Optional. If true, the animation will not be automatically managed by the animation manager
|
|
11
|
-
* and must be updated manually by calling update(). Defaults to false if not specified.
|
|
12
|
-
*/
|
|
13
|
-
export interface MaptilerAnimationOptions {
|
|
14
|
-
keyframes: Keyframe[];
|
|
15
|
-
duration: number;
|
|
16
|
-
iterations: number;
|
|
17
|
-
manualMode?: boolean;
|
|
18
|
-
delay?: number;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* A keyframe in the animation sequence where null or undefined values
|
|
22
|
-
* are interpolated to fill in the gaps between keyframes.
|
|
23
|
-
*
|
|
24
|
-
* @extends Keyframe
|
|
25
|
-
* @property {Record<string, number>} props - The properties to be animated at this keyframe.
|
|
26
|
-
* @property {EasingFunctionName} easing - The easing function to use for this keyframe.
|
|
27
|
-
* @property {string} id - A unique identifier for this keyframe.
|
|
28
|
-
*/
|
|
29
|
-
export type InterpolatedKeyFrame = Keyframe & {
|
|
30
|
-
props: Record<string, number>;
|
|
31
|
-
easing: EasingFunctionName;
|
|
32
|
-
id: string;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Animation controller for keyframe-based animation sequences.
|
|
36
|
-
*
|
|
37
|
-
* MaptilerAnimation handles interpolation between keyframes, timing control,
|
|
38
|
-
* and event dispatching during animation playback.
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```typescript
|
|
42
|
-
* const animation = new MaptilerAnimation({
|
|
43
|
-
* keyframes: [
|
|
44
|
-
* { delta: 0, props: { x: 0, y: 0 } },
|
|
45
|
-
* { delta: 0.5, props: { x: 50, y: 20 } },
|
|
46
|
-
* { delta: 1, props: { x: 100, y: 0 } }
|
|
47
|
-
* ],
|
|
48
|
-
* duration: 1000, // milliseconds
|
|
49
|
-
* iterations: 2
|
|
50
|
-
* });
|
|
51
|
-
*
|
|
52
|
-
* animation.addEventListener(AnimationEventTypes.TimeUpdate, (event) => {
|
|
53
|
-
* // Use interpolated property values to update something
|
|
54
|
-
* console.log(event.props);
|
|
55
|
-
* });
|
|
56
|
-
*
|
|
57
|
-
* animation.play();
|
|
58
|
-
* ```
|
|
59
|
-
*
|
|
60
|
-
* @remarks
|
|
61
|
-
* The animation supports various playback controls (play, pause, stop, reset),
|
|
62
|
-
* time manipulation, and an event system for tracking animation progress.
|
|
63
|
-
* Properties missing in keyframes will be automatically interpolated.
|
|
64
|
-
*
|
|
65
|
-
* Animation events include play, pause, stop, timeupdate, iteration, and more.
|
|
66
|
-
*
|
|
67
|
-
* When not using manualMode, animations are automatically added to the AnimationManager.
|
|
68
|
-
*/
|
|
69
|
-
export default class MaptilerAnimation {
|
|
70
|
-
private playing;
|
|
71
|
-
/**
|
|
72
|
-
* Indicates if the animation is currently playing
|
|
73
|
-
* @returns {boolean} - true if the animation is playing, false otherwise
|
|
74
|
-
*/
|
|
75
|
-
get isPlaying(): boolean;
|
|
76
|
-
/**
|
|
77
|
-
* The number of times to repeat the animation
|
|
78
|
-
* 0 is no repeat, Infinity is infinite repeat
|
|
79
|
-
*/
|
|
80
|
-
private iterations;
|
|
81
|
-
private currentIteration;
|
|
82
|
-
/** An array of keyframes animations to interpolate between */
|
|
83
|
-
private keyframes;
|
|
84
|
-
/** The current keyframe id */
|
|
85
|
-
private currentKeyframe?;
|
|
86
|
-
/**The duration of the animation in milliseconds (when playbackRate === 1) */
|
|
87
|
-
readonly duration: number;
|
|
88
|
-
/**
|
|
89
|
-
* The duration of the animation affected by the playback rate
|
|
90
|
-
* if playback rate is 2, the effective duration is double
|
|
91
|
-
*/
|
|
92
|
-
private effectiveDuration;
|
|
93
|
-
/** the rate at which the animation is playing */
|
|
94
|
-
private playbackRate;
|
|
95
|
-
/** the current time in milliseconds */
|
|
96
|
-
private currentTime;
|
|
97
|
-
/** 0 start of the animation, 1 end of the animation */
|
|
98
|
-
private currentDelta;
|
|
99
|
-
/** The time at which the animation started */
|
|
100
|
-
private animationStartTime;
|
|
101
|
-
/** The time at which the last frame was rendered */
|
|
102
|
-
private lastFrameAt;
|
|
103
|
-
/** The delay before the animation starts */
|
|
104
|
-
private delay;
|
|
105
|
-
/** The timeout ID for the delay before the animation starts */
|
|
106
|
-
private delayTimeoutID?;
|
|
107
|
-
/** The listeners added for each event */
|
|
108
|
-
private listeners;
|
|
109
|
-
/** The props from the previous frame */
|
|
110
|
-
private previousProps;
|
|
111
|
-
constructor({ keyframes, duration, iterations, manualMode, delay }: MaptilerAnimationOptions);
|
|
112
|
-
/**
|
|
113
|
-
* Starts or resumes the animation
|
|
114
|
-
* @returns This animation instance for method chaining
|
|
115
|
-
* @event AnimationEventTypes.Play
|
|
116
|
-
*/
|
|
117
|
-
play(): this;
|
|
118
|
-
/**
|
|
119
|
-
* Pauses the animation
|
|
120
|
-
* @returns This animation instance for method chaining
|
|
121
|
-
* @event AnimationEventTypes.Pause
|
|
122
|
-
*/
|
|
123
|
-
pause(): this;
|
|
124
|
-
/**
|
|
125
|
-
* Stops the animation and resets to initial state
|
|
126
|
-
* @returns This animation instance for method chaining
|
|
127
|
-
* @event AnimationEventTypes.Stop
|
|
128
|
-
*/
|
|
129
|
-
stop(silent?: boolean): this;
|
|
130
|
-
/**
|
|
131
|
-
* Resets the animation to its initial state without stopping
|
|
132
|
-
* @returns This animation instance for method chaining
|
|
133
|
-
* @event AnimationEventTypes.Reset
|
|
134
|
-
*/
|
|
135
|
-
reset(manual?: boolean): this;
|
|
136
|
-
/**
|
|
137
|
-
* Updates the animation state if playing, this is used by the AnimationManager
|
|
138
|
-
* to update all animations in the loop
|
|
139
|
-
* @returns This animation instance for method chaining
|
|
140
|
-
*/
|
|
141
|
-
updateInternal(): this;
|
|
142
|
-
/**
|
|
143
|
-
* Updates the animation state, interpolating between keyframes
|
|
144
|
-
* and emitting events as necessary
|
|
145
|
-
* @event AnimationEventTypes.TimeUpdate
|
|
146
|
-
* @event AnimationEventTypes.Keyframe
|
|
147
|
-
* @event AnimationEventTypes.Iteration
|
|
148
|
-
* @event AnimationEventTypes.AnimationEnd
|
|
149
|
-
* @returns This animation instance for method chaining
|
|
150
|
-
*/
|
|
151
|
-
update(manual?: boolean, ignoreIteration?: boolean): this;
|
|
152
|
-
/**
|
|
153
|
-
* Gets the current and next keyframes at a specific time
|
|
154
|
-
* @param time - The time position to query
|
|
155
|
-
* @returns Object containing current and next keyframes, which may be null
|
|
156
|
-
*/
|
|
157
|
-
getCurrentAndNextKeyFramesAtTime(time: number): {
|
|
158
|
-
current: InterpolatedKeyFrame | null;
|
|
159
|
-
next: InterpolatedKeyFrame | null;
|
|
160
|
-
};
|
|
161
|
-
/**
|
|
162
|
-
* Gets the current and next keyframes at a specific delta value
|
|
163
|
-
* @param delta - The delta value to query
|
|
164
|
-
* @returns Object containing current and next keyframes, which may be null
|
|
165
|
-
*/
|
|
166
|
-
getCurrentAndNextKeyFramesAtDelta(delta: number): {
|
|
167
|
-
current: InterpolatedKeyFrame | null;
|
|
168
|
-
next: InterpolatedKeyFrame | null;
|
|
169
|
-
};
|
|
170
|
-
/**
|
|
171
|
-
* Gets the current time position of the animation
|
|
172
|
-
* @returns The current time in milliseconds
|
|
173
|
-
*/
|
|
174
|
-
getCurrentTime(): number;
|
|
175
|
-
/**
|
|
176
|
-
* Sets the current time position of the animation
|
|
177
|
-
* @param time - The time to set in milliseconds
|
|
178
|
-
* @returns This animation instance for method chaining
|
|
179
|
-
* @throws Error if time is greater than the duration
|
|
180
|
-
* @event AnimationEventTypes.Scrub
|
|
181
|
-
*/
|
|
182
|
-
setCurrentTime(time: number): this;
|
|
183
|
-
/**
|
|
184
|
-
* Gets the current delta value of the animation
|
|
185
|
-
* @returns The current delta value (normalized progress between 0 and 1)
|
|
186
|
-
*/
|
|
187
|
-
getCurrentDelta(): number;
|
|
188
|
-
/**
|
|
189
|
-
* Sets the current delta value of the animation
|
|
190
|
-
* @param delta - The delta value to set (normalized progress between 0 and 1)
|
|
191
|
-
* @returns This animation instance for method chaining
|
|
192
|
-
* @throws Error if delta is greater than 1
|
|
193
|
-
* @event AnimationEventTypes.Scrub
|
|
194
|
-
*/
|
|
195
|
-
setCurrentDelta(delta: number): this;
|
|
196
|
-
/**
|
|
197
|
-
* Sets the playback rate of the animation
|
|
198
|
-
* @param rate - The playback rate (1.0 is normal speed)
|
|
199
|
-
* @returns This animation instance for method chaining
|
|
200
|
-
* @event AnimationEventTypes.PlaybackRateChange
|
|
201
|
-
*/
|
|
202
|
-
setPlaybackRate(rate: number): this;
|
|
203
|
-
/**
|
|
204
|
-
* Gets the current playback rate
|
|
205
|
-
* @returns The current playback rate
|
|
206
|
-
*/
|
|
207
|
-
getPlaybackRate(): number;
|
|
208
|
-
/**
|
|
209
|
-
* Adds an event listener to the animation
|
|
210
|
-
* @param type - The type of event to listen for
|
|
211
|
-
* @param callback - The callback function to execute when the event occurs
|
|
212
|
-
* @returns This animation instance for method chaining
|
|
213
|
-
*/
|
|
214
|
-
addEventListener(type: AnimationEventTypes, callback: AnimationEventCallback): this;
|
|
215
|
-
/**
|
|
216
|
-
* Removes an event listener from the animation
|
|
217
|
-
* @param type - The type of event to remove
|
|
218
|
-
* @param callback - The callback function to remove
|
|
219
|
-
* @returns This animation instance for method chaining
|
|
220
|
-
*/
|
|
221
|
-
removeEventListener(type: AnimationEventTypes, callback: AnimationEventCallback): this;
|
|
222
|
-
/**
|
|
223
|
-
* Emits an event to all listeners of a specific type
|
|
224
|
-
* @param event - The type of event to emit
|
|
225
|
-
* @param keyframe - The keyframe that triggered the event
|
|
226
|
-
* @param props - The interpolated properties at the current delta
|
|
227
|
-
*/
|
|
228
|
-
emitEvent(event: AnimationEventTypes, keyframe?: Keyframe | null, nextKeyframe?: Keyframe | null, props?: Record<string, number>, previousProps?: Record<string, number>): void;
|
|
229
|
-
/**
|
|
230
|
-
* Creates a clone of this animation
|
|
231
|
-
* @returns A new animation instance with the same properties as this one
|
|
232
|
-
*/
|
|
233
|
-
clone(): MaptilerAnimation;
|
|
234
|
-
/**
|
|
235
|
-
* Destroys the animation instance, removing all event listeners and stopping playback
|
|
236
|
-
*/
|
|
237
|
-
destroy(): void;
|
|
238
|
-
}
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { Feature, LineString, MultiLineString, MultiPoint, Polygon } from 'geojson';
|
|
2
|
-
import { EasingFunctionName, Keyframe, NumericArrayWithNull } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Performs simple linear interpolation between two numbers.
|
|
5
|
-
*
|
|
6
|
-
* @param a - The start value
|
|
7
|
-
* @param b - The end value
|
|
8
|
-
* @param alpha - The interpolation factor (typically between 0 and 1):
|
|
9
|
-
* 0 returns a, 1 returns b, and values in between return a proportional mix
|
|
10
|
-
* @returns The interpolated value between a and b
|
|
11
|
-
*/
|
|
12
|
-
export declare function lerp(a: number, b: number, alpha: number): number;
|
|
13
|
-
/**
|
|
14
|
-
* Interpolates an array of numbers, replacing null values with interpolated values.
|
|
15
|
-
*
|
|
16
|
-
* `null` is treated as an empty value where an interpolation is needed.
|
|
17
|
-
*
|
|
18
|
-
* @param {NumericArrayWithNull} numericArray - The array of numbers to interpolate, which may contain null values
|
|
19
|
-
* @returns A new array with null values replaced by interpolated values
|
|
20
|
-
*/
|
|
21
|
-
export declare function lerpArrayValues(numericArray: NumericArrayWithNull): number[];
|
|
22
|
-
/**
|
|
23
|
-
* Looks ahead in an array for the next entry that is not null.
|
|
24
|
-
*
|
|
25
|
-
* @param arr - The array to search through
|
|
26
|
-
* @param currentIndex - The index to start searching from
|
|
27
|
-
* @returns [index, value] A tuple containing the index of the next entry and its value, or null if not found
|
|
28
|
-
*/
|
|
29
|
-
export declare function findNextEntryAndIndexWithValue(arr: NumericArrayWithNull, currentIndex: number): (number | null)[];
|
|
30
|
-
/**
|
|
31
|
-
* Looks back in an array for the previous entry that is not null.
|
|
32
|
-
*
|
|
33
|
-
* @param arr - The array to search through
|
|
34
|
-
* @param currentIndex - The index to start searching from
|
|
35
|
-
* @returns [index, value] A tuple containing the index of the previous entry and its value, or null if not found
|
|
36
|
-
*/
|
|
37
|
-
export declare function findPreviousEntryAndIndexWithValue(arr: NumericArrayWithNull, currentIndex: number): (number | null)[];
|
|
38
|
-
/**
|
|
39
|
-
* Options for parsing GeoJSON data into animation keyframes.
|
|
40
|
-
*
|
|
41
|
-
* @interface IparseGeoJSONToKeyframesOptions
|
|
42
|
-
* @property {EasingFunctionName} [defaultEasing] - The default easing function to apply to the animation.
|
|
43
|
-
* @property {Object|false} [pathSmoothing] - Configuration for path smoothing, or false to disable smoothing.
|
|
44
|
-
* @property {number} [pathSmoothing.resolution] - The resolution used for path smoothing, higher values produce more detailed paths.
|
|
45
|
-
* @property {number} [pathSmoothing.epsilon] - Optional tolerance parameter for path simplification.
|
|
46
|
-
*/
|
|
47
|
-
export interface IparseGeoJSONToKeyframesOptions {
|
|
48
|
-
defaultEasing?: EasingFunctionName;
|
|
49
|
-
pathSmoothing?: {
|
|
50
|
-
resolution: number;
|
|
51
|
-
epsilon?: number;
|
|
52
|
-
} | false;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Represents geometry types that can be animated using keyframes.
|
|
56
|
-
*
|
|
57
|
-
* This type includes geometries like MultiPoint, LineString, MultiLineString, and Polygon
|
|
58
|
-
* which can be interpolated or transformed over time in animations.
|
|
59
|
-
*/
|
|
60
|
-
export type KeyframeableGeometry = MultiPoint | LineString | MultiLineString | Polygon;
|
|
61
|
-
/**
|
|
62
|
-
* Represents a GeoJSON Feature that can be animated with keyframes.
|
|
63
|
-
* Extends the standard GeoJSON Feature with animation-specific properties.
|
|
64
|
-
*
|
|
65
|
-
* @typedef {Object} KeyframeableGeoJSONFeature
|
|
66
|
-
* @extends {Feature<KeyframeableGeometry>}
|
|
67
|
-
* @property {Object} properties - Contains both standard GeoJSON properties (as number arrays) and animation controls
|
|
68
|
-
* @property {EasingFunctionName[]} [properties.@easing] - Easing functions to apply to property animations
|
|
69
|
-
* @property {number[]} [properties.@delta] - Delta values for animation calculations
|
|
70
|
-
* @property {number} [properties.@duration] - Duration of the animation in milliseconds
|
|
71
|
-
* @property {number} [properties.@delay] - Delay before animation starts in milliseconds
|
|
72
|
-
* @property {number} [properties.@iterations] - Number of times the animation should repeat
|
|
73
|
-
* @property {boolean} [properties.@autoplay] - Whether the animation should start automatically
|
|
74
|
-
*/
|
|
75
|
-
export type KeyframeableGeoJSONFeature = Feature<KeyframeableGeometry> & {
|
|
76
|
-
properties: Record<string, number[]> & {
|
|
77
|
-
"@easing"?: EasingFunctionName[];
|
|
78
|
-
"@delta"?: number[];
|
|
79
|
-
"@duration"?: number;
|
|
80
|
-
"@delay"?: number;
|
|
81
|
-
"@iterations"?: number;
|
|
82
|
-
"@autoplay"?: boolean;
|
|
83
|
-
altitude?: (number | null)[];
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Converts a GeoJSON feature into an array of animation keyframes.
|
|
88
|
-
*
|
|
89
|
-
* Parses a GeoJSON feature with reserved properties to create animation keyframes.
|
|
90
|
-
* It extracts coordinates from the geometry and uses properties prefixed with '@' as animation
|
|
91
|
-
* control parameters (easing functions, delta values). Non-reserved properties are preserved
|
|
92
|
-
* and passed to the keyframe objects as props that will be interpolated
|
|
93
|
-
*
|
|
94
|
-
* @param {KeyframeableGeoJSONFeature} feature - The GeoJSON feature to convert to keyframes
|
|
95
|
-
* @param {IparseGeoJSONToKeyframesOptions} options - Configuration options
|
|
96
|
-
*
|
|
97
|
-
* @returns Array of keyframe objects that can be used for animation
|
|
98
|
-
*
|
|
99
|
-
* @throws {Error} When no geometry is found in the feature
|
|
100
|
-
* @throws {Error} When the geometry type is not supported
|
|
101
|
-
*/
|
|
102
|
-
export declare function parseGeoJSONFeatureToKeyframes(feature: KeyframeableGeoJSONFeature, options?: IparseGeoJSONToKeyframesOptions): Keyframe[];
|
|
103
|
-
/**
|
|
104
|
-
*
|
|
105
|
-
* "Stretches" an array of numbers to a new length, filling in null values for the new indices.
|
|
106
|
-
*
|
|
107
|
-
* @param source the array to stretch
|
|
108
|
-
* @param targetLength the length to stretch to
|
|
109
|
-
* @returns {number[]} the stretched array with null values
|
|
110
|
-
*/
|
|
111
|
-
export declare function stretchNumericalArray(source: number[], targetLength: number): (number | null)[];
|
|
112
|
-
/**
|
|
113
|
-
* Generates an array of keyframes from coordinates, deltas, easings, and other properties provided by the geoJSON feature.
|
|
114
|
-
* Assumes that the coordinates are in the format [longitude, latitude, altitude?]. If altitude is not provided, it defaults to 0.
|
|
115
|
-
*
|
|
116
|
-
* @param coordinates - Array of coordinate points, where each point is an array of [longitude, latitude, altitude?]
|
|
117
|
-
* @param deltas - Array of time deltas between keyframes
|
|
118
|
-
* @param easings - Array of easing function names to apply to each keyframe transition
|
|
119
|
-
* @param properties - Optional additional properties as key-value pairs, where each value is an array
|
|
120
|
-
* of numbers corresponding to each keyframe
|
|
121
|
-
*
|
|
122
|
-
* @returns An array of Keyframe objects, each containing coordinate props, delta, and easing information
|
|
123
|
-
*
|
|
124
|
-
* @throws Error if the arrays for coordinates, deltas, easings, and any property values don't have matching lengths
|
|
125
|
-
*
|
|
126
|
-
* @example
|
|
127
|
-
* const keyframes = getKeyframes(
|
|
128
|
-
* [[0, 0, 10], [10, 10, 20]], // coordinates
|
|
129
|
-
* [1000, 2000], // deltas (in milliseconds)
|
|
130
|
-
* [EasingFunctionName.Linear, EasingFunctionName.ElasticIn], // easings
|
|
131
|
-
* { zoom: [10, 15] } // additional properties
|
|
132
|
-
* );
|
|
133
|
-
*/
|
|
134
|
-
export declare function getKeyframes(coordinates: number[][], deltas: number[], easings: EasingFunctionName[], properties?: Record<string, number[]>): Keyframe[];
|
|
135
|
-
/**
|
|
136
|
-
* Creates a smoothed path using cubic Bezier curves from an array of coordinates.
|
|
137
|
-
*
|
|
138
|
-
* This function takes a series of points and creates a smooth path by generating cubic
|
|
139
|
-
* Bezier curves between them. It uses the Catmull-Rom method to automatically calculate
|
|
140
|
-
* control points for each curve segment. If the path has fewer than 4 points, the original
|
|
141
|
-
* path is returned unchanged.
|
|
142
|
-
*
|
|
143
|
-
* @param inputPath - Array of [x, y] coordinates that define the original path
|
|
144
|
-
* @param outputResolution - Controls how many points are generated along each segment
|
|
145
|
-
* (higher values create smoother curves with more points)
|
|
146
|
-
* @param simplificationThreshold - Optional threshold for simplifying the input path before
|
|
147
|
-
* creating the curves.
|
|
148
|
-
* @returns An array of [x, y] coordinates representing the smoothed path
|
|
149
|
-
*/
|
|
150
|
-
export declare function createBezierPathFromCoordinates(inputPath: [number, number][], outputResolution?: number, simplificationThreshold?: number): [number, number][];
|
|
151
|
-
/**
|
|
152
|
-
* Calculates the average distance between points in an array of coordinates.
|
|
153
|
-
*
|
|
154
|
-
* This function computes the average distance between consecutive points in the array.
|
|
155
|
-
* It uses the LngLat class from MapLibre to calculate distances based on geographical coordinates.
|
|
156
|
-
*
|
|
157
|
-
* @param arr - An array of coordinate pairs [longitude, latitude]
|
|
158
|
-
* @returns The average distance between points in the array
|
|
159
|
-
*/
|
|
160
|
-
export declare function getAverageDistance(arr: [number, number][]): number;
|
|
161
|
-
/**
|
|
162
|
-
* Simplfies a path by removing points that are too close together.
|
|
163
|
-
*
|
|
164
|
-
* This function first resamples the path based on the average distance between points,
|
|
165
|
-
* then filters out points that are closer than the specified distance from the last included point.
|
|
166
|
-
* The first and last points of the original path are always preserved.
|
|
167
|
-
*
|
|
168
|
-
* @param points - An array of coordinate pairs [longitude, latitude]
|
|
169
|
-
* @param distance - The minimum distance between points in the simplified path
|
|
170
|
-
* @returns A new array containing a simplified version of the input path
|
|
171
|
-
*/
|
|
172
|
-
export declare function simplifyPath(points: [number, number][], distance: number): [number, number][];
|
|
173
|
-
/**
|
|
174
|
-
* Resamples a geographic path to have points spaced at approximately equal distances.
|
|
175
|
-
* If the original path has fewer than 2 points, it is returned unchanged.
|
|
176
|
-
*
|
|
177
|
-
* @param path - An array of coordinate pairs [longitude, latitude] representing the path to resample
|
|
178
|
-
* @param spacing - The desired spacing between points in the resampled path (in the same unit as used by the distanceTo method), defaults to 10
|
|
179
|
-
* @returns A new array of coordinate pairs representing the resampled path with approximately equal spacing between points
|
|
180
|
-
*
|
|
181
|
-
*/
|
|
182
|
-
export declare function resamplePath(path: [number, number][], spacing?: number): [number, number][];
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { default as MaptilerAnimation } from './MaptilerAnimation';
|
|
2
|
-
export type * from './MaptilerAnimation';
|
|
3
|
-
export default MaptilerAnimation;
|
|
4
|
-
export * from './types';
|
|
5
|
-
export * from './easing';
|
|
6
|
-
export { type KeyframeableGeometry, type KeyframeableGeoJSONFeature, lerp, lerpArrayValues, parseGeoJSONFeatureToKeyframes, createBezierPathFromCoordinates, getAverageDistance, simplifyPath, resamplePath, } from './animation-helpers';
|
|
7
|
-
export type * from './animation-helpers';
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { default as MaptilerAnimation } from './MaptilerAnimation';
|
|
2
|
-
export declare enum EasingFunctionName {
|
|
3
|
-
Linear = "Linear",
|
|
4
|
-
QuadraticIn = "QuadraticIn",
|
|
5
|
-
QuadraticOut = "QuadraticOut",
|
|
6
|
-
QuadraticInOut = "QuadraticInOut",
|
|
7
|
-
CubicIn = "CubicIn",
|
|
8
|
-
CubicOut = "CubicOut",
|
|
9
|
-
CubicInOut = "CubicInOut",
|
|
10
|
-
SinusoidalIn = "SinusoidalIn",
|
|
11
|
-
SinusoidalOut = "SinusoidalOut",
|
|
12
|
-
SinusoidalInOut = "SinusoidalInOut",
|
|
13
|
-
ExponentialIn = "ExponentialIn",
|
|
14
|
-
ExponentialOut = "ExponentialOut",
|
|
15
|
-
ExponentialInOut = "ExponentialInOut",
|
|
16
|
-
ElasticIn = "ElasticIn",
|
|
17
|
-
ElasticOut = "ElasticOut",
|
|
18
|
-
ElasticInOut = "ElasticInOut",
|
|
19
|
-
BounceIn = "BounceIn",
|
|
20
|
-
BounceOut = "BounceOut",
|
|
21
|
-
BounceInOut = "BounceInOut"
|
|
22
|
-
}
|
|
23
|
-
export type Keyframe = {
|
|
24
|
-
props: Record<string, number | null>;
|
|
25
|
-
delta: number;
|
|
26
|
-
easing?: EasingFunctionName;
|
|
27
|
-
userData?: Record<string, any>;
|
|
28
|
-
};
|
|
29
|
-
export declare enum AnimationEventTypes {
|
|
30
|
-
Pause = "pause",
|
|
31
|
-
Reset = "reset",
|
|
32
|
-
Play = "play",
|
|
33
|
-
Stop = "stop",
|
|
34
|
-
TimeUpdate = "timeupdate",
|
|
35
|
-
Scrub = "scrub",
|
|
36
|
-
PlaybackRateChange = "playbackratechange",
|
|
37
|
-
AnimationStart = "animationstart",
|
|
38
|
-
AnimationEnd = "animationend",
|
|
39
|
-
Keyframe = "keyframe",
|
|
40
|
-
Iteration = "iteration"
|
|
41
|
-
}
|
|
42
|
-
export type NumericArrayWithNull = (number | null)[];
|
|
43
|
-
export type AnimationEvent = {
|
|
44
|
-
type: AnimationEventTypes;
|
|
45
|
-
target: MaptilerAnimation;
|
|
46
|
-
currentTime: number;
|
|
47
|
-
currentDelta: number;
|
|
48
|
-
playbackRate: number;
|
|
49
|
-
keyframe?: Keyframe | null;
|
|
50
|
-
nextKeyframe?: Keyframe | null;
|
|
51
|
-
props: Record<string, number>;
|
|
52
|
-
previousProps: Record<string, number>;
|
|
53
|
-
iteration?: number;
|
|
54
|
-
};
|
|
55
|
-
export type AnimationEventListenersRecord = Record<AnimationEventTypes, AnimationEventCallback[]>;
|
|
56
|
-
export type AnimationEventCallback = (event: AnimationEvent) => void;
|
|
57
|
-
export { MaptilerAnimation };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function arraysAreTheSameLength(...arrays: unknown[][]): boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/e2e/global.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Map } from "@maptiler/sdk";
|
|
2
|
-
|
|
3
|
-
declare global {
|
|
4
|
-
interface Window {
|
|
5
|
-
__map: Map;
|
|
6
|
-
__pageLoadTimeout: number;
|
|
7
|
-
notifyScreenshotStateReady: (data: TTestTransferData) => Promise<void>;
|
|
8
|
-
__pageObjects: Record<string, unknown>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
type TTestTransferData = string | number | boolean | string[] | number[] | boolean[] | null | Record<string, unknown> | [number, number];
|
|
12
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"type": "FeatureCollection",
|
|
3
|
-
"features": [
|
|
4
|
-
{
|
|
5
|
-
"type": "Feature",
|
|
6
|
-
"properties": {
|
|
7
|
-
"pitch": [
|
|
8
|
-
30,
|
|
9
|
-
40,
|
|
10
|
-
50,
|
|
11
|
-
60,
|
|
12
|
-
50,
|
|
13
|
-
40,
|
|
14
|
-
30
|
|
15
|
-
],
|
|
16
|
-
"bearing": [
|
|
17
|
-
0,
|
|
18
|
-
180,
|
|
19
|
-
360
|
|
20
|
-
],
|
|
21
|
-
"zoom": [
|
|
22
|
-
13.5,
|
|
23
|
-
14,
|
|
24
|
-
14.5,
|
|
25
|
-
15,
|
|
26
|
-
14.5,
|
|
27
|
-
14,
|
|
28
|
-
13.5
|
|
29
|
-
]
|
|
30
|
-
},
|
|
31
|
-
"geometry": {
|
|
32
|
-
"coordinates": [
|
|
33
|
-
[
|
|
34
|
-
-5.513465218122661,
|
|
35
|
-
55.44452556522981
|
|
36
|
-
],
|
|
37
|
-
[
|
|
38
|
-
-5.498757996681263,
|
|
39
|
-
55.45488849896259
|
|
40
|
-
],
|
|
41
|
-
[
|
|
42
|
-
-5.4776627901701715,
|
|
43
|
-
55.459774141237716
|
|
44
|
-
],
|
|
45
|
-
[
|
|
46
|
-
-5.450773829757111,
|
|
47
|
-
55.45446729456921
|
|
48
|
-
],
|
|
49
|
-
[
|
|
50
|
-
-5.434581030391769,
|
|
51
|
-
55.44241894502119
|
|
52
|
-
],
|
|
53
|
-
[
|
|
54
|
-
-5.434433020938883,
|
|
55
|
-
55.42337006037573
|
|
56
|
-
],
|
|
57
|
-
[
|
|
58
|
-
-5.447655667245527,
|
|
59
|
-
55.40895140980018
|
|
60
|
-
],
|
|
61
|
-
[
|
|
62
|
-
-5.474692405196635,
|
|
63
|
-
55.40169789075969
|
|
64
|
-
],
|
|
65
|
-
[
|
|
66
|
-
-5.504997423959253,
|
|
67
|
-
55.410637475280794
|
|
68
|
-
],
|
|
69
|
-
[
|
|
70
|
-
-5.520595992154796,
|
|
71
|
-
55.42809094495976
|
|
72
|
-
],
|
|
73
|
-
[
|
|
74
|
-
-5.513910891499705,
|
|
75
|
-
55.44393572290733
|
|
76
|
-
]
|
|
77
|
-
],
|
|
78
|
-
"type": "LineString"
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
]
|
|
82
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>MapTiler E2E Animated Route Layer</title>
|
|
7
|
-
<style>
|
|
8
|
-
#map {
|
|
9
|
-
width: 100vw;
|
|
10
|
-
height: 100vh;
|
|
11
|
-
border: 1px solid red;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
body {
|
|
15
|
-
margin: 0;
|
|
16
|
-
padding: 0;
|
|
17
|
-
}
|
|
18
|
-
</style>
|
|
19
|
-
</head>
|
|
20
|
-
<body>
|
|
21
|
-
<div id="map"></div>
|
|
22
|
-
<script type="module" src="/src/animatedRouteLayer.ts"></script>
|
|
23
|
-
</body>
|
|
24
|
-
</html>
|
package/e2e/public/mapLoad.html
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>MapTiler E2E Map Load</title>
|
|
7
|
-
<style>
|
|
8
|
-
#map {
|
|
9
|
-
width: 100vw;
|
|
10
|
-
height: 100vh;
|
|
11
|
-
border: 1px solid red;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
body {
|
|
15
|
-
margin: 0;
|
|
16
|
-
padding: 0;
|
|
17
|
-
}
|
|
18
|
-
</style>
|
|
19
|
-
</head>
|
|
20
|
-
<body>
|
|
21
|
-
<div id="map"></div>
|
|
22
|
-
<script type="module" src="/src/mapLoad.ts"></script>
|
|
23
|
-
</body>
|
|
24
|
-
</html>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|