@maptiler/sdk 3.4.0-rc1 → 3.4.0-rc3

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.
Files changed (74) hide show
  1. package/dist/maptiler-sdk.d.ts +2 -0
  2. package/dist/maptiler-sdk.mjs +11601 -0
  3. package/dist/maptiler-sdk.mjs.map +1 -0
  4. package/dist/playwright.config.d.ts +9 -0
  5. package/dist/src/ColorRamp.d.ts +359 -0
  6. package/dist/src/MLAdapters/AttributionControl.d.ts +5 -0
  7. package/dist/src/MLAdapters/BoxZoomHandler.d.ts +7 -0
  8. package/dist/src/MLAdapters/CanvasSource.d.ts +5 -0
  9. package/dist/src/MLAdapters/CooperativeGesturesHandler.d.ts +5 -0
  10. package/dist/src/MLAdapters/FullscreenControl.d.ts +5 -0
  11. package/dist/src/MLAdapters/GeoJSONSource.d.ts +5 -0
  12. package/dist/src/MLAdapters/GeolocateControl.d.ts +5 -0
  13. package/dist/src/MLAdapters/ImageSource.d.ts +5 -0
  14. package/dist/src/MLAdapters/KeyboardHandler.d.ts +5 -0
  15. package/dist/src/MLAdapters/LogoControl.d.ts +5 -0
  16. package/dist/src/MLAdapters/MapMouseEvent.d.ts +5 -0
  17. package/dist/src/MLAdapters/MapTouchEvent.d.ts +5 -0
  18. package/dist/src/MLAdapters/MapWheelEvent.d.ts +5 -0
  19. package/dist/src/MLAdapters/Marker.d.ts +5 -0
  20. package/dist/src/MLAdapters/NavigationControl.d.ts +5 -0
  21. package/dist/src/MLAdapters/Popup.d.ts +5 -0
  22. package/dist/src/MLAdapters/RasterDEMTileSource.d.ts +5 -0
  23. package/dist/src/MLAdapters/RasterTileSource.d.ts +5 -0
  24. package/dist/src/MLAdapters/ScaleControl.d.ts +5 -0
  25. package/dist/src/MLAdapters/ScrollZoomHandler.d.ts +5 -0
  26. package/dist/src/MLAdapters/Style.d.ts +5 -0
  27. package/dist/src/MLAdapters/TerrainControl.d.ts +5 -0
  28. package/dist/src/MLAdapters/TwoFingersTouchPitchHandler.d.ts +5 -0
  29. package/dist/src/MLAdapters/VectorTileSource.d.ts +5 -0
  30. package/dist/src/MLAdapters/VideoSource.d.ts +5 -0
  31. package/dist/src/Map.d.ts +405 -0
  32. package/dist/src/Point.d.ts +177 -0
  33. package/dist/src/Telemetry.d.ts +40 -0
  34. package/dist/src/caching.d.ts +4 -0
  35. package/dist/src/config.d.ts +85 -0
  36. package/dist/src/constants/defaults.d.ts +15 -0
  37. package/dist/src/controls/MaptilerGeolocateControl.d.ts +21 -0
  38. package/dist/src/controls/MaptilerLogoControl.d.ts +19 -0
  39. package/dist/src/controls/MaptilerNavigationControl.d.ts +17 -0
  40. package/dist/src/controls/MaptilerProjectionControl.d.ts +14 -0
  41. package/dist/src/controls/MaptilerTerrainControl.d.ts +16 -0
  42. package/dist/src/controls/Minimap.d.ts +57 -0
  43. package/dist/src/controls/index.d.ts +6 -0
  44. package/dist/src/converters/index.d.ts +1 -0
  45. package/dist/src/converters/xml.d.ts +54 -0
  46. package/dist/src/custom-layers/AnimatedRouteLayer.d.ts +291 -0
  47. package/dist/src/helpers/index.d.ts +3 -0
  48. package/dist/src/helpers/screenshot.d.ts +18 -0
  49. package/dist/src/helpers/stylehelper.d.ts +28 -0
  50. package/dist/src/helpers/vectorlayerhelpers.d.ts +508 -0
  51. package/dist/src/index.d.ts +88 -0
  52. package/dist/src/language.d.ts +107 -0
  53. package/dist/src/mapstyle.d.ts +17 -0
  54. package/dist/src/tools.d.ts +84 -0
  55. package/dist/src/types.d.ts +1 -0
  56. package/dist/src/utils/MaptilerAnimation/AnimationManager.d.ts +41 -0
  57. package/dist/src/utils/MaptilerAnimation/MaptilerAnimation.d.ts +238 -0
  58. package/dist/src/utils/MaptilerAnimation/animation-helpers.d.ts +182 -0
  59. package/dist/src/utils/MaptilerAnimation/easing.d.ts +3 -0
  60. package/dist/src/utils/MaptilerAnimation/index.d.ts +7 -0
  61. package/dist/src/utils/MaptilerAnimation/types.d.ts +57 -0
  62. package/dist/src/utils/array.d.ts +1 -0
  63. package/dist/src/utils/dom.d.ts +2 -0
  64. package/dist/src/utils/index.d.ts +4 -0
  65. package/dist/vite.config-e2e.d.ts +2 -0
  66. package/dist/vite.config-test.d.ts +2 -0
  67. package/dist/vite.config-umd.d.ts +2 -0
  68. package/dist/vitest-setup-tests.d.ts +1 -0
  69. package/eslint.config.mjs +71 -0
  70. package/package.json +3 -3
  71. package/tsconfig.json +3 -2
  72. package/tsconfig.tsbuildinfo +1 -0
  73. package/vite.config-es.ts +1 -0
  74. package/vite.config-umd.ts +17 -7
