@maptiler/sdk 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/biome.json +2 -1
- package/dist/maptiler-sdk.css +0 -1
- package/dist/maptiler-sdk.d.ts +1 -1785
- package/dist/maptiler-sdk.mjs +1782 -2617
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/src/MLAdapters/AttributionControl.d.ts +6 -0
- package/dist/src/MLAdapters/BoxZoomHandler.d.ts +8 -0
- package/dist/src/MLAdapters/CanvasSource.d.ts +6 -0
- package/dist/src/MLAdapters/CooperativeGesturesHandler.d.ts +6 -0
- package/dist/src/MLAdapters/FullscreenControl.d.ts +6 -0
- package/dist/src/MLAdapters/GeoJSONSource.d.ts +6 -0
- package/dist/src/MLAdapters/GeolocateControl.d.ts +6 -0
- package/dist/src/MLAdapters/ImageSource.d.ts +6 -0
- package/dist/src/MLAdapters/KeyboardHandler.d.ts +6 -0
- package/dist/src/MLAdapters/LogoControl.d.ts +6 -0
- package/dist/src/MLAdapters/MapMouseEvent.d.ts +6 -0
- package/dist/src/MLAdapters/MapTouchEvent.d.ts +6 -0
- package/dist/src/MLAdapters/MapWheelEvent.d.ts +6 -0
- package/dist/src/MLAdapters/Marker.d.ts +6 -0
- package/dist/src/MLAdapters/NavigationControl.d.ts +6 -0
- package/dist/src/MLAdapters/Popup.d.ts +6 -0
- package/dist/src/MLAdapters/RasterDEMTileSource.d.ts +6 -0
- package/dist/src/MLAdapters/RasterTileSource.d.ts +6 -0
- package/dist/src/MLAdapters/ScaleControl.d.ts +6 -0
- package/dist/src/MLAdapters/ScrollZoomHandler.d.ts +6 -0
- package/dist/src/MLAdapters/Style.d.ts +6 -0
- package/dist/src/MLAdapters/TerrainControl.d.ts +6 -0
- package/dist/src/MLAdapters/TwoFingersTouchPitchHandler.d.ts +6 -0
- package/dist/src/MLAdapters/VectorTileSource.d.ts +6 -0
- package/dist/src/MLAdapters/VideoSource.d.ts +6 -0
- package/dist/src/Map.d.ts +349 -0
- package/dist/src/MaptilerGeolocateControl.d.ts +21 -0
- package/dist/src/MaptilerLogoControl.d.ts +20 -0
- package/dist/src/MaptilerNavigationControl.d.ts +18 -0
- package/dist/src/MaptilerTerrainControl.d.ts +17 -0
- package/dist/src/Minimap.d.ts +58 -0
- package/dist/src/Point.d.ts +177 -0
- package/dist/src/caching.d.ts +5 -0
- package/dist/src/colorramp.d.ts +359 -0
- package/dist/src/config.d.ts +68 -0
- package/dist/src/converters/index.d.ts +1 -0
- package/dist/src/converters/xml.d.ts +54 -0
- package/dist/src/defaults.d.ts +14 -0
- package/dist/src/helpers/index.d.ts +14 -0
- package/dist/src/helpers/screenshot.d.ts +19 -0
- package/dist/src/helpers/stylehelper.d.ts +29 -0
- package/dist/src/helpers/vectorlayerhelpers.d.ts +509 -0
- package/dist/src/index.d.ts +89 -0
- package/dist/src/language.d.ts +108 -0
- package/dist/src/mapstyle.d.ts +3 -0
- package/dist/src/tools.d.ts +46 -0
- package/dist/src/unit.d.ts +1 -0
- package/package.json +15 -21
- package/readme.md +31 -0
- package/tsconfig.json +21 -8
- package/vite.config-es.ts +48 -0
- package/vite.config-umd.ts +27 -0
- package/.github/pull_request_template.md +0 -11
- package/.github/workflows/format-lint.yml +0 -21
- package/.github/workflows/npm-publish.yml +0 -22
- package/dist/maptiler-sdk.min.mjs +0 -3
- package/rollup.config.js +0 -147
|
@@ -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,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Some default settings for the SDK
|
|
3
|
+
*/
|
|
4
|
+
declare const defaults: {
|
|
5
|
+
maptilerLogoURL: string;
|
|
6
|
+
maptilerURL: string;
|
|
7
|
+
maptilerApiHost: string;
|
|
8
|
+
rtlPluginURL: string;
|
|
9
|
+
primaryLanguage: import('@maptiler/client').LanguageInfo;
|
|
10
|
+
secondaryLanguage: import('@maptiler/client').LanguageInfo;
|
|
11
|
+
terrainSourceURL: string;
|
|
12
|
+
terrainSourceId: string;
|
|
13
|
+
};
|
|
14
|
+
export { defaults };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { takeScreenshot } from './screenshot';
|
|
2
|
+
import { addPolyline, addPolygon, addPoint, addHeatmap } from './vectorlayerhelpers';
|
|
3
|
+
|
|
4
|
+
export type { ZoomStringValues, ZoomNumberValues, PropertyValues, CommonShapeLayerOptions, PolylineLayerOptions, PolygonLayerOptions, PointLayerOptions, HeatmapLayerOptions, } from './vectorlayerhelpers';
|
|
5
|
+
/**
|
|
6
|
+
* Helpers are a set of functions to facilitate the creation of sources and layers
|
|
7
|
+
*/
|
|
8
|
+
export declare const helpers: {
|
|
9
|
+
addPolyline: typeof addPolyline;
|
|
10
|
+
addPolygon: typeof addPolygon;
|
|
11
|
+
addPoint: typeof addPoint;
|
|
12
|
+
addHeatmap: typeof addHeatmap;
|
|
13
|
+
takeScreenshot: typeof takeScreenshot;
|
|
14
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Map as MapSDK } from '../Map';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Takes a screenshot (PNG file) of the curent map view.
|
|
5
|
+
* Depending on the options, this function can automatically trigger a download of te file.
|
|
6
|
+
*/
|
|
7
|
+
export declare function takeScreenshot(map: MapSDK, options?: {
|
|
8
|
+
/**
|
|
9
|
+
* If `true`, this function will trigger a download in addition to returning a blob.
|
|
10
|
+
* Default: `false`
|
|
11
|
+
*/
|
|
12
|
+
download?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Only if `options.download` is `true`. Indicates the filename under which
|
|
15
|
+
* the file will be downloaded.
|
|
16
|
+
* Default: `"maptiler_screenshot.png"`
|
|
17
|
+
*/
|
|
18
|
+
filename?: string;
|
|
19
|
+
}): Promise<Blob>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DataDrivenPropertyValueSpecification, ExpressionSpecification } from 'maplibre-gl';
|
|
2
|
+
import { ColorRamp } from '../colorramp';
|
|
3
|
+
import { DataDrivenStyle, PropertyValues, ZoomNumberValues, ZoomStringValues } from './vectorlayerhelpers';
|
|
4
|
+
|
|
5
|
+
export type ColorPalette = [string, string, string, string];
|
|
6
|
+
export declare const colorPalettes: Array<ColorPalette>;
|
|
7
|
+
export declare function getRandomColor(): string;
|
|
8
|
+
export declare function generateRandomSourceName(): string;
|
|
9
|
+
export declare function generateRandomLayerName(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Linera interpolation to find a value at an arbitrary zoom level, given a list of tuple zoom-value
|
|
12
|
+
*/
|
|
13
|
+
export declare function lerpZoomNumberValues(znv: ZoomNumberValues, z: number): number;
|
|
14
|
+
export declare function paintColorOptionsToPaintSpec(color: ZoomStringValues): DataDrivenPropertyValueSpecification<string>;
|
|
15
|
+
export declare function rampedOptionsToLayerPaintSpec(ramp: ZoomNumberValues): DataDrivenPropertyValueSpecification<number>;
|
|
16
|
+
export declare function computeRampedOutlineWidth(lineWidth: number | ZoomNumberValues, outlineWidth: number | ZoomNumberValues): number | DataDrivenPropertyValueSpecification<number>;
|
|
17
|
+
export declare function rampedPropertyValueWeight(ramp: PropertyValues, property: string): DataDrivenPropertyValueSpecification<number>;
|
|
18
|
+
/**
|
|
19
|
+
* Create a dash array from a string pattern that uses underscore and whitespace characters
|
|
20
|
+
*/
|
|
21
|
+
export declare function dashArrayMaker(pattern: string): Array<number>;
|
|
22
|
+
export declare function colorDrivenByProperty(style: DataDrivenStyle, property: string): DataDrivenPropertyValueSpecification<string>;
|
|
23
|
+
export declare function radiusDrivenByProperty(style: DataDrivenStyle, property: string, zoomCompensation?: boolean): DataDrivenPropertyValueSpecification<number>;
|
|
24
|
+
export declare function radiusDrivenByPropertyHeatmap(style: PropertyValues, property: string, zoomCompensation?: boolean): DataDrivenPropertyValueSpecification<number>;
|
|
25
|
+
/**
|
|
26
|
+
* Turns a ColorRamp instance into a MapLibre style for ramping the opacity, driven by a property
|
|
27
|
+
*/
|
|
28
|
+
export declare function opacityDrivenByProperty(colorramp: ColorRamp, property: string): DataDrivenPropertyValueSpecification<number>;
|
|
29
|
+
export declare function heatmapIntensityFromColorRamp(colorRamp: ColorRamp, steps?: number): ExpressionSpecification;
|
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
import { FeatureCollection } from 'geojson';
|
|
2
|
+
import { Map as SDKMap } from '../Map';
|
|
3
|
+
import { ColorRamp } from '../colorramp';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Array of string values that depend on zoom level
|
|
7
|
+
*/
|
|
8
|
+
export type ZoomStringValues = Array<{
|
|
9
|
+
/**
|
|
10
|
+
* Zoom level
|
|
11
|
+
*/
|
|
12
|
+
zoom: number;
|
|
13
|
+
/**
|
|
14
|
+
* Value for the given zoom level
|
|
15
|
+
*/
|
|
16
|
+
value: string;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* Array of number values that depend on zoom level
|
|
21
|
+
*/
|
|
22
|
+
export type ZoomNumberValues = Array<{
|
|
23
|
+
/**
|
|
24
|
+
* Zoom level
|
|
25
|
+
*/
|
|
26
|
+
zoom: number;
|
|
27
|
+
/**
|
|
28
|
+
* Value for the given zoom level
|
|
29
|
+
*/
|
|
30
|
+
value: number;
|
|
31
|
+
}>;
|
|
32
|
+
export type PropertyValues = Array<{
|
|
33
|
+
/**
|
|
34
|
+
* Value of the property (input)
|
|
35
|
+
*/
|
|
36
|
+
propertyValue: number;
|
|
37
|
+
/**
|
|
38
|
+
* Value to associate it with (output)
|
|
39
|
+
*/
|
|
40
|
+
value: number;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Describes how to render a cluster of points
|
|
44
|
+
*/
|
|
45
|
+
export type DataDrivenStyle = Array<{
|
|
46
|
+
/**
|
|
47
|
+
* Numerical value to observe and apply the style upon.
|
|
48
|
+
* In case of clusters, the value to observe is automatically the number of elements in a cluster.
|
|
49
|
+
* In other cases, it can be a provided value.
|
|
50
|
+
*/
|
|
51
|
+
value: number;
|
|
52
|
+
/**
|
|
53
|
+
* Radius of the cluster circle
|
|
54
|
+
*/
|
|
55
|
+
pointRadius: number;
|
|
56
|
+
/**
|
|
57
|
+
* Color of the cluster
|
|
58
|
+
*/
|
|
59
|
+
color: string;
|
|
60
|
+
}>;
|
|
61
|
+
export type CommonShapeLayerOptions = {
|
|
62
|
+
/**
|
|
63
|
+
* ID to give to the layer.
|
|
64
|
+
* If not provided, an auto-generated ID of the for "maptiler-layer-xxxxxx" will be auto-generated,
|
|
65
|
+
* with "xxxxxx" being a random string.
|
|
66
|
+
*/
|
|
67
|
+
layerId?: string;
|
|
68
|
+
/**
|
|
69
|
+
* ID to give to the geojson source.
|
|
70
|
+
* If not provided, an auto-generated ID of the for "maptiler-source-xxxxxx" will be auto-generated,
|
|
71
|
+
* with "xxxxxx" being a random string.
|
|
72
|
+
*/
|
|
73
|
+
sourceId?: string;
|
|
74
|
+
/**
|
|
75
|
+
* A geojson Feature collection or a URL to a geojson or the UUID of a MapTiler Cloud dataset.
|
|
76
|
+
*/
|
|
77
|
+
data: FeatureCollection | string;
|
|
78
|
+
/**
|
|
79
|
+
* The ID of an existing layer to insert the new layer before, resulting in the new layer appearing
|
|
80
|
+
* visually beneath the existing layer. If this argument is not specified, the layer will be appended
|
|
81
|
+
* to the end of the layers array and appear visually above all other layers.
|
|
82
|
+
*/
|
|
83
|
+
beforeId?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Zoom level at which it starts to show.
|
|
86
|
+
* Default: `0`
|
|
87
|
+
*/
|
|
88
|
+
minzoom?: number;
|
|
89
|
+
/**
|
|
90
|
+
* Zoom level after which it no longer show.
|
|
91
|
+
* Default: `22`
|
|
92
|
+
*/
|
|
93
|
+
maxzoom?: number;
|
|
94
|
+
/**
|
|
95
|
+
* Whether or not to add an outline.
|
|
96
|
+
* Default: `false`
|
|
97
|
+
*/
|
|
98
|
+
outline?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Color of the outline. This is can be a constant color string or a definition based on zoom levels.
|
|
101
|
+
* Applies only if `.outline` is `true`.
|
|
102
|
+
* Default: `white`
|
|
103
|
+
*/
|
|
104
|
+
outlineColor?: string | ZoomStringValues;
|
|
105
|
+
/**
|
|
106
|
+
* Width of the outline (relative to screen-space). This is can be a constant width or a definition based on zoom levels.
|
|
107
|
+
* Applies only if `.outline` is `true`.
|
|
108
|
+
* Default: `1`
|
|
109
|
+
*/
|
|
110
|
+
outlineWidth?: number | ZoomNumberValues;
|
|
111
|
+
/**
|
|
112
|
+
* Opacity of the outline. This is can be a constant opacity in [0, 1] or a definition based on zoom levels
|
|
113
|
+
* Applies only if `.outline` is `true`.
|
|
114
|
+
* Default: `1`
|
|
115
|
+
*/
|
|
116
|
+
outlineOpacity?: number | ZoomNumberValues;
|
|
117
|
+
};
|
|
118
|
+
export type PolylineLayerOptions = CommonShapeLayerOptions & {
|
|
119
|
+
/**
|
|
120
|
+
* Color of the line (or polyline). This is can be a constant color string or a definition based on zoom levels.
|
|
121
|
+
* Default: a color randomly pick from a list
|
|
122
|
+
*/
|
|
123
|
+
lineColor?: string | ZoomStringValues;
|
|
124
|
+
/**
|
|
125
|
+
* Width of the line (relative to screen-space). This is can be a constant width or a definition based on zoom levels
|
|
126
|
+
* Default: `3`
|
|
127
|
+
*/
|
|
128
|
+
lineWidth?: number | ZoomNumberValues;
|
|
129
|
+
/**
|
|
130
|
+
* Opacity of the line. This is can be a constant opacity in [0, 1] or a definition based on zoom levels.
|
|
131
|
+
* Default: `1`
|
|
132
|
+
*/
|
|
133
|
+
lineOpacity?: number | ZoomNumberValues;
|
|
134
|
+
/**
|
|
135
|
+
* How blury the line is, with `0` being no blur and `10` and beyond being quite blurry.
|
|
136
|
+
* Default: `0`
|
|
137
|
+
*/
|
|
138
|
+
lineBlur?: number | ZoomNumberValues;
|
|
139
|
+
/**
|
|
140
|
+
* Draws a line casing outside of a line's actual path. Value indicates the width of the inner gap.
|
|
141
|
+
* Default: `0`
|
|
142
|
+
*/
|
|
143
|
+
lineGapWidth?: number | ZoomNumberValues;
|
|
144
|
+
/**
|
|
145
|
+
* Sequence of line and void to create a dash pattern. The unit is the line width so that
|
|
146
|
+
* a dash array value of `[3, 1]` will create a segment worth 3 times the width of the line,
|
|
147
|
+
* followed by a spacing worth 1 time the line width, and then repeat.
|
|
148
|
+
*
|
|
149
|
+
* Alternatively, this property can be a string made of underscore and whitespace characters
|
|
150
|
+
* such as `"___ _ "` and internaly this will be translated into [3, 1, 1, 1]. Note that
|
|
151
|
+
* this way of describing dash arrays with a string only works for integer values.
|
|
152
|
+
*
|
|
153
|
+
* Dash arrays can contain more than 2 element to create more complex patters. For instance
|
|
154
|
+
* a dash array value of [3, 2, 1, 2] will create the following sequence:
|
|
155
|
+
* - a segment worth 3 times the width
|
|
156
|
+
* - a spacing worth 2 times the width
|
|
157
|
+
* - a segment worth 1 times the width
|
|
158
|
+
* - a spacing worth 2 times the width
|
|
159
|
+
* - repeat
|
|
160
|
+
*
|
|
161
|
+
* Default: no dash pattern
|
|
162
|
+
*/
|
|
163
|
+
lineDashArray?: Array<number> | string;
|
|
164
|
+
/**
|
|
165
|
+
* The display of line endings for both the line and the outline (if `.outline` is `true`)
|
|
166
|
+
* - "butt": A cap with a squared-off end which is drawn to the exact endpoint of the line.
|
|
167
|
+
* - "round": A cap with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's width and centered on the endpoint of the line.
|
|
168
|
+
* - "square": A cap with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line's width.
|
|
169
|
+
* Default: "round"
|
|
170
|
+
*/
|
|
171
|
+
lineCap?: "butt" | "round" | "square";
|
|
172
|
+
/**
|
|
173
|
+
* The display of lines when joining for both the line and the outline (if `.outline` is `true`)
|
|
174
|
+
* - "bevel": A join with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line's width.
|
|
175
|
+
* - "round": A join with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's width and centered on the endpoint of the line.
|
|
176
|
+
* - "miter": A join with a sharp, angled corner which is drawn with the outer sides beyond the endpoint of the path until they meet.
|
|
177
|
+
* Default: "round"
|
|
178
|
+
*/
|
|
179
|
+
lineJoin?: "bevel" | "round" | "miter";
|
|
180
|
+
/**
|
|
181
|
+
* How blury the outline is, with `0` being no blur and `10` and beyond being quite blurry.
|
|
182
|
+
* Applies only if `.outline` is `true`.
|
|
183
|
+
* Default: `0`
|
|
184
|
+
*/
|
|
185
|
+
outlineBlur?: number | ZoomNumberValues;
|
|
186
|
+
};
|
|
187
|
+
export type PolygonLayerOptions = CommonShapeLayerOptions & {
|
|
188
|
+
/**
|
|
189
|
+
* Color of the polygon. This is can be a constant color string or a definition based on zoom levels.
|
|
190
|
+
* Default: a color randomly pick from a list
|
|
191
|
+
*/
|
|
192
|
+
fillColor?: string | ZoomStringValues;
|
|
193
|
+
/**
|
|
194
|
+
* Opacity of the polygon. This is can be a constant opacity in [0, 1] or a definition based on zoom levels
|
|
195
|
+
* Default: `1`
|
|
196
|
+
*/
|
|
197
|
+
fillOpacity?: ZoomNumberValues;
|
|
198
|
+
/**
|
|
199
|
+
* Position of the outline with regard to the polygon edge (when `.outline` is `true`)
|
|
200
|
+
* Default: `"center"`
|
|
201
|
+
*/
|
|
202
|
+
outlinePosition: "center" | "inside" | "outside";
|
|
203
|
+
/**
|
|
204
|
+
* Sequence of line and void to create a dash pattern. The unit is the line width so that
|
|
205
|
+
* a dash array value of `[3, 1]` will create a segment worth 3 times the width of the line,
|
|
206
|
+
* followed by a spacing worth 1 time the line width, and then repeat.
|
|
207
|
+
*
|
|
208
|
+
* Alternatively, this property can be a string made of underscore and whitespace characters
|
|
209
|
+
* such as `"___ _ "` and internaly this will be translated into [3, 1, 1, 1]. Note that
|
|
210
|
+
* this way of describing dash arrays with a string only works for integer values.
|
|
211
|
+
*
|
|
212
|
+
* Dash arrays can contain more than 2 element to create more complex patters. For instance
|
|
213
|
+
* a dash array value of [3, 2, 1, 2] will create the following sequence:
|
|
214
|
+
* - a segment worth 3 times the width
|
|
215
|
+
* - a spacing worth 2 times the width
|
|
216
|
+
* - a segment worth 1 times the width
|
|
217
|
+
* - a spacing worth 2 times the width
|
|
218
|
+
* - repeat
|
|
219
|
+
*
|
|
220
|
+
* Default: no dash pattern
|
|
221
|
+
*/
|
|
222
|
+
outlineDashArray?: Array<number> | string;
|
|
223
|
+
/**
|
|
224
|
+
* The display of line endings for both the line and the outline (if `.outline` is `true`)
|
|
225
|
+
* - "butt": A cap with a squared-off end which is drawn to the exact endpoint of the line.
|
|
226
|
+
* - "round": A cap with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's width and centered on the endpoint of the line.
|
|
227
|
+
* - "square": A cap with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line's width.
|
|
228
|
+
* Default: "round"
|
|
229
|
+
*/
|
|
230
|
+
outlineCap?: "butt" | "round" | "square";
|
|
231
|
+
/**
|
|
232
|
+
* The display of lines when joining for both the line and the outline (if `.outline` is `true`)
|
|
233
|
+
* - "bevel": A join with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line's width.
|
|
234
|
+
* - "round": A join with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's width and centered on the endpoint of the line.
|
|
235
|
+
* - "miter": A join with a sharp, angled corner which is drawn with the outer sides beyond the endpoint of the path until they meet.
|
|
236
|
+
* Default: "round"
|
|
237
|
+
*/
|
|
238
|
+
outlineJoin?: "bevel" | "round" | "miter";
|
|
239
|
+
/**
|
|
240
|
+
* The pattern is an image URL to be put as a repeated background pattern of the polygon.
|
|
241
|
+
* Default: `null` (no pattern, `fillColor` will be used)
|
|
242
|
+
*/
|
|
243
|
+
pattern?: string | null;
|
|
244
|
+
/**
|
|
245
|
+
* How blury the outline is, with `0` being no blur and `10` and beyond being quite blurry.
|
|
246
|
+
* Applies only if `.outline` is `true`.
|
|
247
|
+
* Default: `0`
|
|
248
|
+
*/
|
|
249
|
+
outlineBlur?: number | ZoomNumberValues;
|
|
250
|
+
};
|
|
251
|
+
export type PointLayerOptions = CommonShapeLayerOptions & {
|
|
252
|
+
/**
|
|
253
|
+
* Can be a unique point color as a string (CSS color such as "#FF0000" or "red").
|
|
254
|
+
* Alternatively, the color can be a ColorRamp with a range.
|
|
255
|
+
* In case of `.cluster` being `true`, the range of the ColorRamp will be addressed with the number of elements in
|
|
256
|
+
* the cluster. If `.cluster` is `false`, the color will be addressed using the value of the `.property`.
|
|
257
|
+
* If no `.property` is given but `.pointColor` is a ColorRamp, the chosen color is the one at the lower bound of the ColorRamp.
|
|
258
|
+
* Default: a color randomly pick from a list
|
|
259
|
+
*/
|
|
260
|
+
pointColor?: string | ColorRamp;
|
|
261
|
+
/**
|
|
262
|
+
* Radius of the points. Can be a fixed size or a value dependant on the zoom.
|
|
263
|
+
* If `.pointRadius` is not provided, the radius will depend on the size of each cluster (if `.cluster` is `true`)
|
|
264
|
+
* or on the value of each point (if `.property` is provided and `.pointColor` is a ColorRamp).
|
|
265
|
+
* The radius will be between `.minPointRadius` and `.maxPointRadius`
|
|
266
|
+
*/
|
|
267
|
+
pointRadius?: number | ZoomNumberValues;
|
|
268
|
+
/**
|
|
269
|
+
* The minimum point radius posible.
|
|
270
|
+
* Default: `10`
|
|
271
|
+
*/
|
|
272
|
+
minPointRadius?: number;
|
|
273
|
+
/**
|
|
274
|
+
* The maximum point radius posible.
|
|
275
|
+
* Default: `40`
|
|
276
|
+
*/
|
|
277
|
+
maxPointRadius?: number;
|
|
278
|
+
/**
|
|
279
|
+
* The point property to observe and apply the radius and color upon.
|
|
280
|
+
* This is ignored if `.cluster` is `true` as the observed value will be fiorced to being the number
|
|
281
|
+
* of elements in each cluster.
|
|
282
|
+
*
|
|
283
|
+
* Default: none
|
|
284
|
+
*/
|
|
285
|
+
property?: string;
|
|
286
|
+
/**
|
|
287
|
+
* Opacity of the point or icon. This is can be a constant opacity in [0, 1] or a definition based on zoom levels.
|
|
288
|
+
* Alternatively, if not provided but the `.pointColor` is a ColorRamp, the opacity will be extracted from tha alpha
|
|
289
|
+
* component if present.
|
|
290
|
+
* Default: `1`
|
|
291
|
+
*/
|
|
292
|
+
pointOpacity?: number | ZoomNumberValues;
|
|
293
|
+
/**
|
|
294
|
+
* If `true`, the points will keep their circular shape align with the wiewport.
|
|
295
|
+
* If `false`, the points will be like flatten on the map. This difference shows
|
|
296
|
+
* when the map is tilted.
|
|
297
|
+
* Default: `true`
|
|
298
|
+
*/
|
|
299
|
+
alignOnViewport?: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Whether the points should cluster
|
|
302
|
+
*/
|
|
303
|
+
cluster?: boolean;
|
|
304
|
+
/**
|
|
305
|
+
* Shows a label with the numerical value id `true`.
|
|
306
|
+
* If `.cluster` is `true`, the value will be the numebr of elements in the cluster.
|
|
307
|
+
*
|
|
308
|
+
*
|
|
309
|
+
* Default: `true` if `cluster` or `dataDrivenStyleProperty` are used, `false` otherwise.
|
|
310
|
+
*/
|
|
311
|
+
showLabel?: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* text color used for the number elements in each cluster.
|
|
314
|
+
* Applicable only when `cluster` is `true`.
|
|
315
|
+
* Default: `#000000` (black)
|
|
316
|
+
*/
|
|
317
|
+
labelColor?: string;
|
|
318
|
+
/**
|
|
319
|
+
* text size used for the number elements in each cluster.
|
|
320
|
+
* Applicable only when `cluster` is `true`.
|
|
321
|
+
* Default: `12`
|
|
322
|
+
*/
|
|
323
|
+
labelSize?: number;
|
|
324
|
+
/**
|
|
325
|
+
* Only if `.cluster` is `false`.
|
|
326
|
+
* If the radius is driven by a property, then it will also scale by zoomming if `.zoomCompensation` is `true`.
|
|
327
|
+
* If `false`, the radius will not adapt according to the zoom level.
|
|
328
|
+
* Default: `true`
|
|
329
|
+
*/
|
|
330
|
+
zoomCompensation?: boolean;
|
|
331
|
+
};
|
|
332
|
+
export type HeatmapLayerOptions = {
|
|
333
|
+
/**
|
|
334
|
+
* ID to give to the layer.
|
|
335
|
+
* If not provided, an auto-generated ID of the for "maptiler-layer-xxxxxx" will be auto-generated,
|
|
336
|
+
* with "xxxxxx" being a random string.
|
|
337
|
+
*/
|
|
338
|
+
layerId?: string;
|
|
339
|
+
/**
|
|
340
|
+
* ID to give to the geojson source.
|
|
341
|
+
* If not provided, an auto-generated ID of the for "maptiler-source-xxxxxx" will be auto-generated,
|
|
342
|
+
* with "xxxxxx" being a random string.
|
|
343
|
+
*/
|
|
344
|
+
sourceId?: string;
|
|
345
|
+
/**
|
|
346
|
+
* A geojson Feature collection or a URL to a geojson or the UUID of a MapTiler Cloud dataset.
|
|
347
|
+
*/
|
|
348
|
+
data: FeatureCollection | string;
|
|
349
|
+
/**
|
|
350
|
+
* The ID of an existing layer to insert the new layer before, resulting in the new layer appearing
|
|
351
|
+
* visually beneath the existing layer. If this argument is not specified, the layer will be appended
|
|
352
|
+
* to the end of the layers array and appear visually above all other layers.
|
|
353
|
+
*/
|
|
354
|
+
beforeId?: string;
|
|
355
|
+
/**
|
|
356
|
+
* Zoom level at which it starts to show.
|
|
357
|
+
* Default: `0`
|
|
358
|
+
*/
|
|
359
|
+
minzoom?: number;
|
|
360
|
+
/**
|
|
361
|
+
* Zoom level after which it no longer show.
|
|
362
|
+
* Default: `22`
|
|
363
|
+
*/
|
|
364
|
+
maxzoom?: number;
|
|
365
|
+
/**
|
|
366
|
+
* The ColorRamp instance to use for visualization. The color ramp is expected to be defined in the
|
|
367
|
+
* range `[0, 1]` or else will be forced to this range.
|
|
368
|
+
* Default: `ColorRampCollection.TURBO`
|
|
369
|
+
*/
|
|
370
|
+
colorRamp?: ColorRamp;
|
|
371
|
+
/**
|
|
372
|
+
* Use a property to apply a weight to each data point. Using a property requires also using
|
|
373
|
+
* the options `.propertyValueWeight` or otherwise will be ignored.
|
|
374
|
+
* Default: none, the points will all have a weight of `1`.
|
|
375
|
+
*/
|
|
376
|
+
property?: string;
|
|
377
|
+
/**
|
|
378
|
+
* The weight to give to each data point. If of type `PropertyValueWeights`, then the options `.property`
|
|
379
|
+
* must also be provided. If used a number, all data points will be weighted by the same number (which is of little interest)
|
|
380
|
+
*/
|
|
381
|
+
weight?: PropertyValues | number;
|
|
382
|
+
/**
|
|
383
|
+
* The radius (in screenspace) can be:
|
|
384
|
+
* - a fixed number that will be constant across zoom level
|
|
385
|
+
* - of type `ZoomNumberValues` to be ramped accoding to zoom level (`.zoomCompensation` will then be ignored)
|
|
386
|
+
* - of type `PropertyValues` to be driven by the value of a property.
|
|
387
|
+
* If so, the option `.property` must be provided and will still be resized according to zoom level,
|
|
388
|
+
* unless the option `.zoomCompensation` is set to `false`.
|
|
389
|
+
*
|
|
390
|
+
* Default:
|
|
391
|
+
*/
|
|
392
|
+
radius?: number | ZoomNumberValues | PropertyValues;
|
|
393
|
+
/**
|
|
394
|
+
* The opacity can be a fixed value or zoom-driven.
|
|
395
|
+
* Default: fades-in 0.25z after minzoom and fade-out 0.25z before maxzoom
|
|
396
|
+
*/
|
|
397
|
+
opacity?: number | ZoomNumberValues;
|
|
398
|
+
/**
|
|
399
|
+
* The intensity is zoom-dependent. By default, the intensity is going to be scaled by zoom to preserve
|
|
400
|
+
* a natural aspect or the data distribution.
|
|
401
|
+
*/
|
|
402
|
+
intensity?: number | ZoomNumberValues;
|
|
403
|
+
/**
|
|
404
|
+
* If the radius is driven by a property, then it will also scale by zoomming if `.zoomCompensation` is `true`.
|
|
405
|
+
* If `false`, the radius will not adapt according to the zoom level.
|
|
406
|
+
* Default: `true`
|
|
407
|
+
*/
|
|
408
|
+
zoomCompensation?: boolean;
|
|
409
|
+
};
|
|
410
|
+
/**
|
|
411
|
+
* Add a polyline to the map from various sources and with builtin styling.
|
|
412
|
+
* Compatible sources:
|
|
413
|
+
* - gpx content as string
|
|
414
|
+
* - gpx file from URL
|
|
415
|
+
* - kml content from string
|
|
416
|
+
* - kml from url
|
|
417
|
+
* - geojson from url
|
|
418
|
+
* - geojson content as string
|
|
419
|
+
* - geojson content as JS object
|
|
420
|
+
* - uuid of a MapTiler Cloud dataset
|
|
421
|
+
*
|
|
422
|
+
* The method also gives the possibility to add an outline layer (if `options.outline` is `true`)
|
|
423
|
+
* and if so , the returned property `polylineOutlineLayerId` will be a string. As a result, two layers
|
|
424
|
+
* would be added.
|
|
425
|
+
*
|
|
426
|
+
* The default styling creates a line layer of constant width of 3px, the color will be randomly picked
|
|
427
|
+
* from a curated list of colors and the opacity will be 1.
|
|
428
|
+
* If the outline is enabled, the outline width is of 1px at all zoom levels, the color is white and
|
|
429
|
+
* the opacity is 1.
|
|
430
|
+
*
|
|
431
|
+
* Those style properties can be changed and ramped according to zoom level using an easier syntax.
|
|
432
|
+
*
|
|
433
|
+
*/
|
|
434
|
+
export declare function addPolyline(
|
|
435
|
+
/**
|
|
436
|
+
* Map instance to add a polyline layer to
|
|
437
|
+
*/
|
|
438
|
+
map: SDKMap,
|
|
439
|
+
/**
|
|
440
|
+
* Options related to adding a polyline layer
|
|
441
|
+
*/
|
|
442
|
+
options: PolylineLayerOptions,
|
|
443
|
+
/**
|
|
444
|
+
* When the polyline data is loaded from a distant source, these options are propagated to the call of `fetch`
|
|
445
|
+
*/
|
|
446
|
+
fetchOptions?: RequestInit): Promise<{
|
|
447
|
+
polylineLayerId: string;
|
|
448
|
+
polylineOutlineLayerId: string;
|
|
449
|
+
polylineSourceId: string;
|
|
450
|
+
}>;
|
|
451
|
+
/**
|
|
452
|
+
* Add a polygon with styling options.
|
|
453
|
+
*/
|
|
454
|
+
export declare function addPolygon(map: SDKMap, options: PolygonLayerOptions): {
|
|
455
|
+
/**
|
|
456
|
+
* ID of the fill layer
|
|
457
|
+
*/
|
|
458
|
+
polygonLayerId: string;
|
|
459
|
+
/**
|
|
460
|
+
* ID of the outline layer (will be `""` if no outline)
|
|
461
|
+
*/
|
|
462
|
+
polygonOutlineLayerId: string;
|
|
463
|
+
/**
|
|
464
|
+
* ID of the source that contains the data
|
|
465
|
+
*/
|
|
466
|
+
polygonSourceId: string;
|
|
467
|
+
};
|
|
468
|
+
/**
|
|
469
|
+
* Add a point layer from a GeoJSON source (or an existing sourceId) with many styling options
|
|
470
|
+
*/
|
|
471
|
+
export declare function addPoint(
|
|
472
|
+
/**
|
|
473
|
+
* The Map instance to add a point layer to
|
|
474
|
+
*/
|
|
475
|
+
map: SDKMap, options: PointLayerOptions): {
|
|
476
|
+
/**
|
|
477
|
+
* ID of the unclustered point layer
|
|
478
|
+
*/
|
|
479
|
+
pointLayerId: string;
|
|
480
|
+
/**
|
|
481
|
+
* ID of the clustered point layer (empty if `cluster` options id `false`)
|
|
482
|
+
*/
|
|
483
|
+
clusterLayerId: string;
|
|
484
|
+
/**
|
|
485
|
+
* ID of the layer that shows the count of elements in each cluster (empty if `cluster` options id `false`)
|
|
486
|
+
*/
|
|
487
|
+
labelLayerId: string;
|
|
488
|
+
/**
|
|
489
|
+
* ID of the data source
|
|
490
|
+
*/
|
|
491
|
+
pointSourceId: string;
|
|
492
|
+
};
|
|
493
|
+
/**
|
|
494
|
+
* Add a polyline witgh optional outline from a GeoJSON object
|
|
495
|
+
*/
|
|
496
|
+
export declare function addHeatmap(
|
|
497
|
+
/**
|
|
498
|
+
* Map instance to add a heatmap layer to
|
|
499
|
+
*/
|
|
500
|
+
map: SDKMap, options: HeatmapLayerOptions): {
|
|
501
|
+
/**
|
|
502
|
+
* ID of the heatmap layer
|
|
503
|
+
*/
|
|
504
|
+
heatmapLayerId: string;
|
|
505
|
+
/**
|
|
506
|
+
* ID of the data source
|
|
507
|
+
*/
|
|
508
|
+
heatmapSourceId: string;
|
|
509
|
+
};
|