@maptiler/sdk 3.2.1 → 3.2.2

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 (59) hide show
  1. package/dist/maptiler-sdk.d.ts +2 -0
  2. package/dist/maptiler-sdk.mjs +10797 -0
  3. package/dist/maptiler-sdk.mjs.map +1 -0
  4. package/dist/src/ColorRamp.d.ts +359 -0
  5. package/dist/src/MLAdapters/AttributionControl.d.ts +5 -0
  6. package/dist/src/MLAdapters/BoxZoomHandler.d.ts +7 -0
  7. package/dist/src/MLAdapters/CanvasSource.d.ts +5 -0
  8. package/dist/src/MLAdapters/CooperativeGesturesHandler.d.ts +5 -0
  9. package/dist/src/MLAdapters/FullscreenControl.d.ts +5 -0
  10. package/dist/src/MLAdapters/GeoJSONSource.d.ts +5 -0
  11. package/dist/src/MLAdapters/GeolocateControl.d.ts +5 -0
  12. package/dist/src/MLAdapters/ImageSource.d.ts +5 -0
  13. package/dist/src/MLAdapters/KeyboardHandler.d.ts +5 -0
  14. package/dist/src/MLAdapters/LogoControl.d.ts +5 -0
  15. package/dist/src/MLAdapters/MapMouseEvent.d.ts +5 -0
  16. package/dist/src/MLAdapters/MapTouchEvent.d.ts +5 -0
  17. package/dist/src/MLAdapters/MapWheelEvent.d.ts +5 -0
  18. package/dist/src/MLAdapters/Marker.d.ts +5 -0
  19. package/dist/src/MLAdapters/NavigationControl.d.ts +5 -0
  20. package/dist/src/MLAdapters/Popup.d.ts +5 -0
  21. package/dist/src/MLAdapters/RasterDEMTileSource.d.ts +5 -0
  22. package/dist/src/MLAdapters/RasterTileSource.d.ts +5 -0
  23. package/dist/src/MLAdapters/ScaleControl.d.ts +5 -0
  24. package/dist/src/MLAdapters/ScrollZoomHandler.d.ts +5 -0
  25. package/dist/src/MLAdapters/Style.d.ts +5 -0
  26. package/dist/src/MLAdapters/TerrainControl.d.ts +5 -0
  27. package/dist/src/MLAdapters/TwoFingersTouchPitchHandler.d.ts +5 -0
  28. package/dist/src/MLAdapters/VectorTileSource.d.ts +5 -0
  29. package/dist/src/MLAdapters/VideoSource.d.ts +5 -0
  30. package/dist/src/Map.d.ts +403 -0
  31. package/dist/src/Point.d.ts +177 -0
  32. package/dist/src/Telemetry.d.ts +21 -0
  33. package/dist/src/caching.d.ts +4 -0
  34. package/dist/src/config.d.ts +85 -0
  35. package/dist/src/constants/defaults.d.ts +15 -0
  36. package/dist/src/controls/MaptilerGeolocateControl.d.ts +21 -0
  37. package/dist/src/controls/MaptilerLogoControl.d.ts +19 -0
  38. package/dist/src/controls/MaptilerNavigationControl.d.ts +17 -0
  39. package/dist/src/controls/MaptilerProjectionControl.d.ts +14 -0
  40. package/dist/src/controls/MaptilerTerrainControl.d.ts +16 -0
  41. package/dist/src/controls/Minimap.d.ts +57 -0
  42. package/dist/src/controls/index.d.ts +6 -0
  43. package/dist/src/converters/index.d.ts +1 -0
  44. package/dist/src/converters/xml.d.ts +54 -0
  45. package/dist/src/helpers/index.d.ts +3 -0
  46. package/dist/src/helpers/screenshot.d.ts +18 -0
  47. package/dist/src/helpers/stylehelper.d.ts +28 -0
  48. package/dist/src/helpers/vectorlayerhelpers.d.ts +508 -0
  49. package/dist/src/index.d.ts +87 -0
  50. package/dist/src/language.d.ts +107 -0
  51. package/dist/src/mapstyle.d.ts +17 -0
  52. package/dist/src/tools.d.ts +84 -0
  53. package/dist/src/types.d.ts +1 -0
  54. package/dist/src/utils/dom.d.ts +2 -0
  55. package/dist/src/utils/index.d.ts +1 -0
  56. package/dist/vite.config-test.d.ts +2 -0
  57. package/dist/vitest-setup-tests.d.ts +1 -0
  58. package/package.json +1 -1
  59. package/tsconfig.json +0 -1
@@ -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,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;