@maptiler/sdk 3.10.2-rc.2 → 3.11.0-rc.1
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 +233 -66
- package/dist/eslint.mjs +8 -0
- package/dist/maptiler-sdk.mjs +3512 -2464
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/src/ImageViewer/ImageViewer.d.ts +2 -2
- package/dist/src/Map.d.ts +42 -2
- package/dist/src/MaptilerAnimation/AnimationManager.d.ts +41 -0
- package/dist/src/MaptilerAnimation/MaptilerAnimation.d.ts +238 -0
- package/dist/src/MaptilerAnimation/animation-helpers.d.ts +183 -0
- package/dist/src/MaptilerAnimation/easing.d.ts +3 -0
- package/dist/src/MaptilerAnimation/index.d.ts +7 -0
- package/dist/src/MaptilerAnimation/types.d.ts +26 -0
- package/dist/src/custom-layers/AnimatedRouteLayer/AnimatedRouteLayer.d.ts +293 -0
- package/dist/src/custom-layers/AnimatedRouteLayer/index.d.ts +1 -0
- package/dist/src/custom-layers/CubemapLayer/CubemapLayer.d.ts +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/utils/array.d.ts +1 -0
- package/dist/src/utils/json.d.ts +1 -0
- package/dist/src/utils/string.d.ts +1 -0
- package/e2e/global.d.ts +14 -1
- package/e2e/public/animated-route.geojson +82 -0
- package/e2e/public/animatedRouteLayer.html +24 -0
- package/e2e/public/haloSpace.html +25 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-0-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-1-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-10-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-11-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-12-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-13-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-14-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-15-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-16-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-17-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-18-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-19-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-2-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-3-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-4-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-5-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-6-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-7-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-8-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-9-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-catalogue-style-halo-constructor-override-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-json-style-config-halo-constructor-override-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-json-style-config-halo-rendered-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-json-style-config-halo-rendered-chromium.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-json-style-config-halo-true-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-no-style-config-halo-true-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-remote-style-config-halo-constructor-override-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-remote-style-config-halo-false-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-remote-style-config-halo-true-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-style-config-halo-json-default-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-style-config-halo-json-default-chromium.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-style-config-halo-json-false-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-style-config-halo-json-false-chromium.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-style-config-halo-json-valid-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-style-config-halo-json-valid-chromium.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/halo-halo-style-config-halo-remote-valid-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-catalogue-style-config-space-true-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-catalogue-style-config-space-undefined-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-json-style-config-space-true-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-json-style-config-space-true-chromium.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-json-style-config-space-true-default-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-json-style-config-space-true-default-chromium.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-style-config-constructor-undefined-with-json-style-config-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-style-config-space-constructor-with-catalogue-style-config-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-style-config-space-constructor-with-json-space-config-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-style-config-space-constructor-with-json-space-config-chromium.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-style-config-space-false-with-json-style-config-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-style-config-space-false-with-json-style-config-chromium.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-style-config-space-false-with-style-config-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/haloSpace.test.ts-snapshots/space-space-style-config-space-true-no-style-config-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/halo-halo-json-style-config-halo-rendered-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/halo-halo-json-style-config-halo-true-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/halo-halo-style-config-halo-json-default-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/halo-halo-style-config-halo-json-false-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/halo-halo-style-config-halo-json-valid-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/space-space-json-style-config-space-true-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/space-space-json-style-config-space-true-chromium.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/space-space-json-style-config-space-true-default-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/space-space-style-config-space-constructor-with-json-space-config-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/space-space-style-config-space-false-with-json-style-config-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/halo-halo-json-style-config-halo-rendered-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/halo-halo-json-style-config-halo-true-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/halo-halo-style-config-halo-json-default-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/halo-halo-style-config-halo-json-false-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/halo-halo-style-config-halo-json-valid-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/space-space-json-style-config-space-true-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/space-space-json-style-config-space-true-default-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/space-space-style-config-space-constructor-with-json-space-config-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/space-space-style-config-space-false-with-json-style-config-chromium-linux.png +0 -0
- package/e2e/tests/AnimatedRouteLayer.test.ts +45 -0
- package/e2e/tests/consts.ts +0 -0
- package/e2e/tests/expected-results/animatedRouteLayer-1.json +202 -0
- package/e2e/tests/haloSpace.test.ts +809 -0
- package/e2e/tests/helpers/fetchGeojson.ts +21 -0
- package/e2e/tests/helpers/getMapInstanceForFixture.ts +87 -0
- package/e2e/tests/helpers/injectGlobalVariables.ts +13 -0
- package/e2e/tests/helpers/loadFixtureAndGetMapHandle.ts +46 -36
- package/e2e/tests/mocks/maptiler-style-space-halo-invalid.json +38 -0
- package/e2e/tests/mocks/maptiler-style-space-halo.json +41 -0
- package/e2e/tests/mocks/maptiler-style.json +1 -0
- package/e2e/tests/rtlTextPlugin.test.ts +3 -12
- package/e2e/tsconfig.json +1 -1
- package/eslint.config.mjs +8 -0
- package/package.json +11 -4
- package/playwright.config.ts +7 -2
- package/tsconfig.json +1 -1
- package/vitest-setup-tests.ts +16 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/rtlTextPlugin-active-chromium-linux.png +0 -0
- package/e2e/snapshots/tests/rtlTextPlugin.test.ts-snapshots/rtlTextPlugin-disabled-chromium-linux.png +0 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { AnimationEvent, AnimationEventTypes, EasingFunctionName, Keyframe } from '../../MaptilerAnimation/types';
|
|
2
|
+
import { MaptilerAnimation, MaptilerAnimationOptions } from '../../MaptilerAnimation';
|
|
3
|
+
import { CustomLayerInterface, Map as MapSDK } from '../../';
|
|
4
|
+
export type SourceData = {
|
|
5
|
+
id: string;
|
|
6
|
+
layerID: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Options for configuring the animated stroke effect for routes.
|
|
10
|
+
* When an object is provided, it defines colors for active and inactive parts of the route.
|
|
11
|
+
* When `false`, the animated stroke effect is disabled.
|
|
12
|
+
*
|
|
13
|
+
* @typedef {Object|boolean} AnimatedStrokeOptions
|
|
14
|
+
* @property {[number, number, number, number]} activeColor - The color of the path that has been progressed, in RGBA format.
|
|
15
|
+
* @property {[number, number, number, number]} inactiveColor - The base color of the path, in RGBA format.
|
|
16
|
+
*/
|
|
17
|
+
export type AnimatedStrokeOptions = {
|
|
18
|
+
activeColor: [number, number, number, number];
|
|
19
|
+
inactiveColor: [number, number, number, number];
|
|
20
|
+
} | false;
|
|
21
|
+
/**
|
|
22
|
+
* Options for configuring the animated camera movement
|
|
23
|
+
* along the route.
|
|
24
|
+
*
|
|
25
|
+
* @typedef {Object|boolean} AnimatedCameraOptions
|
|
26
|
+
* @property {boolean} [follow] - Whether the camera should follow the animation.
|
|
27
|
+
* @property {Object|boolean} [pathSmoothing] - Whether the camera path should be smoothed.
|
|
28
|
+
* @property {number} [pathSmoothing.resolution] - The resolution of the smoothing, higher resolution means more fidelity to the path.
|
|
29
|
+
* @property {number} [pathSmoothing.epsilon] - How much to simplify the path beforehand.
|
|
30
|
+
* @property {false} [pathSmoothing] - Whether the camera path should be smoothed.
|
|
31
|
+
*/
|
|
32
|
+
export type AnimatedCameraOptions = {
|
|
33
|
+
/** Whether the camera should follow the animation */
|
|
34
|
+
follow?: boolean;
|
|
35
|
+
/** Whether the camera path should be smoothed */
|
|
36
|
+
pathSmoothing?: {
|
|
37
|
+
/** the resolution of the smoothing, higher resolution means more fidelity to the path */
|
|
38
|
+
resolution: number;
|
|
39
|
+
/** How mich to simplify the path beforehand */
|
|
40
|
+
epsilon: number;
|
|
41
|
+
} | false;
|
|
42
|
+
} | false;
|
|
43
|
+
/**
|
|
44
|
+
* Configuration options for the AnimatedRouteLayer.
|
|
45
|
+
* This type supports either providing keyframes directly OR source data for the animation.
|
|
46
|
+
*
|
|
47
|
+
* @typedef AnimatedRouteLayerOptions
|
|
48
|
+
* @property {number} [duration] - The duration of the animation in milliseconds
|
|
49
|
+
* @property {number} [iterations] - The number of animation iterations to perform
|
|
50
|
+
* @property {number} [delay] - The delay in milliseconds before starting the animation
|
|
51
|
+
* @property {EasingFunctionName} [easing] - The default easing function to use if not provided in the GeoJSON
|
|
52
|
+
* @property {AnimatedCameraOptions} [cameraAnimation] - Options for camera animation
|
|
53
|
+
* @property {AnimatedStrokeOptions} [pathStrokeAnimation] - Options for stroke animation, only applicable for LineString geometries
|
|
54
|
+
* @property {boolean} [autoplay] - Whether the animation should start playing automatically
|
|
55
|
+
* @property {boolean} [manualUpdate] - Whether the animation should update automatically or require manual frameAdvance calls
|
|
56
|
+
* @property {Keyframe[]} [keyframes] - The keyframes for the animation (mutually exclusive with source)
|
|
57
|
+
* @property {SourceData} [source] - The source data for the animation (mutually exclusive with keyframes)
|
|
58
|
+
*/
|
|
59
|
+
export type AnimatedRouteLayerOptions = {
|
|
60
|
+
/** The Duration in ms */
|
|
61
|
+
duration?: number;
|
|
62
|
+
/** The number of iterations */
|
|
63
|
+
iterations?: number;
|
|
64
|
+
/** The delay in ms before playing */
|
|
65
|
+
delay?: number;
|
|
66
|
+
/** The default easing to use if not provided in teh GeoJSON */
|
|
67
|
+
easing?: EasingFunctionName;
|
|
68
|
+
/** The camera animation options */
|
|
69
|
+
cameraAnimation?: AnimatedCameraOptions;
|
|
70
|
+
/** The stroke animation options, only viable for LineString geometries */
|
|
71
|
+
pathStrokeAnimation?: AnimatedStrokeOptions;
|
|
72
|
+
/** Whether the animation should autoplay */
|
|
73
|
+
autoplay?: boolean;
|
|
74
|
+
/** Whether the animation should auto matically animated or whether the frameAdvance method should be called */
|
|
75
|
+
manualUpdate?: boolean;
|
|
76
|
+
} & ({
|
|
77
|
+
/** The keyframes for the the animation OR */
|
|
78
|
+
keyframes: Keyframe[];
|
|
79
|
+
source?: never;
|
|
80
|
+
} | {
|
|
81
|
+
/** The source data */
|
|
82
|
+
source: SourceData;
|
|
83
|
+
keyframes?: never;
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* A callback function that gets executed for each animation frame. This is simply a utility type.
|
|
87
|
+
* @param {AnimationEvent} event - The animation event data provided during animation frame updates.
|
|
88
|
+
*/
|
|
89
|
+
export type FrameCallback = (event: AnimationEvent) => void;
|
|
90
|
+
export declare const ANIM_LAYER_PREFIX = "animated-route-layer";
|
|
91
|
+
/**
|
|
92
|
+
* This layer allows you to create animated paths on a map by providing keyframes or a GeoJSON source
|
|
93
|
+
* with route data. The animation can control both the visual appearance of the path (using color transitions)
|
|
94
|
+
* and optionally animate the camera to follow along the route path.
|
|
95
|
+
* @class AnimatedRouteLayer
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* // Create an animated route layer using a GeoJSON source
|
|
100
|
+
* const animatedRoute = new AnimatedRouteLayer({
|
|
101
|
+
* source: {
|
|
102
|
+
* id: 'route-source',
|
|
103
|
+
* layerID: 'route-layer',
|
|
104
|
+
* },
|
|
105
|
+
* duration: 5000,
|
|
106
|
+
* pathStrokeAnimation: {
|
|
107
|
+
* activeColor: [0, 255, 0, 1],
|
|
108
|
+
* inactiveColor: [100, 100, 100, 0.5]
|
|
109
|
+
* },
|
|
110
|
+
* autoplay: true
|
|
111
|
+
* });
|
|
112
|
+
*
|
|
113
|
+
* // Add the layer to the map
|
|
114
|
+
* map.addLayer(animatedRoute);
|
|
115
|
+
*
|
|
116
|
+
* // Control playback
|
|
117
|
+
* animatedRoute.play();
|
|
118
|
+
* animatedRoute.pause();
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* @remarks
|
|
122
|
+
* The animation can be configured using either explicit keyframes or a GeoJSON source.
|
|
123
|
+
* When using a GeoJSON source, the feature can include special properties that control
|
|
124
|
+
* animation behavior:
|
|
125
|
+
* - `@duration`: Animation duration in milliseconds
|
|
126
|
+
* - `@iterations`: Number of times to repeat the animation
|
|
127
|
+
* - `@delay`: Delay before starting animation in milliseconds
|
|
128
|
+
* - `@autoplay`: Whether to start the animation automatically
|
|
129
|
+
*
|
|
130
|
+
* Only one AnimatedRouteLayer can be active at a time on a map.
|
|
131
|
+
*/
|
|
132
|
+
/**
|
|
133
|
+
* Creates an animated route layer for MapTiler maps.
|
|
134
|
+
*
|
|
135
|
+
* The `AnimatedRouteLayer` allows you to animate paths on a map with visual effects and optional camera following.
|
|
136
|
+
* You can define animations either through explicit keyframes or by referencing GeoJSON data with animation metadata.
|
|
137
|
+
*
|
|
138
|
+
* Features:
|
|
139
|
+
* - Animate route paths with color transitions (active/inactive segments)
|
|
140
|
+
* - Optional camera following along the route
|
|
141
|
+
* - Control animation playback (play, pause)
|
|
142
|
+
* - Configure animation properties (duration, iterations, delay, easing)
|
|
143
|
+
* - Support for manual or automatic animation updates
|
|
144
|
+
* - Event system for animation state changes
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* // Create an animated route from GeoJSON source
|
|
149
|
+
* const animatedRoute = new AnimatedRouteLayer({
|
|
150
|
+
* source: {
|
|
151
|
+
* id: 'route-source',
|
|
152
|
+
* layerID: 'route-layer',
|
|
153
|
+
* },
|
|
154
|
+
* duration: 5000,
|
|
155
|
+
* iterations: 1,
|
|
156
|
+
* autoplay: true,
|
|
157
|
+
* cameraAnimation: {
|
|
158
|
+
* follow: true,
|
|
159
|
+
* pathSmoothing: { resolution: 20, epsilon: 5 }
|
|
160
|
+
* },
|
|
161
|
+
* pathStrokeAnimation: {
|
|
162
|
+
* activeColor: [255, 0, 0, 1],
|
|
163
|
+
* inactiveColor: [0, 0, 255, 1]
|
|
164
|
+
* }
|
|
165
|
+
* });
|
|
166
|
+
*
|
|
167
|
+
* // Add the layer to the map
|
|
168
|
+
* map.addLayer(animatedRoute);
|
|
169
|
+
*
|
|
170
|
+
* // Control playback
|
|
171
|
+
* animatedRoute.pause();
|
|
172
|
+
* animatedRoute.play();
|
|
173
|
+
*
|
|
174
|
+
* // Listen for animation events
|
|
175
|
+
* animatedRoute.addEventListener("animationend", () => {
|
|
176
|
+
* console.log('Animation completed');
|
|
177
|
+
* });
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* @implements {CustomLayerInterface}
|
|
181
|
+
*/
|
|
182
|
+
export declare class AnimatedRouteLayer implements CustomLayerInterface {
|
|
183
|
+
/** Unique ID for the layer */
|
|
184
|
+
readonly id: string;
|
|
185
|
+
readonly type = "custom";
|
|
186
|
+
/** The MaptilerAnimation instance that handles the animation */
|
|
187
|
+
animationInstance: MaptilerAnimation | null;
|
|
188
|
+
/**
|
|
189
|
+
* Keyframes for the animation
|
|
190
|
+
* If keyframes are provided, they will be used for the animation
|
|
191
|
+
* If a source is provided, the keyframes will be parsed from the GeoJSON feature
|
|
192
|
+
*/
|
|
193
|
+
private keyframes;
|
|
194
|
+
/**
|
|
195
|
+
* Source data for the animation
|
|
196
|
+
* If a source is provided, it will be used to get the keyframes
|
|
197
|
+
* If keyframes are provided, this will be ignored
|
|
198
|
+
*/
|
|
199
|
+
private source;
|
|
200
|
+
/** The duration of the animation in ms */
|
|
201
|
+
private duration;
|
|
202
|
+
/** The number of interations */
|
|
203
|
+
private iterations;
|
|
204
|
+
/** The delay before the animation starts in ms */
|
|
205
|
+
private delay;
|
|
206
|
+
/** The default easing function for the animation */
|
|
207
|
+
private easing?;
|
|
208
|
+
/** The map instance */
|
|
209
|
+
private map;
|
|
210
|
+
/** The camera animation options */
|
|
211
|
+
private cameraMaptilerAnimationOptions?;
|
|
212
|
+
/**
|
|
213
|
+
* The path stroke animation options
|
|
214
|
+
* This controls the color of the path during the animation
|
|
215
|
+
*/
|
|
216
|
+
private pathStrokeAnimation?;
|
|
217
|
+
/** Whether the animation will autoplay */
|
|
218
|
+
private autoplay;
|
|
219
|
+
/** Whether the animation will be managed manually */
|
|
220
|
+
private manualUpdate;
|
|
221
|
+
private enquedEventHandlers;
|
|
222
|
+
private enquedCommands;
|
|
223
|
+
constructor({ keyframes, source, duration, iterations, easing, delay, cameraAnimation, pathStrokeAnimation, autoplay, manualUpdate, }: AnimatedRouteLayerOptions);
|
|
224
|
+
/**
|
|
225
|
+
* This method is called when the layer is added to the map.
|
|
226
|
+
* It initializes the animation instance and sets up event listeners.
|
|
227
|
+
*
|
|
228
|
+
* @param {MapLibreMap} map - The map instance (maplibre Map, but will be MapSDK at runtime)
|
|
229
|
+
* @param {WebGLRenderingContext | WebGL2RenderingContext} _gl - The WebGL context (unused in this layer)
|
|
230
|
+
*/
|
|
231
|
+
onAdd(map: MapSDK): Promise<void>;
|
|
232
|
+
/**
|
|
233
|
+
* Initializes the animation instance asynchronously.
|
|
234
|
+
* This is called from onAdd but runs asynchronously to handle async data loading.
|
|
235
|
+
*/
|
|
236
|
+
/**
|
|
237
|
+
* This method is used to manually advance the animation
|
|
238
|
+
*
|
|
239
|
+
* @returns {AnimatedRouteLayer} - The current instance of AnimatedRouteLayer
|
|
240
|
+
*/
|
|
241
|
+
frameAdvance(): this;
|
|
242
|
+
/**
|
|
243
|
+
* Adds an event listener to the animation instance.
|
|
244
|
+
*
|
|
245
|
+
* @param {AnimationEventTypes} type - The type of event to listen for
|
|
246
|
+
* @param {FrameCallback} callback - The callback function to execute when the event occurs
|
|
247
|
+
*/
|
|
248
|
+
addEventListener(type: AnimationEventTypes, callback: FrameCallback): AnimatedRouteLayer;
|
|
249
|
+
/**
|
|
250
|
+
* Removes an event listener from the animation instance.
|
|
251
|
+
*
|
|
252
|
+
* @param {AnimationEventTypes} type - The type of event to remove
|
|
253
|
+
* @param {FrameCallback} callback - The callback function to remove
|
|
254
|
+
*/
|
|
255
|
+
removeEventListener(type: AnimationEventTypes, callback: FrameCallback): AnimatedRouteLayer;
|
|
256
|
+
updateManual(): void;
|
|
257
|
+
/**
|
|
258
|
+
* Updates the layer's properties based on the animation event.
|
|
259
|
+
* @private
|
|
260
|
+
* @param {AnimationEvent} event - The animation event
|
|
261
|
+
*/
|
|
262
|
+
private update;
|
|
263
|
+
/**
|
|
264
|
+
* Plays the animation.
|
|
265
|
+
*
|
|
266
|
+
* @returns {AnimatedRouteLayer} - The current instance of AnimatedRouteLayer
|
|
267
|
+
*/
|
|
268
|
+
play(): AnimatedRouteLayer;
|
|
269
|
+
/**
|
|
270
|
+
* Stops the animation.
|
|
271
|
+
*
|
|
272
|
+
* @returns {AnimatedRouteLayer} - The current instance of AnimatedRouteLayer
|
|
273
|
+
*/
|
|
274
|
+
pause(): AnimatedRouteLayer;
|
|
275
|
+
/**
|
|
276
|
+
* Gets the source GeoJSON data from the map instance, parses it, and returns the animation options.
|
|
277
|
+
*
|
|
278
|
+
* @returns {Promise<MaptilerAnimationOptions>} - The MaptilerAnimation constructor options
|
|
279
|
+
*/
|
|
280
|
+
getMaptilerAnimationOptions(): Promise<MaptilerAnimationOptions & {
|
|
281
|
+
autoplay: boolean;
|
|
282
|
+
}>;
|
|
283
|
+
/**
|
|
284
|
+
* This method is called when the layer is removed from the map.
|
|
285
|
+
* It destroys the animation instance.
|
|
286
|
+
*/
|
|
287
|
+
onRemove(): void;
|
|
288
|
+
/**
|
|
289
|
+
* This method is called to render the layer.
|
|
290
|
+
* It is a no-op for this layer.
|
|
291
|
+
*/
|
|
292
|
+
render(): void;
|
|
293
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AnimatedRouteLayer';
|
|
@@ -235,5 +235,5 @@ declare class CubemapLayer implements CustomLayerInterface {
|
|
|
235
235
|
*/
|
|
236
236
|
hide(): void;
|
|
237
237
|
}
|
|
238
|
-
export declare function validateSpaceSpecification(space?: CubemapDefinition | boolean):
|
|
238
|
+
export declare function validateSpaceSpecification(space?: CubemapDefinition | boolean): string[];
|
|
239
239
|
export { CubemapLayer };
|
package/dist/src/index.d.ts
CHANGED
|
@@ -98,3 +98,5 @@ export * from './custom-layers/index';
|
|
|
98
98
|
export { ColorRamp, ColorRampCollection } from './ColorRamp';
|
|
99
99
|
export type { RgbaColor, ColorStop, ArrayColor, ArrayColorRampStop, ArrayColorRamp, ColorRampOptions } from './ColorRamp';
|
|
100
100
|
export * from './utils';
|
|
101
|
+
export * from './MaptilerAnimation';
|
|
102
|
+
export * from './custom-layers/AnimatedRouteLayer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function arraysAreTheSameLength(...arrays: unknown[][]): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function jsonParseNoThrow<T>(doc: string): T | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isUUID(s: string): boolean;
|
package/e2e/global.d.ts
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
import { Map } from "../src";
|
|
1
|
+
import { Map, StyleSpecificationWithMetaData, type MapOptions } from "../src";
|
|
2
2
|
|
|
3
3
|
declare global {
|
|
4
4
|
interface Window {
|
|
5
5
|
__map: Map;
|
|
6
6
|
__pageObjects: Record<string, any>;
|
|
7
|
+
__pageLoadTimeout: number;
|
|
7
8
|
notifyScreenshotStateReady: (data: TTestTransferData) => Promise<void>;
|
|
8
9
|
notifyTest: (data: TTestTransferData) => Promise<void>;
|
|
10
|
+
setFixtureWithConfig: (config: { id: string; options: MapOptions; requiresScreenShot?: boolean }) => Promise<void>;
|
|
11
|
+
setFixtureMapStyle: (style: string | StyleSpecificationWithMetaData) => Promise<void>;
|
|
12
|
+
__MT_SDK_VERSION__: string;
|
|
13
|
+
__MT_NODE_ENV__: string | undefined;
|
|
14
|
+
__testUtils?: {
|
|
15
|
+
getHaloConfig: () => any;
|
|
16
|
+
getSpaceConfig: () => any;
|
|
17
|
+
hasHalo: () => boolean;
|
|
18
|
+
hasSpace: () => boolean;
|
|
19
|
+
};
|
|
9
20
|
}
|
|
10
21
|
|
|
11
22
|
type TTestTransferData = string | number | boolean | string[] | number[] | boolean[] | null | Record<string, unknown> | [number, number];
|
|
12
23
|
}
|
|
24
|
+
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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>
|
|
@@ -0,0 +1,25 @@
|
|
|
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 Halo Space</title>
|
|
7
|
+
<style>
|
|
8
|
+
#map {
|
|
9
|
+
width: 100vw;
|
|
10
|
+
height: 100vh;
|
|
11
|
+
border: 1px solid red;
|
|
12
|
+
background: repeating-conic-gradient(#eee 0% 25%, #ccc 0% 50%) 0% 0% / 40px 40px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
body {
|
|
16
|
+
margin: 0;
|
|
17
|
+
padding: 0;
|
|
18
|
+
}
|
|
19
|
+
</style>
|
|
20
|
+
</head>
|
|
21
|
+
<body>
|
|
22
|
+
<div id="map"></div>
|
|
23
|
+
<script type="module" src="/src/haloSpace.ts"></script>
|
|
24
|
+
</body>
|
|
25
|
+
</html>
|
package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-0-chromium-linux.png
ADDED
|
Binary file
|
package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-1-chromium-linux.png
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-2-chromium-linux.png
ADDED
|
Binary file
|
package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-3-chromium-linux.png
ADDED
|
Binary file
|
package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-4-chromium-linux.png
ADDED
|
Binary file
|
package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-5-chromium-linux.png
ADDED
|
Binary file
|
package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-6-chromium-linux.png
ADDED
|
Binary file
|
package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-7-chromium-linux.png
ADDED
|
Binary file
|
package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-8-chromium-linux.png
ADDED
|
Binary file
|
package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-9-chromium-linux.png
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|