@@ -0,0 +1,85 @@
1
+ import { default as EventEmitter } from 'events';
2
+ import { LanguageInfo } from './language';
3
+ import { FetchFunction } from '@maptiler/client';
4
+ import { Unit } from './types';
5
+ export declare const MAPTILER_SESSION_ID: string;
6
+ /**
7
+ * Configuration class for the SDK
8
+ */
9
+ declare class SdkConfig extends EventEmitter {
10
+ /**
11
+ * The primary language. By default, the language of the web browser is used.
12
+ */
13
+ primaryLanguage: LanguageInfo;
14
+ /**
15
+ * The secondary language, to overwrite the default language defined in the map style.
16
+ * This settings is highly dependant on the style compatibility and may not work in most cases.
17
+ */
18
+ secondaryLanguage?: LanguageInfo;
19
+ /**
20
+ * Setting on whether of not the SDK runs with a session logic.
21
+ * A "session" is started at the initialization of the SDK and finished when the browser
22
+ * page is being refreshed.
23
+ * When `session` is enabled (default: true), the extra URL param `mtsid` is added to queries
24
+ * on the MapTiler Cloud API. This allows MapTiler to enable "session based billing".
25
+ */
26
+ session: boolean;
27
+ /**
28
+ * Enables client-side caching of requests for tiles and fonts.
29
+ * The cached requests persist multiple browser sessions and will be reused when possible.
30
+ * Works only for requests to the MapTiler Cloud API when sessions are enabled.
31
+ */
32
+ caching: boolean;
33
+ /**
34
+ * Telemetry is enabled by default but can be opted-out by setting this value to `false`.
35
+ * The telemetry is very valuable to the team at MapTiler because it shares information
36
+ * about where to add the extra effort. It also helps spotting some incompatibility issues
37
+ * that may arise between the SDK and a specific version of a module.
38
+ *
39
+ * It consists in sending metrics about usage of the following features:
40
+ * - SDK version [string]
41
+ * - API key [string]
42
+ * - MapTiler sesion ID (if opted-in) [string]
43
+ * - if tile caching is enabled [boolean]
44
+ * - if language specified at initialization [boolean]
45
+ * - if terrain is activated at initialization [boolean]
46
+ * - if globe projection is activated at initialization [boolean]
47
+ *
48
+ * In addition, each official module will be added to a list, alongside its version number.
49
+ */
50
+ telemetry: boolean;
51
+ /**
52
+ * Unit to be used
53
+ */
54
+ private _unit;
55
+ /**
56
+ * MapTiler Cloud API key
57
+ */
58
+ private _apiKey;
59
+ /**
60
+ * Set the unit system
61
+ */
62
+ set unit(u: Unit);
63
+ /**
64
+ * Get the unit system
65
+ */
66
+ get unit(): Unit;
67
+ /**
68
+ * Set the MapTiler Cloud API key
69
+ */
70
+ set apiKey(k: string);
71
+ /**
72
+ * Get the MapTiler Cloud API key
73
+ */
74
+ get apiKey(): string;
75
+ /**
76
+ * Set a the custom fetch function to replace the default one
77
+ */
78
+ set fetch(f: FetchFunction);
79
+ /**
80
+ * Get the fetch fucntion
81
+ */
82
+ get fetch(): FetchFunction | null;
83
+ }
84
+ declare const config: SdkConfig;
85
+ export { config, SdkConfig };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Some default settings for the SDK
3
+ */
4
+ declare const defaults: {
5
+ maptilerLogoURL: string;
6
+ maptilerURL: string;
7
+ maptilerApiHost: string;
8
+ telemetryURL: string;
9
+ rtlPluginURL: string;
10
+ primaryLanguage: import('@maptiler/client').LanguageInfo;
11
+ secondaryLanguage: import('@maptiler/client').LanguageInfo;
12
+ terrainSourceURL: string;
13
+ terrainSourceId: string;
14
+ };
15
+ export { defaults };
@@ -0,0 +1,21 @@
1
+ import { GeolocateControl } from '../MLAdapters/GeolocateControl';
2
+ /**
3
+ * The MaptilerGeolocateControl is an extension of the original GeolocateControl
4
+ * with a few changes. In this version, the active mode persists as long as the
5
+ * location is still centered. This means it's robust to rotation, pitch and zoom.
6
+ *
7
+ */
8
+ export declare class MaptilerGeolocateControl extends GeolocateControl {
9
+ private lastUpdatedCenter;
10
+ /**
11
+ * Update the camera location to center on the current position
12
+ *
13
+ * @param {Position} position the Geolocation API Position
14
+ * @private
15
+ */
16
+ _updateCamera: (position: GeolocationPosition) => void;
17
+ _finishSetupUI: (supported: boolean) => void;
18
+ _updateCircleRadius(): void;
19
+ _onZoom: () => void;
20
+ _setErrorState(): void;
21
+ }
@@ -0,0 +1,19 @@
1
+ import { LogoControlOptions as LogoControlOptionsML } from 'maplibre-gl';
2
+ import { LogoControl } from '../MLAdapters/LogoControl';
3
+ import { Map as SDKMap } from '../Map';
4
+ type LogoControlOptions = LogoControlOptionsML & {
5
+ logoURL?: string;
6
+ linkURL?: string;
7
+ };
8
+ /**
9
+ * This LogoControl extends the MapLibre LogoControl but instead can use any image URL and
10
+ * any link URL. By default this is using MapTiler logo and URL.
11
+ */
12
+ export declare class MaptilerLogoControl extends LogoControl {
13
+ _compact: boolean;
14
+ private logoURL;
15
+ private linkURL;
16
+ constructor(options?: LogoControlOptions);
17
+ onAdd(map: SDKMap): HTMLElement;
18
+ }
19
+ export {};
@@ -0,0 +1,17 @@
1
+ import { NavigationControlOptions } from 'maplibre-gl';
2
+ import { NavigationControl } from '../MLAdapters/NavigationControl';
3
+ type HTMLButtonElementPlus = HTMLButtonElement & {
4
+ clickFunction: (e?: Event) => unknown;
5
+ };
6
+ export declare class MaptilerNavigationControl extends NavigationControl {
7
+ constructor(options?: NavigationControlOptions);
8
+ /**
9
+ * Overloading: the button now stores its click callback so that we can later on delete it and replace it
10
+ */
11
+ _createButton(className: string, fn: (e?: Event) => unknown): HTMLButtonElementPlus;
12
+ /**
13
+ * Overloading: Limit how flat the compass icon can get
14
+ */
15
+ _rotateCompassArrow: () => void;
16
+ }
17
+ export {};
@@ -0,0 +1,14 @@
1
+ import { Map as SDKMap } from '../Map';
2
+ import { IControl } from 'maplibre-gl';
3
+ /**
4
+ * A `MaptilerProjectionControl` control adds a button to switch from Mercator to Globe projection.
5
+ */
6
+ export declare class MaptilerProjectionControl implements IControl {
7
+ map: SDKMap;
8
+ container: HTMLElement;
9
+ projectionButton: HTMLButtonElement;
10
+ onAdd(map: SDKMap): HTMLElement;
11
+ onRemove(): void;
12
+ private toggleProjection;
13
+ private updateProjectionIcon;
14
+ }
@@ -0,0 +1,16 @@
1
+ import { Map as SDKMap } from '../Map';
2
+ import { IControl } from 'maplibre-gl';
3
+ /**
4
+ * A `MaptilerTerrainControl` control adds a button to turn terrain on and off
5
+ * by triggering the terrain logic that is already deployed in the Map object.
6
+ */
7
+ export declare class MaptilerTerrainControl implements IControl {
8
+ _map: SDKMap;
9
+ _container: HTMLElement;
10
+ _terrainButton: HTMLButtonElement;
11
+ constructor();
12
+ onAdd(map: SDKMap): HTMLElement;
13
+ onRemove(): void;
14
+ _toggleTerrain(): void;
15
+ _updateTerrainIcon(): void;
16
+ }
@@ -0,0 +1,57 @@
1
+ import { Map as SDKMap, MapOptions } from '../Map';
2
+ import { ControlPosition, CustomLayerInterface, FillLayerSpecification, FilterSpecification, IControl, LayerSpecification, LineLayerSpecification, SourceSpecification, StyleOptions, StyleSetterOptions, StyleSpecification, StyleSwapOptions } from 'maplibre-gl';
3
+ import { MapStyleVariant, ReferenceMapStyle } from '@maptiler/client';
4
+ export interface ParentRect {
5
+ lineLayout: LineLayerSpecification["layout"];
6
+ linePaint: LineLayerSpecification["paint"];
7
+ fillPaint: FillLayerSpecification["paint"];
8
+ }
9
+ export interface MinimapOptionsInput {
10
+ /**
11
+ * Style of the map. Can be:
12
+ * - a full style URL (possibly with API key)
13
+ * - a shorthand with only the MapTIler style name (eg. `"streets-v2"`)
14
+ * - a longer form with the prefix `"maptiler://"` (eg. `"maptiler://streets-v2"`)
15
+ */
16
+ style?: ReferenceMapStyle | MapStyleVariant | StyleSpecification | string;
17
+ /**
18
+ * Set the zoom difference between the parent and the minimap
19
+ * If the parent is zoomed to 10 and the minimap is zoomed to 8, the zoomAdjust should be 2
20
+ * Default: -4
21
+ */
22
+ zoomAdjust?: number;
23
+ /** Set a zoom of the minimap and don't allow any future changes */
24
+ lockZoom?: number;
25
+ /** Adjust the pitch only if the user requests */
26
+ pitchAdjust?: boolean;
27
+ /** Set CSS properties of the container using object key-values */
28
+ containerStyle?: Record<string, string>;
29
+ /** Set the position of the minimap at either "top-left", "top-right", "bottom-left", or "bottom-right" */
30
+ position?: ControlPosition;
31
+ /** Set the parentRect fill and/or line options */
32
+ parentRect?: ParentRect;
33
+ }
34
+ export interface MinimapOptions extends MapOptions {
35
+ zoomAdjust: number;
36
+ pitchAdjust: boolean;
37
+ containerStyle: Record<string, string>;
38
+ parentRect?: ParentRect;
39
+ }
40
+ export default class Minimap implements IControl {
41
+ #private;
42
+ map: SDKMap;
43
+ constructor(options: MinimapOptionsInput, mapOptions: MapOptions);
44
+ setStyle(style: null | ReferenceMapStyle | MapStyleVariant | StyleSpecification | string, options?: StyleSwapOptions & StyleOptions): void;
45
+ addLayer(layer: (LayerSpecification & {
46
+ source?: string | SourceSpecification;
47
+ }) | CustomLayerInterface, beforeId?: string): SDKMap;
48
+ moveLayer(id: string, beforeId?: string): SDKMap;
49
+ removeLayer(id: string): this;
50
+ setLayerZoomRange(layerId: string, minzoom: number, maxzoom: number): this;
51
+ setFilter(layerId: string, filter?: FilterSpecification | null, options?: StyleSetterOptions): this;
52
+ setPaintProperty(layerId: string, name: string, value: any, options?: StyleSetterOptions): this;
53
+ setLayoutProperty(layerId: string, name: string, value: any, options?: StyleSetterOptions): this;
54
+ setGlyphs(glyphsUrl: string | null, options?: StyleSetterOptions): this;
55
+ onAdd(parentMap: SDKMap): HTMLElement;
56
+ onRemove(): void;
57
+ }
@@ -0,0 +1,6 @@
1
+ export * from './MaptilerGeolocateControl';
2
+ export * from './MaptilerLogoControl';
3
+ export * from './MaptilerTerrainControl';
4
+ export * from './MaptilerNavigationControl';
5
+ export * from './MaptilerProjectionControl';
6
+ export * from './Minimap';
@@ -0,0 +1 @@
1
+ export * from './xml';
@@ -0,0 +1,54 @@
1
+ export interface Link {
2
+ href: string | null;
3
+ }
4
+ export interface XMLProperties {
5
+ links?: Link[];
6
+ }
7
+ export interface PlacemarkProperties {
8
+ name?: string;
9
+ address?: string;
10
+ styleUrl?: string;
11
+ description?: string;
12
+ styleHash?: string;
13
+ styleMapHash?: Record<string, string | null>;
14
+ timespan?: {
15
+ begin: string;
16
+ end: string;
17
+ };
18
+ timestamp?: string;
19
+ stroke?: string;
20
+ "stroke-opacity"?: number;
21
+ "stroke-width"?: number;
22
+ fill?: string;
23
+ "fill-opacity"?: number;
24
+ visibility?: string;
25
+ icon?: string;
26
+ coordTimes?: (string | null)[] | (string | null)[][];
27
+ }
28
+ /**
29
+ * create a function that converts a string to XML
30
+ * https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
31
+ */
32
+ export declare function str2xml(str: string): Document;
33
+ /**
34
+ * Check one of the top level child node is of a given type ("gpx", "kml").
35
+ * The check is not case sensitive.
36
+ * @param doc
37
+ * @param nodeName
38
+ * @returns
39
+ */
40
+ export declare function hasChildNodeWithName(doc: Document, nodeName: string): boolean;
41
+ /**
42
+ * create a function that converts a XML to a string
43
+ * https://developer.mozilla.org/en-US/docs/Web/API/XMLSerializer
44
+ */
45
+ export declare function xml2str(node: Node): string;
46
+ /**
47
+ * Given a XML document using the GPX spec, return GeoJSON
48
+ */
49
+ export declare function gpx(doc: string | Document): GeoJSON.FeatureCollection;
50
+ /**
51
+ * Given a XML document using the KML spec, return GeoJSON
52
+ */
53
+ export declare function kml(doc: string | Document, xml2string?: (node: Node) => string): GeoJSON.FeatureCollection;
54
+ export declare function gpxOrKml(doc: string | Document): GeoJSON.FeatureCollection | null;
@@ -0,0 +1,291 @@
1
+ import { AnimationEvent, AnimationEventTypes, EasingFunctionName, Keyframe } from '../utils/MaptilerAnimation/types';
2
+ import { default as MaptilerAnimation, MaptilerAnimationOptions } from '../utils/MaptilerAnimation/MaptilerAnimation';
3
+ import { CustomLayerInterface, Map } from '../index';
4
+ export type SourceData = {
5
+ id: string;
6
+ featureSetIndex: number;
7
+ layerID: string;
8
+ };
9
+ /**
10
+ * Options for configuring the animated stroke effect for routes.
11
+ * When an object is provided, it defines colors for active and inactive parts of the route.
12
+ * When `false`, the animated stroke effect is disabled.
13
+ *
14
+ * @typedef {Object|boolean} AnimatedStrokeOptions
15
+ * @property {[number, number, number, number]} activeColor - The color of the path that has been progressed, in RGBA format.
16
+ * @property {[number, number, number, number]} inactiveColor - The base color of the path, in RGBA format.
17
+ */
18
+ export type AnimatedStrokeOptions = {
19
+ activeColor: [number, number, number, number];
20
+ inactiveColor: [number, number, number, number];
21
+ } | false;
22
+ /**
23
+ * Options for configuring the animated camera movement
24
+ * along the route.
25
+ *
26
+ * @typedef {Object|boolean} AnimatedCameraOptions
27
+ * @property {boolean} [follow] - Whether the camera should follow the animation.
28
+ * @property {Object|boolean} [pathSmoothing] - Whether the camera path should be smoothed.
29
+ * @property {number} [pathSmoothing.resolution] - The resolution of the smoothing, higher resolution means more fidelity to the path.
30
+ * @property {number} [pathSmoothing.epsilon] - How much to simplify the path beforehand.
31
+ * @property {false} [pathSmoothing] - Whether the camera path should be smoothed.
32
+ */
33
+ export type AnimatedCameraOptions = {
34
+ /** Whether the camera should follow the animation */
35
+ follow?: boolean;
36
+ /** Whether the camera path should be smoothed */
37
+ pathSmoothing?: {
38
+ /** the resolution of the smoothing, higher resolution means more fidelity to the path */
39
+ resolution: number;
40
+ /** How mich to simplify the path beforehand */
41
+ epsilon: number;
42
+ } | false;
43
+ } | false;
44
+ /**
45
+ * Configuration options for the AnimatedRouteLayer.
46
+ * This type supports either providing keyframes directly OR source data for the animation.
47
+ *
48
+ * @typedef AnimatedRouteLayerOptions
49
+ * @property {number} [duration] - The duration of the animation in milliseconds
50
+ * @property {number} [iterations] - The number of animation iterations to perform
51
+ * @property {number} [delay] - The delay in milliseconds before starting the animation
52
+ * @property {EasingFunctionName} [easing] - The default easing function to use if not provided in the GeoJSON
53
+ * @property {AnimatedCameraOptions} [cameraAnimation] - Options for camera animation
54
+ * @property {AnimatedStrokeOptions} [pathStrokeAnimation] - Options for stroke animation, only applicable for LineString geometries
55
+ * @property {boolean} [autoplay] - Whether the animation should start playing automatically
56
+ * @property {boolean} [manualUpdate] - Whether the animation should update automatically or require manual frameAdvance calls
57
+ * @property {Keyframe[]} [keyframes] - The keyframes for the animation (mutually exclusive with source)
58
+ * @property {SourceData} [source] - The source data for the animation (mutually exclusive with keyframes)
59
+ */
60
+ export type AnimatedRouteLayerOptions = {
61
+ /** The Duration in ms */
62
+ duration?: number;
63
+ /** The number of iterations */
64
+ iterations?: number;
65
+ /** The delay in ms before playing */
66
+ delay?: number;
67
+ /** The default easing to use if not provided in teh GeoJSON */
68
+ easing?: EasingFunctionName;
69
+ /** The camera animation options */
70
+ cameraAnimation?: AnimatedCameraOptions;
71
+ /** The stroke animation options, only viable for LineString geometries */
72
+ pathStrokeAnimation?: AnimatedStrokeOptions;
73
+ /** Whether the animation should autoplay */
74
+ autoplay?: boolean;
75
+ /** Whether the animation should auto matically animated or whether the frameAdvance method should be called */
76
+ manualUpdate?: boolean;
77
+ } & ({
78
+ /** The keyframes for the the animation OR */
79
+ keyframes: Keyframe[];
80
+ source?: never;
81
+ } | {
82
+ /** The source data */
83
+ source: SourceData;
84
+ keyframes?: never;
85
+ });
86
+ /**
87
+ * A callback function that gets executed for each animation frame. This is simply a utility type.
88
+ * @param {AnimationEvent} event - The animation event data provided during animation frame updates.
89
+ */
90
+ export type FrameCallback = (event: AnimationEvent) => void;
91
+ export declare const ANIM_LAYER_PREFIX = "animated-route-layer";
92
+ /**
93
+ * This layer allows you to create animated paths on a map by providing keyframes or a GeoJSON source
94
+ * with route data. The animation can control both the visual appearance of the path (using color transitions)
95
+ * and optionally animate the camera to follow along the route path.
96
+ * @class AnimatedRouteLayer
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * // Create an animated route layer using a GeoJSON source
101
+ * const animatedRoute = new AnimatedRouteLayer({
102
+ * source: {
103
+ * id: 'route-source',
104
+ * layerID: 'route-layer',
105
+ * featureSetIndex: 0
106
+ * },
107
+ * duration: 5000,
108
+ * pathStrokeAnimation: {
109
+ * activeColor: [0, 255, 0, 1],
110
+ * inactiveColor: [100, 100, 100, 0.5]
111
+ * },
112
+ * autoplay: true
113
+ * });
114
+ *
115
+ * // Add the layer to the map
116
+ * map.addLayer(animatedRoute);
117
+ *
118
+ * // Control playback
119
+ * animatedRoute.play();
120
+ * animatedRoute.pause();
121
+ * ```
122
+ *
123
+ * @remarks
124
+ * The animation can be configured using either explicit keyframes or a GeoJSON source.
125
+ * When using a GeoJSON source, the feature can include special properties that control
126
+ * animation behavior:
127
+ * - `@duration`: Animation duration in milliseconds
128
+ * - `@iterations`: Number of times to repeat the animation
129
+ * - `@delay`: Delay before starting animation in milliseconds
130
+ * - `@autoplay`: Whether to start the animation automatically
131
+ *
132
+ * Only one AnimatedRouteLayer can be active at a time on a map.
133
+ */
134
+ /**
135
+ * Creates an animated route layer for MapTiler maps.
136
+ *
137
+ * The `AnimatedRouteLayer` allows you to animate paths on a map with visual effects and optional camera following.
138
+ * You can define animations either through explicit keyframes or by referencing GeoJSON data with animation metadata.
139
+ *
140
+ * Features:
141
+ * - Animate route paths with color transitions (active/inactive segments)
142
+ * - Optional camera following along the route
143
+ * - Control animation playback (play, pause)
144
+ * - Configure animation properties (duration, iterations, delay, easing)
145
+ * - Support for manual or automatic animation updates
146
+ * - Event system for animation state changes
147
+ *
148
+ * @example
149
+ * ```typescript
150
+ * // Create an animated route from GeoJSON source
151
+ * const animatedRoute = new AnimatedRouteLayer({
152
+ * source: {
153
+ * id: 'route-source',
154
+ * layerID: 'route-layer',
155
+ * featureSetIndex: 0
156
+ * },
157
+ * duration: 5000,
158
+ * iterations: 1,
159
+ * autoplay: true,
160
+ * cameraAnimation: {
161
+ * follow: true,
162
+ * pathSmoothing: { resolution: 20, epsilon: 5 }
163
+ * },
164
+ * pathStrokeAnimation: {
165
+ * activeColor: [255, 0, 0, 1],
166
+ * inactiveColor: [0, 0, 255, 1]
167
+ * }
168
+ * });
169
+ *
170
+ * // Add the layer to the map
171
+ * map.addLayer(animatedRoute);
172
+ *
173
+ * // Control playback
174
+ * animatedRoute.pause();
175
+ * animatedRoute.play();
176
+ *
177
+ * // Listen for animation events
178
+ * animatedRoute.addEventListener(AnimationEventTypes.Finish, () => {
179
+ * console.log('Animation completed');
180
+ * });
181
+ * ```
182
+ *
183
+ * @implements {CustomLayerInterface}
184
+ */
185
+ export declare class AnimatedRouteLayer implements CustomLayerInterface {
186
+ /** Unique ID for the layer */
187
+ readonly id: string;
188
+ readonly type = "custom";
189
+ /** The MaptilerAnimation instance that handles the animation */
190
+ animationInstance: MaptilerAnimation;
191
+ /**
192
+ * Keyframes for the animation
193
+ * If keyframes are provided, they will be used for the animation
194
+ * If a source is provided, the keyframes will be parsed from the GeoJSON feature
195
+ */
196
+ private keyframes;
197
+ /**
198
+ * Source data for the animation
199
+ * If a source is provided, it will be used to get the keyframes
200
+ * If keyframes are provided, this will be ignored
201
+ */
202
+ private source;
203
+ /** The duration of the animation in ms */
204
+ private duration;
205
+ /** The number of interations */
206
+ private iterations;
207
+ /** The delay before the animation starts in ms */
208
+ private delay;
209
+ /** The default easing function for the animation */
210
+ private easing?;
211
+ /** The map instance */
212
+ private map;
213
+ /** The camera animation options */
214
+ private cameraMaptilerAnimationOptions?;
215
+ /**
216
+ * The path stroke animation options
217
+ * This controls the color of the path during the animation
218
+ */
219
+ private pathStrokeAnimation?;
220
+ /** Whether the animation will autoplay */
221
+ private autoplay;
222
+ /** Whether the animation will be managed manually */
223
+ private manualUpdate;
224
+ private enquedEventHandlers;
225
+ private enquedCommands;
226
+ constructor({ keyframes, source, duration, iterations, easing, delay, cameraAnimation, pathStrokeAnimation, autoplay, manualUpdate, }: AnimatedRouteLayerOptions);
227
+ /**
228
+ * This method is called when the layer is added to the map.
229
+ * It initializes the animation instance and sets up event listeners.
230
+ *
231
+ * @param {Map} map - The map instance
232
+ */
233
+ onAdd(map: Map): Promise<void>;
234
+ /**
235
+ * This method is used to manually advance the animation
236
+ *
237
+ * @returns {AnimatedRouteLayer} - The current instance of AnimatedRouteLayer
238
+ */
239
+ frameAdvance(): this;
240
+ /**
241
+ * Adds an event listener to the animation instance.
242
+ *
243
+ * @param {AnimationEventTypes} type - The type of event to listen for
244
+ * @param {FrameCallback} callback - The callback function to execute when the event occurs
245
+ */
246
+ addEventListener(type: AnimationEventTypes, callback: FrameCallback): AnimatedRouteLayer;
247
+ /**
248
+ * Removes an event listener from the animation instance.
249
+ *
250
+ * @param {AnimationEventTypes} type - The type of event to remove
251
+ * @param {FrameCallback} callback - The callback function to remove
252
+ */
253
+ removeEventListener(type: AnimationEventTypes, callback: FrameCallback): AnimatedRouteLayer;
254
+ updateManual(): void;
255
+ /**
256
+ * Updates the layer's properties based on the animation event.
257
+ * @private
258
+ * @param {AnimationEvent} event - The animation event
259
+ */
260
+ private update;
261
+ /**
262
+ * Plays the animation.
263
+ *
264
+ * @returns {AnimatedRouteLayer} - The current instance of AnimatedRouteLayer
265
+ */
266
+ play(): AnimatedRouteLayer;
267
+ /**
268
+ * Stops the animation.
269
+ *
270
+ * @returns {AnimatedRouteLayer} - The current instance of AnimatedRouteLayer
271
+ */
272
+ pause(): AnimatedRouteLayer;
273
+ /**
274
+ * Gets the source GeoJSON data from the map instance, parses it, and returns the animation options.
275
+ *
276
+ * @returns {Promise<MaptilerAnimationOptions>} - The MaptilerAnimation constructor options
277
+ */
278
+ getMaptilerAnimationOptions(): Promise<MaptilerAnimationOptions & {
279
+ autoplay: boolean;
280
+ }>;
281
+ /**
282
+ * This method is called when the layer is removed from the map.
283
+ * It destroys the animation instance.
284
+ */
285
+ onRemove(): void;
286
+ /**
287
+ * This method is called to render the layer.
288
+ * It is a no-op for this layer.
289
+ */
290
+ render(): void;
291
+ }
@@ -0,0 +1,3 @@
1
+ export * from './screenshot';
2
+ export * from './vectorlayerhelpers';
3
+ export * from './stylehelper';
@@ -0,0 +1,18 @@
1
+ import { Map as MapSDK } from '../Map';
2
+ /**
3
+ * Takes a screenshot (PNG file) of the curent map view.
4
+ * Depending on the options, this function can automatically trigger a download of te file.
5
+ */
6
+ export declare function takeScreenshot(map: MapSDK, options?: {
7
+ /**
8
+ * If `true`, this function will trigger a download in addition to returning a blob.
9
+ * Default: `false`
10
+ */
11
+ download?: boolean;
12
+ /**
13
+ * Only if `options.download` is `true`. Indicates the filename under which
14
+ * the file will be downloaded.
15
+ * Default: `"maptiler_screenshot.png"`
16
+ */
17
+ filename?: string;
18
+ }): Promise<Blob>;
@@ -0,0 +1,28 @@
1
+ import { DataDrivenPropertyValueSpecification, ExpressionSpecification } from 'maplibre-gl';
2
+ import { ColorRamp } from '../ColorRamp';
3
+ import { DataDrivenStyle, PropertyValues, ZoomNumberValues, ZoomStringValues } from './vectorlayerhelpers';
4
+ export type ColorPalette = [string, string, string, string];
5
+ export declare const colorPalettes: Array<ColorPalette>;
6
+ export declare function getRandomColor(): string;
7
+ export declare function generateRandomSourceName(): string;
8
+ export declare function generateRandomLayerName(): string;
9
+ /**
10
+ * Linera interpolation to find a value at an arbitrary zoom level, given a list of tuple zoom-value
11
+ */
12
+ export declare function lerpZoomNumberValues(znv: ZoomNumberValues, z: number): number;
13
+ export declare function paintColorOptionsToPaintSpec(color: ZoomStringValues): DataDrivenPropertyValueSpecification<string>;
14
+ export declare function rampedOptionsToLayerPaintSpec(ramp: ZoomNumberValues): DataDrivenPropertyValueSpecification<number>;
15
+ export declare function computeRampedOutlineWidth(lineWidth: number | ZoomNumberValues, outlineWidth: number | ZoomNumberValues): number | DataDrivenPropertyValueSpecification<number>;
16
+ export declare function rampedPropertyValueWeight(ramp: PropertyValues, property: string): DataDrivenPropertyValueSpecification<number>;
17
+ /**
18
+ * Create a dash array from a string pattern that uses underscore and whitespace characters
19
+ */
20
+ export declare function dashArrayMaker(pattern: string): Array<number>;
21
+ export declare function colorDrivenByProperty(style: DataDrivenStyle, property: string): DataDrivenPropertyValueSpecification<string>;
22
+ export declare function radiusDrivenByProperty(style: DataDrivenStyle, property: string, zoomCompensation?: boolean): DataDrivenPropertyValueSpecification<number>;
23
+ export declare function radiusDrivenByPropertyHeatmap(style: PropertyValues, property: string, zoomCompensation?: boolean): DataDrivenPropertyValueSpecification<number>;
24
+ /**
25
+ * Turns a ColorRamp instance into a MapLibre style for ramping the opacity, driven by a property
26
+ */
27
+ export declare function opacityDrivenByProperty(colorramp: ColorRamp, property: string): DataDrivenPropertyValueSpecification<number>;
28
+ export declare function heatmapIntensityFromColorRamp(colorRamp: ColorRamp, steps?: number): ExpressionSpecification;