@maptiler/sdk 3.10.0 → 3.10.1-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/dist/eslint.mjs +133 -0
- package/dist/maptiler-sdk.d.ts +2 -0
- package/dist/maptiler-sdk.mjs +14235 -0
- package/dist/maptiler-sdk.mjs.map +1 -0
- package/dist/src/ColorRamp.d.ts +359 -0
- package/dist/src/ImageViewer/ImageViewer.d.ts +408 -0
- package/dist/src/ImageViewer/ImageViewerMarker.d.ts +236 -0
- package/dist/src/ImageViewer/events.d.ts +47 -0
- package/dist/src/ImageViewer/index.d.ts +5 -0
- package/dist/src/ImageViewer/monkeyPatchML.d.ts +10 -0
- package/dist/src/ImageViewer/symbols.d.ts +2 -0
- package/dist/src/MLAdapters/AttributionControl.d.ts +5 -0
- package/dist/src/MLAdapters/BoxZoomHandler.d.ts +7 -0
- package/dist/src/MLAdapters/CanvasSource.d.ts +5 -0
- package/dist/src/MLAdapters/CooperativeGesturesHandler.d.ts +5 -0
- package/dist/src/MLAdapters/FullscreenControl.d.ts +5 -0
- package/dist/src/MLAdapters/GeoJSONSource.d.ts +5 -0
- package/dist/src/MLAdapters/GeolocateControl.d.ts +5 -0
- package/dist/src/MLAdapters/ImageSource.d.ts +5 -0
- package/dist/src/MLAdapters/KeyboardHandler.d.ts +5 -0
- package/dist/src/MLAdapters/LogoControl.d.ts +5 -0
- package/dist/src/MLAdapters/MapMouseEvent.d.ts +5 -0
- package/dist/src/MLAdapters/MapTouchEvent.d.ts +5 -0
- package/dist/src/MLAdapters/MapWheelEvent.d.ts +5 -0
- package/dist/src/MLAdapters/Marker.d.ts +5 -0
- package/dist/src/MLAdapters/NavigationControl.d.ts +5 -0
- package/dist/src/MLAdapters/Popup.d.ts +5 -0
- package/dist/src/MLAdapters/RasterDEMTileSource.d.ts +5 -0
- package/dist/src/MLAdapters/RasterTileSource.d.ts +5 -0
- package/dist/src/MLAdapters/ScaleControl.d.ts +5 -0
- package/dist/src/MLAdapters/ScrollZoomHandler.d.ts +5 -0
- package/dist/src/MLAdapters/Style.d.ts +5 -0
- package/dist/src/MLAdapters/TerrainControl.d.ts +5 -0
- package/dist/src/MLAdapters/TwoFingersTouchPitchHandler.d.ts +5 -0
- package/dist/src/MLAdapters/VectorTileSource.d.ts +5 -0
- package/dist/src/MLAdapters/VideoSource.d.ts +5 -0
- package/dist/src/Map.d.ts +480 -0
- package/dist/src/Point.d.ts +177 -0
- package/dist/src/Telemetry.d.ts +23 -0
- package/dist/src/caching.d.ts +4 -0
- package/dist/src/config.d.ts +85 -0
- package/dist/src/constants/defaults.d.ts +15 -0
- package/dist/src/controls/ImageViewerFitImageToBoundsControl.d.ts +13 -0
- package/dist/src/controls/MaptilerCustomControl.d.ts +17 -0
- package/dist/src/controls/MaptilerExternalControl.d.ts +25 -0
- package/dist/src/controls/MaptilerGeolocateControl.d.ts +21 -0
- package/dist/src/controls/MaptilerLogoControl.d.ts +19 -0
- package/dist/src/controls/MaptilerNavigationControl.d.ts +17 -0
- package/dist/src/controls/MaptilerProjectionControl.d.ts +15 -0
- package/dist/src/controls/MaptilerTerrainControl.d.ts +17 -0
- package/dist/src/controls/Minimap.d.ts +57 -0
- package/dist/src/controls/index.d.ts +8 -0
- package/dist/src/converters/index.d.ts +1 -0
- package/dist/src/converters/xml.d.ts +54 -0
- package/dist/src/custom-layers/CubemapLayer/CubemapLayer.d.ts +239 -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 +43 -0
- package/dist/src/custom-layers/CubemapLayer/types.d.ts +67 -0
- package/dist/src/custom-layers/RadialGradientLayer/RadialGradientLayer.d.ts +149 -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 +6 -0
- package/dist/src/helpers/index.d.ts +5 -0
- package/dist/src/helpers/screenshot.d.ts +18 -0
- package/dist/src/helpers/stylehelper.d.ts +28 -0
- package/dist/src/helpers/vectorlayerhelpers.d.ts +508 -0
- package/dist/src/index.d.ts +100 -0
- package/dist/src/language.d.ts +107 -0
- package/dist/src/mapstyle.d.ts +18 -0
- package/dist/src/ml-types.d.ts +634 -0
- package/dist/src/tools.d.ts +84 -0
- package/dist/src/types.d.ts +1 -0
- package/dist/src/utils/dom.d.ts +2 -0
- package/dist/src/utils/errors.d.ts +5 -0
- package/dist/src/utils/geo-utils.d.ts +6 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/logSDKVersion.d.ts +1 -0
- package/dist/src/utils/math-utils.d.ts +8 -0
- package/dist/src/utils/object.d.ts +1 -0
- package/dist/src/utils/webgl-utils.d.ts +49 -0
- package/package.json +3 -3
|
@@ -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,13 @@
|
|
|
1
|
+
import { IControl } from 'maplibre-gl';
|
|
2
|
+
import { ImageViewer } from '../ImageViewer';
|
|
3
|
+
import { Map as MapSDK } from '../Map';
|
|
4
|
+
export declare class ImageViewerFitImageToBoundsControl implements IControl {
|
|
5
|
+
private viewer;
|
|
6
|
+
private container;
|
|
7
|
+
constructor({ imageViewer }: {
|
|
8
|
+
imageViewer: ImageViewer;
|
|
9
|
+
});
|
|
10
|
+
handleClick: () => void;
|
|
11
|
+
onAdd(_map: MapSDK): HTMLElement;
|
|
12
|
+
onRemove(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Map as SDKMap } from '../Map';
|
|
2
|
+
import { IControl, MapLibreEvent } from 'maplibre-gl';
|
|
3
|
+
export type MaptilerCustomControlCallback<E> = (map: SDKMap, element: HTMLElement, event: E) => void;
|
|
4
|
+
/**
|
|
5
|
+
* The MaptilerCustomControl allows any existing element to become a map control.
|
|
6
|
+
*/
|
|
7
|
+
export declare class MaptilerCustomControl implements IControl {
|
|
8
|
+
#private;
|
|
9
|
+
/**
|
|
10
|
+
* @param selectorOrElement Element to be used as control, specified as either reference to element itself or a CSS selector to find the element in DOM
|
|
11
|
+
* @param onClick Function called when the element is clicked
|
|
12
|
+
* @param onRender Function called every time the underlying map renders a new state
|
|
13
|
+
*/
|
|
14
|
+
constructor(selectorOrElement: string | HTMLElement, onClick?: MaptilerCustomControlCallback<Event>, onRender?: MaptilerCustomControlCallback<MapLibreEvent>);
|
|
15
|
+
onAdd(map: SDKMap): HTMLElement;
|
|
16
|
+
onRemove(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Map as SDKMap } from '../Map';
|
|
2
|
+
import { IControl } from 'maplibre-gl';
|
|
3
|
+
import { MaptilerCustomControl, MaptilerCustomControlCallback } from './MaptilerCustomControl';
|
|
4
|
+
export type MaptilerExternalControlType = "zoom-in" | "zoom-out" | "toggle-projection" | "toggle-terrain" | "reset-view" | "reset-bearing" | "reset-pitch" | "reset-roll";
|
|
5
|
+
/**
|
|
6
|
+
* The MaptilerExternalControl allows any existing element to automatically become a map control. Used for detected controls if `customControls` config is turned on.
|
|
7
|
+
*/
|
|
8
|
+
export declare class MaptilerExternalControl extends MaptilerCustomControl implements IControl {
|
|
9
|
+
#private;
|
|
10
|
+
static controlCallbacks: Record<MaptilerExternalControlType, MaptilerCustomControlCallback<Event>>;
|
|
11
|
+
/**
|
|
12
|
+
* Constructs an instance of External Control to have a predefined functionality
|
|
13
|
+
* @param controlElement Element to be used as control, specified as reference to element itself
|
|
14
|
+
* @param controlType One of the predefined types of functionality
|
|
15
|
+
*/
|
|
16
|
+
constructor(controlElement: HTMLElement, controlType?: MaptilerExternalControlType);
|
|
17
|
+
onAdd(map: SDKMap): HTMLElement;
|
|
18
|
+
onRemove(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Configure a child element to be part of this control and to have a predefined functionality added
|
|
21
|
+
* @param controlElement Element that is a descendant of the control element and that optionally should have some functionality
|
|
22
|
+
* @param controlType One of the predefined types of functionality
|
|
23
|
+
*/
|
|
24
|
+
configureGroupItem(controlElement: HTMLElement, controlType: MaptilerExternalControlType | undefined): void;
|
|
25
|
+
}
|
|
@@ -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,15 @@
|
|
|
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
|
+
}
|
|
15
|
+
export declare function toggleProjection(map: SDKMap): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
}
|
|
17
|
+
export declare function toggleTerrain(map: SDKMap): void;
|
|
@@ -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 Omit<MapOptions, "space" | "halo"> {
|
|
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,8 @@
|
|
|
1
|
+
export * from './MaptilerCustomControl';
|
|
2
|
+
export * from './MaptilerExternalControl';
|
|
3
|
+
export * from './MaptilerGeolocateControl';
|
|
4
|
+
export * from './MaptilerLogoControl';
|
|
5
|
+
export * from './MaptilerTerrainControl';
|
|
6
|
+
export * from './MaptilerNavigationControl';
|
|
7
|
+
export * from './MaptilerProjectionControl';
|
|
8
|
+
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,239 @@
|
|
|
1
|
+
import { CustomLayerInterface, CustomRenderMethodInput } from 'maplibre-gl';
|
|
2
|
+
import { Map as MapSDK } from '../../Map';
|
|
3
|
+
import { WebGLContext } from '../../utils/webgl-utils';
|
|
4
|
+
import { CubemapDefinition, CubemapFaces, CubemapLayerConstructorOptions } from './types';
|
|
5
|
+
declare class CubemapLayer implements CustomLayerInterface {
|
|
6
|
+
id: string;
|
|
7
|
+
type: CustomLayerInterface["type"];
|
|
8
|
+
renderingMode: CustomLayerInterface["renderingMode"];
|
|
9
|
+
/**
|
|
10
|
+
* The map instance to which this layer is added.
|
|
11
|
+
* @type {MapSDK}
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
private map;
|
|
15
|
+
/**
|
|
16
|
+
* The cubemap faces definition, which can be either a preset, path, or explicit face URLs.
|
|
17
|
+
* @type {CubemapFaces | null}
|
|
18
|
+
* @remarks
|
|
19
|
+
* This property is set during the initialization of the layer and can be updated later.
|
|
20
|
+
* If no faces are defined, it will be `null`.
|
|
21
|
+
*/
|
|
22
|
+
private faces?;
|
|
23
|
+
/**
|
|
24
|
+
* Indicates whether to use a cubemap texture for rendering.
|
|
25
|
+
* @type {boolean}
|
|
26
|
+
* @private
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
private useCubemapTexture;
|
|
30
|
+
/**
|
|
31
|
+
* The current opacity of the fade effect applied to the cubemap image texture, used for fading in and out.
|
|
32
|
+
* @type {number}
|
|
33
|
+
* @private
|
|
34
|
+
* @default 0.0
|
|
35
|
+
*/
|
|
36
|
+
private currentFadeOpacity;
|
|
37
|
+
/**
|
|
38
|
+
* Indicates whether the cubemap needs to be updated, typically when the faces or texture changes.
|
|
39
|
+
* @type {boolean}
|
|
40
|
+
* @private
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
private cubeMapNeedsUpdate;
|
|
44
|
+
/**
|
|
45
|
+
* The background color of the cubemap layer, represented as a Vec4 (RGBA).
|
|
46
|
+
* @type {Vec4}
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
private bgColor;
|
|
50
|
+
/**
|
|
51
|
+
* The previous background color used for transition animations.
|
|
52
|
+
* @type {Vec4}
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
private previousBgColor;
|
|
56
|
+
/**
|
|
57
|
+
* The target background color to which the layer will transition.
|
|
58
|
+
* @type {Vec4}
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
private targetBgColor;
|
|
62
|
+
/**
|
|
63
|
+
* The delta value used for transitioning the background color. 0 = start of transition, 1 = end of transition.
|
|
64
|
+
* This value is incremented over time to create a smooth transition effect.
|
|
65
|
+
* @type {number}
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
private transitionDelta;
|
|
69
|
+
/**
|
|
70
|
+
* The WebGL context used for rendering the cubemap layer.
|
|
71
|
+
* @type {WebGLContext}
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
private gl;
|
|
75
|
+
/**
|
|
76
|
+
* The cubemap object that contains the shader program, buffers and uniform locations for rendering.
|
|
77
|
+
* @type {Object3D}
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
private cubemap?;
|
|
81
|
+
/**
|
|
82
|
+
* The WebGL texture used for the cubemap, which is created from the defined faces.
|
|
83
|
+
* This texture is used to render the cubemap in the scene.
|
|
84
|
+
* @type {WebGLTexture | undefined}
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
private texture?;
|
|
88
|
+
/**
|
|
89
|
+
* The key representing the current faces definition, used to diff / track changes in the cubemap faces.
|
|
90
|
+
* @type {string}
|
|
91
|
+
*/
|
|
92
|
+
currentFacesDefinitionKey: string;
|
|
93
|
+
/**
|
|
94
|
+
* The configuration options for the cubemap layer.
|
|
95
|
+
* @type {CubemapLayerConstructorOptions}
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
private options;
|
|
99
|
+
private animationActive;
|
|
100
|
+
/**
|
|
101
|
+
* Creates a new instance of CubemapLayer
|
|
102
|
+
*
|
|
103
|
+
* @param {CubemapLayerConstructorOptions | true} cubemapConfig - Configuration options for the cubemap layer or `true` to use default options.
|
|
104
|
+
* Can specify faces, preset, path, and color properties to configure the cubemap.
|
|
105
|
+
*
|
|
106
|
+
* @remarks You shouldn't have to use this class directly.
|
|
107
|
+
* Instead, use the `Map.setHalo` method to create and add a halo layer to the map.
|
|
108
|
+
* The constructor initializes the cubemap with the provided configuration.
|
|
109
|
+
* It processes the faces definition, sets up background colors, and determines
|
|
110
|
+
* whether to use a cubemap texture based on the provided options.
|
|
111
|
+
*/
|
|
112
|
+
constructor(cubemapConfig: CubemapLayerConstructorOptions | true);
|
|
113
|
+
/**
|
|
114
|
+
* Updates the cubemap object with the current faces and shader configuration.
|
|
115
|
+
* This method is called when the cubemap faces change or when the layer is initialized.
|
|
116
|
+
* @returns {void}
|
|
117
|
+
* @remarks
|
|
118
|
+
* It creates a new Object3D instance with the specified vertex and fragment shaders,
|
|
119
|
+
* attributes, and uniforms. The cubemap will be rendered using this configuration.
|
|
120
|
+
*/
|
|
121
|
+
updateCubemap({ facesNeedUpdate }?: {
|
|
122
|
+
facesNeedUpdate: boolean;
|
|
123
|
+
}): void;
|
|
124
|
+
/**
|
|
125
|
+
* Called when the layer is added to the map.
|
|
126
|
+
* Initializes the cubemap and sets up the WebGL context.
|
|
127
|
+
*
|
|
128
|
+
* @param {MapSDK} map - The map instance to which this layer is added.
|
|
129
|
+
* @param {WebGLRenderingContext | WebGL2RenderingContext} gl - The WebGL context used for rendering.
|
|
130
|
+
*/
|
|
131
|
+
onAdd(map: MapSDK, gl: WebGLRenderingContext | WebGL2RenderingContext): void;
|
|
132
|
+
/**
|
|
133
|
+
* Called when the layer is removed from the map.
|
|
134
|
+
* Cleans up the cubemap resources and WebGL buffers.
|
|
135
|
+
*
|
|
136
|
+
* @param {MapSDK} _map - The map instance from which this layer is removed.
|
|
137
|
+
* @param {WebGLRenderingContext | WebGL2RenderingContext} gl - The WebGL context used for rendering.
|
|
138
|
+
*/
|
|
139
|
+
onRemove(_map: MapSDK, gl: WebGLRenderingContext | WebGL2RenderingContext): void;
|
|
140
|
+
/**
|
|
141
|
+
* Updates the cubemap texture with the provided faces.
|
|
142
|
+
* This method is called when the cubemap faces change or when the layer is initialized.
|
|
143
|
+
*
|
|
144
|
+
* @param {WebGLContext} gl - The WebGL context used for rendering.
|
|
145
|
+
* @param {CubemapFaces} faces - The cubemap faces to be loaded into the texture.
|
|
146
|
+
*/
|
|
147
|
+
updateTexture(gl: WebGLContext, faces: CubemapFaces): void;
|
|
148
|
+
/**
|
|
149
|
+
* Called before the layer is rendered.
|
|
150
|
+
* Updates the cubemap texture with the current faces.
|
|
151
|
+
*
|
|
152
|
+
* @param {WebGLContext} gl - The WebGL context used for rendering.
|
|
153
|
+
* @param {CustomRenderMethodInput} _options - Additional options for the render method.
|
|
154
|
+
*/
|
|
155
|
+
prerender(_gl: WebGLContext, _options: CustomRenderMethodInput): void;
|
|
156
|
+
/**
|
|
157
|
+
* Lerps the background color transition of the cubemap layer.
|
|
158
|
+
* This method smoothly transitions the background color from the previous color to the target color.
|
|
159
|
+
*
|
|
160
|
+
* @private
|
|
161
|
+
*/
|
|
162
|
+
private animateColorChange;
|
|
163
|
+
/**
|
|
164
|
+
* Animates the cubemap image fading in.
|
|
165
|
+
* This method gradually increases the opacity of the cubemap image to create a fade-in effect.
|
|
166
|
+
*
|
|
167
|
+
* @private
|
|
168
|
+
*/
|
|
169
|
+
private imageIsAnimating;
|
|
170
|
+
/**
|
|
171
|
+
* The delta value used for the image fade-in animation.
|
|
172
|
+
* This value is incremented over time to create a smooth fade-in effect.
|
|
173
|
+
* @type {number}
|
|
174
|
+
* @private
|
|
175
|
+
*/
|
|
176
|
+
private imageFadeInDelta;
|
|
177
|
+
/**
|
|
178
|
+
* Animates the cubemap image fading in.
|
|
179
|
+
* This method gradually increases the opacity of the cubemap image to create a fade-in effect.
|
|
180
|
+
* @private
|
|
181
|
+
*/
|
|
182
|
+
private animateIn;
|
|
183
|
+
/**
|
|
184
|
+
* Animates the cubemap image fading out.
|
|
185
|
+
* This method gradually decreases the opacity of the cubemap image to create a fade-out effect.
|
|
186
|
+
* @returns {Promise<void>} A promise that resolves when the animation is complete.
|
|
187
|
+
* @private
|
|
188
|
+
*/
|
|
189
|
+
private animateOut;
|
|
190
|
+
setAnimationActive(active: boolean): void;
|
|
191
|
+
/**
|
|
192
|
+
* Renders the cubemap layer to the WebGL context.
|
|
193
|
+
* This method is called internally during the rendering phase of the map.
|
|
194
|
+
*
|
|
195
|
+
* @param {WebGLRenderingContext | WebGL2RenderingContext} gl - The WebGL context used for rendering.
|
|
196
|
+
* @param {CustomRenderMethodInput} _options - Additional options for the render method.
|
|
197
|
+
* @throws Error if the map, cubemap, or texture is undefined.
|
|
198
|
+
*/
|
|
199
|
+
render(gl: WebGLRenderingContext | WebGL2RenderingContext, _options: CustomRenderMethodInput): void;
|
|
200
|
+
private setBgColor;
|
|
201
|
+
/**
|
|
202
|
+
* Returns the current configuration options for the cubemap layer.
|
|
203
|
+
* @returns {CubemapLayerConstructorOptions} The current configuration options.
|
|
204
|
+
*/
|
|
205
|
+
getConfig(): CubemapLayerConstructorOptions;
|
|
206
|
+
/**
|
|
207
|
+
* Checks if the cubemap needs to be updated based on the provided specification.
|
|
208
|
+
*
|
|
209
|
+
* @param {CubemapDefinition} spec - The cubemap specification to compare with the current cubemap.
|
|
210
|
+
* @returns {boolean} True if the cubemap needs to be updated, false otherwise.
|
|
211
|
+
*/
|
|
212
|
+
shouldUpdate(newSpec?: CubemapDefinition | boolean): boolean;
|
|
213
|
+
private setCubemapFaces;
|
|
214
|
+
/**
|
|
215
|
+
* Sets the cubemap for the layer based on the provided definition.
|
|
216
|
+
* This method updates the cubemap faces, background color, and triggers a repaint of the map.
|
|
217
|
+
*
|
|
218
|
+
* @param {CubemapDefinition} cubemap - The cubemap definition containing faces, preset, path, or color.
|
|
219
|
+
* @returns {Promise<void>} A promise that resolves when the cubemap is set and the map is updated.
|
|
220
|
+
* @remarks
|
|
221
|
+
* This method checks if the provided cubemap definition has a color, and if so, it updates the background color.
|
|
222
|
+
* It also checks if the faces definition has changed compared to the current one,
|
|
223
|
+
* and if so, it updates the cubemap faces.
|
|
224
|
+
* Finally, it calls `updateCubemap` to apply the changes and trigger a repaint of the map.
|
|
225
|
+
*/
|
|
226
|
+
setCubemap(spec: CubemapDefinition | boolean): Promise<void>;
|
|
227
|
+
/**
|
|
228
|
+
* Shows the cubemap layer by setting its visibility to "visible".
|
|
229
|
+
* This method is used to make the cubemap layer visible on the map.
|
|
230
|
+
*/
|
|
231
|
+
show(): void;
|
|
232
|
+
/**
|
|
233
|
+
* Hides the cubemap layer by setting its visibility to "none".
|
|
234
|
+
* This method is used to remove the cubemap layer from the map without deleting it.
|
|
235
|
+
*/
|
|
236
|
+
hide(): void;
|
|
237
|
+
}
|
|
238
|
+
export declare function validateSpaceSpecification(space?: CubemapDefinition | boolean): boolean;
|
|
239
|
+
export { CubemapLayer };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CubemapFaces } from './types';
|
|
2
|
+
type WebGLCtx = WebGLRenderingContext | WebGL2RenderingContext;
|
|
3
|
+
interface LoadCubemapTextureOptions {
|
|
4
|
+
gl: WebGLCtx;
|
|
5
|
+
faces?: CubemapFaces;
|
|
6
|
+
onReady: (texture: WebGLTexture, images?: HTMLImageElement[]) => void;
|
|
7
|
+
forceRefresh?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function deleteMemoizedTexture(gl: WebGLCtx): void;
|
|
10
|
+
/**
|
|
11
|
+
* Loads a cubemap texture from a set of image URLs.
|
|
12
|
+
*
|
|
13
|
+
* This function creates and configures a WebGL cubemap texture from a set of images.
|
|
14
|
+
* It memoizes the created texture to avoid redundant loading of the same faces,
|
|
15
|
+
* unless the `forceRefresh` flag is set.
|
|
16
|
+
*
|
|
17
|
+
* @param {Object} options - The options object.
|
|
18
|
+
* @param {WebGLRenderingContext | WebGL2RenderingContext} options.gl - The WebGL rendering context.
|
|
19
|
+
* @param {CubemapFaces} options.faces - An object containing URLs for each face of the cubemap.
|
|
20
|
+
* Must contain exactly 6 faces.
|
|
21
|
+
* @param {Function} [options.onReady] - Optional callback function to be called when all faces are loaded.
|
|
22
|
+
* @param {boolean} [options.forceRefresh] - If true, forces creation of a new texture instead of returning the memoized one.
|
|
23
|
+
*
|
|
24
|
+
* @returns {WebGLTexture | undefined} The created WebGL cubemap texture, or undefined if there was an error.
|
|
25
|
+
*
|
|
26
|
+
* @see {@link facesKey}
|
|
27
|
+
* @see {@link memoizedReturnValue}
|
|
28
|
+
* @example
|
|
29
|
+
* const texture = loadCubemapTexture({
|
|
30
|
+
* gl: webglContext,
|
|
31
|
+
* faces: {
|
|
32
|
+
* px: 'right.jpg',
|
|
33
|
+
* nx: 'left.jpg',
|
|
34
|
+
* py: 'top.jpg',
|
|
35
|
+
* ny: 'bottom.jpg',
|
|
36
|
+
* pz: 'front.jpg',
|
|
37
|
+
* nz: 'back.jpg'
|
|
38
|
+
* },
|
|
39
|
+
* onReady: () => console.log('Cubemap loaded')
|
|
40
|
+
* });
|
|
41
|
+
*/
|
|
42
|
+
export declare function loadCubemapTexture({ gl, faces, onReady, forceRefresh }: LoadCubemapTextureOptions): void;
|
|
43
|
+
export {};
|