@maptiler/sdk 3.0.0-rc.4 → 3.0.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/dist/maptiler-sdk.css +2 -2
- package/dist/maptiler-sdk.d.ts +1 -0
- package/dist/maptiler-sdk.mjs +222 -255
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/src/MLAdapters/AttributionControl.d.ts +0 -1
- package/dist/src/MLAdapters/BoxZoomHandler.d.ts +0 -1
- package/dist/src/MLAdapters/CanvasSource.d.ts +0 -1
- package/dist/src/MLAdapters/CooperativeGesturesHandler.d.ts +0 -1
- package/dist/src/MLAdapters/FullscreenControl.d.ts +0 -1
- package/dist/src/MLAdapters/GeoJSONSource.d.ts +0 -1
- package/dist/src/MLAdapters/GeolocateControl.d.ts +0 -1
- package/dist/src/MLAdapters/ImageSource.d.ts +0 -1
- package/dist/src/MLAdapters/KeyboardHandler.d.ts +0 -1
- package/dist/src/MLAdapters/LogoControl.d.ts +0 -1
- package/dist/src/MLAdapters/MapMouseEvent.d.ts +0 -1
- package/dist/src/MLAdapters/MapTouchEvent.d.ts +0 -1
- package/dist/src/MLAdapters/MapWheelEvent.d.ts +0 -1
- package/dist/src/MLAdapters/Marker.d.ts +0 -1
- package/dist/src/MLAdapters/NavigationControl.d.ts +0 -1
- package/dist/src/MLAdapters/Popup.d.ts +0 -1
- package/dist/src/MLAdapters/RasterDEMTileSource.d.ts +0 -1
- package/dist/src/MLAdapters/RasterTileSource.d.ts +0 -1
- package/dist/src/MLAdapters/ScaleControl.d.ts +0 -1
- package/dist/src/MLAdapters/ScrollZoomHandler.d.ts +0 -1
- package/dist/src/MLAdapters/Style.d.ts +0 -1
- package/dist/src/MLAdapters/TerrainControl.d.ts +0 -1
- package/dist/src/MLAdapters/TwoFingersTouchPitchHandler.d.ts +0 -1
- package/dist/src/MLAdapters/VectorTileSource.d.ts +0 -1
- package/dist/src/MLAdapters/VideoSource.d.ts +0 -1
- package/dist/src/Map.d.ts +4 -5
- package/dist/src/MaptilerGeolocateControl.d.ts +1 -1
- package/dist/src/MaptilerLogoControl.d.ts +0 -1
- package/dist/src/MaptilerNavigationControl.d.ts +0 -1
- package/dist/src/MaptilerProjectionControl.d.ts +0 -1
- package/dist/src/MaptilerTerrainControl.d.ts +0 -1
- package/dist/src/Minimap.d.ts +0 -1
- package/dist/src/Telemetry.d.ts +0 -1
- package/dist/src/caching.d.ts +0 -1
- package/dist/src/config.d.ts +0 -1
- package/dist/src/helpers/index.d.ts +0 -1
- package/dist/src/helpers/screenshot.d.ts +0 -1
- package/dist/src/helpers/stylehelper.d.ts +0 -1
- package/dist/src/helpers/vectorlayerhelpers.d.ts +0 -1
- package/dist/src/index.d.ts +1 -2
- package/dist/src/language.d.ts +0 -1
- package/dist/src/mapstyle.d.ts +0 -1
- package/dist/src/tools.d.ts +0 -1
- package/package.json +16 -16
- package/readme.md +35 -2
- package/vite.config-dev.ts +27 -0
- package/vite.config-umd.ts +4 -10
- /package/{vite.config.ts → vite.config-test.ts} +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { default as maplibregl, GestureOptions, Map as MapMLGL } from 'maplibre-gl';
|
|
2
2
|
import { Map as SDKMap } from '../Map';
|
|
3
|
-
|
|
4
3
|
export declare class CooperativeGesturesHandler extends maplibregl.CooperativeGesturesHandler {
|
|
5
4
|
constructor(map: SDKMap | MapMLGL, options: GestureOptions);
|
|
6
5
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { default as maplibregl, Map as MapMLGL } from 'maplibre-gl';
|
|
2
2
|
import { Map as SDKMap } from '../Map';
|
|
3
|
-
|
|
4
3
|
export declare class MapMouseEvent extends maplibregl.MapMouseEvent {
|
|
5
4
|
constructor(type: string, map: SDKMap | MapMLGL, originalEvent: MouseEvent, data?: any);
|
|
6
5
|
}
|
package/dist/src/Map.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { SdkConfig } from './config';
|
|
|
4
4
|
import { LanguageInfo } from './language';
|
|
5
5
|
import { MinimapOptionsInput } from './Minimap';
|
|
6
6
|
import { Telemetry } from './Telemetry';
|
|
7
|
-
|
|
8
7
|
export type LoadWithTerrainEvent = {
|
|
9
8
|
type: "loadWithTerrain";
|
|
10
9
|
target: Map;
|
|
@@ -381,13 +380,13 @@ export declare class Map extends maplibregl.Map {
|
|
|
381
380
|
*/
|
|
382
381
|
isGlobeProjection(): boolean;
|
|
383
382
|
/**
|
|
384
|
-
*
|
|
383
|
+
* Activate the globe projection.
|
|
385
384
|
*/
|
|
386
|
-
enableGlobeProjection(
|
|
385
|
+
enableGlobeProjection(): void;
|
|
387
386
|
/**
|
|
388
|
-
*
|
|
387
|
+
* Activate the mercator projection.
|
|
389
388
|
*/
|
|
390
|
-
enableMercatorProjection(
|
|
389
|
+
enableMercatorProjection(): void;
|
|
391
390
|
/**
|
|
392
391
|
* Returns `true` is the language was ever updated, meaning changed
|
|
393
392
|
* from what is delivered in the style.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { GeolocateControl } from './MLAdapters/GeolocateControl';
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* The MaptilerGeolocateControl is an extension of the original GeolocateControl
|
|
5
4
|
* with a few changes. In this version, the active mode persists as long as the
|
|
@@ -18,4 +17,5 @@ export declare class MaptilerGeolocateControl extends GeolocateControl {
|
|
|
18
17
|
_finishSetupUI: (supported: boolean) => void;
|
|
19
18
|
_updateCircleRadius(): void;
|
|
20
19
|
_onZoom: () => void;
|
|
20
|
+
_setErrorState(): void;
|
|
21
21
|
}
|
package/dist/src/Minimap.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Map as SDKMap, MapOptions } from './Map';
|
|
2
2
|
import { ControlPosition, CustomLayerInterface, FillLayerSpecification, FilterSpecification, IControl, LayerSpecification, LineLayerSpecification, SourceSpecification, StyleOptions, StyleSetterOptions, StyleSpecification, StyleSwapOptions } from 'maplibre-gl';
|
|
3
3
|
import { MapStyleVariant, ReferenceMapStyle } from '@maptiler/client';
|
|
4
|
-
|
|
5
4
|
export interface ParentRect {
|
|
6
5
|
lineLayout: LineLayerSpecification["layout"];
|
|
7
6
|
linePaint: LineLayerSpecification["paint"];
|
package/dist/src/Telemetry.d.ts
CHANGED
package/dist/src/caching.d.ts
CHANGED
package/dist/src/config.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { default as EventEmitter } from 'events';
|
|
|
2
2
|
import { LanguageInfo } from './language';
|
|
3
3
|
import { FetchFunction } from '@maptiler/client';
|
|
4
4
|
import { Unit } from './unit';
|
|
5
|
-
|
|
6
5
|
export declare const MAPTILER_SESSION_ID: string;
|
|
7
6
|
/**
|
|
8
7
|
* Configuration class for the SDK
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { takeScreenshot } from './screenshot';
|
|
2
2
|
import { addPolyline, addPolygon, addPoint, addHeatmap } from './vectorlayerhelpers';
|
|
3
|
-
|
|
4
3
|
export type { ZoomStringValues, ZoomNumberValues, PropertyValues, CommonShapeLayerOptions, PolylineLayerOptions, PolygonLayerOptions, PointLayerOptions, HeatmapLayerOptions, } from './vectorlayerhelpers';
|
|
5
4
|
/**
|
|
6
5
|
* Helpers are a set of functions to facilitate the creation of sources and layers
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DataDrivenPropertyValueSpecification, ExpressionSpecification } from 'maplibre-gl';
|
|
2
2
|
import { ColorRamp } from '../colorramp';
|
|
3
3
|
import { DataDrivenStyle, PropertyValues, ZoomNumberValues, ZoomStringValues } from './vectorlayerhelpers';
|
|
4
|
-
|
|
5
4
|
export type ColorPalette = [string, string, string, string];
|
|
6
5
|
export declare const colorPalettes: Array<ColorPalette>;
|
|
7
6
|
export declare function getRandomColor(): string;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { default as maplibregl } from 'maplibre-gl';
|
|
2
|
-
|
|
3
2
|
export type * from 'maplibre-gl';
|
|
4
3
|
/**
|
|
5
4
|
* Get the version of MapTiler SDK
|
|
@@ -84,7 +83,7 @@ export { type AutomaticStaticMapOptions, type BoundedStaticMapOptions, type Buff
|
|
|
84
83
|
export { getWebGLSupportError } from './tools';
|
|
85
84
|
export { config, SdkConfig } from './config';
|
|
86
85
|
export * from './language';
|
|
87
|
-
export {
|
|
86
|
+
export type { Unit } from './unit';
|
|
88
87
|
export * from './Minimap';
|
|
89
88
|
export * from './converters';
|
|
90
89
|
export * from './colorramp';
|
package/dist/src/language.d.ts
CHANGED
package/dist/src/mapstyle.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ReferenceMapStyle, MapStyleVariant } from '@maptiler/client';
|
|
2
|
-
|
|
3
2
|
export declare function styleToStyle(style: string | ReferenceMapStyle | MapStyleVariant | maplibregl.StyleSpecification | null | undefined): {
|
|
4
3
|
style: string | maplibregl.StyleSpecification;
|
|
5
4
|
requiresUrlMonitoring: boolean;
|
package/dist/src/tools.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { default as maplibregl, RequestParameters, ResourceType, RequestTransformFunction } from 'maplibre-gl';
|
|
2
2
|
import { Map as MapSDK } from './Map';
|
|
3
|
-
|
|
4
3
|
export declare function enableRTL(): void;
|
|
5
4
|
export declare function bindAll(fns: Array<string>, context: any): void;
|
|
6
5
|
export declare function DOMcreate<K extends keyof HTMLElementTagNameMap>(tagName: K, className?: string, container?: HTMLElement): HTMLElementTagNameMap[K];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maptiler/sdk",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "The Javascript & TypeScript map SDK tailored for MapTiler Cloud",
|
|
5
5
|
"module": "dist/maptiler-sdk.mjs",
|
|
6
6
|
"types": "dist/maptiler-sdk.d.ts",
|
|
@@ -37,35 +37,35 @@
|
|
|
37
37
|
"biome": "biome check --max-diagnostics=1000",
|
|
38
38
|
"biome:fix": "npx @biomejs/biome check --max-diagnostics=1000 --write",
|
|
39
39
|
"doc": "rm -rf docs/* && typedoc --out docs && cp -r images docs/",
|
|
40
|
-
"test": "vitest run",
|
|
41
|
-
"build-css": "node scripts/replace-path-with-content.js src/style/style_template.css dist/tmp_maptiler-sdk.css && cat node_modules/maplibre-gl/dist/maplibre-gl.css dist/tmp_maptiler-sdk.css > dist/maptiler-sdk.css && rm dist/tmp_maptiler-sdk.css && cp dist/maptiler-sdk.css build/maptiler-sdk.css",
|
|
40
|
+
"test": "vitest run -c vite.config-test.ts",
|
|
41
|
+
"build-css": "mkdir -p dist build && node scripts/replace-path-with-content.js src/style/style_template.css dist/tmp_maptiler-sdk.css && cat node_modules/maplibre-gl/dist/maplibre-gl.css dist/tmp_maptiler-sdk.css > dist/maptiler-sdk.css && rm dist/tmp_maptiler-sdk.css && cp dist/maptiler-sdk.css build/maptiler-sdk.css",
|
|
42
42
|
"build-umd": "tsc && NODE_ENV=production vite build -c vite.config-umd.ts",
|
|
43
43
|
"build-es": "tsc && NODE_ENV=production vite build -c vite.config-es.ts",
|
|
44
44
|
"build": "npm run build-es; npm run build-umd; npm run build-css",
|
|
45
45
|
"make": "npm run biome:fix && npm run build",
|
|
46
|
+
"dev": "concurrently \"vite -c vite.config-dev.ts\" \"npm run dev-umd\"",
|
|
46
47
|
"dev-umd": "npm run build-css && tsc && NODE_ENV=dev vite build -w -c vite.config-umd.ts",
|
|
47
|
-
"
|
|
48
|
+
"ncu": "npx npm-check-updates"
|
|
48
49
|
},
|
|
49
50
|
"author": "MapTiler",
|
|
50
51
|
"devDependencies": {
|
|
51
|
-
"@biomejs/biome": "1.
|
|
52
|
-
"@types/uuid": "^
|
|
52
|
+
"@biomejs/biome": "1.9.4",
|
|
53
|
+
"@types/uuid": "^10.0.0",
|
|
53
54
|
"@types/xmldom": "^0.1.31",
|
|
54
55
|
"@xmldom/xmldom": "^0.8.10",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"vite": "^
|
|
60
|
-
"
|
|
61
|
-
"vitest": "^0.34.2"
|
|
56
|
+
"concurrently": "^9.1.2",
|
|
57
|
+
"typedoc": "^0.27.6",
|
|
58
|
+
"typescript": "^5.7.2",
|
|
59
|
+
"vite": "^6.0.7",
|
|
60
|
+
"vite-plugin-dts": "^4.4.0",
|
|
61
|
+
"vitest": "^2.1.8"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@maplibre/maplibre-gl-style-spec": "^22.0.1",
|
|
65
65
|
"@maptiler/client": "^2.2.0",
|
|
66
66
|
"events": "^3.3.0",
|
|
67
|
-
"js-base64": "^3.7.
|
|
68
|
-
"maplibre-gl": "^5.0.0
|
|
69
|
-
"uuid": "^
|
|
67
|
+
"js-base64": "^3.7.7",
|
|
68
|
+
"maplibre-gl": "^5.0.0",
|
|
69
|
+
"uuid": "^11.0.4"
|
|
70
70
|
}
|
|
71
71
|
}
|
package/readme.md
CHANGED
|
@@ -136,7 +136,7 @@ The SDK hosted on our CDN is bundled as *[Universal Module Definition](https://g
|
|
|
136
136
|
<body>
|
|
137
137
|
<div id="map-container"></div>
|
|
138
138
|
|
|
139
|
-
<script src ="dist/maptiler-sdk.umd.js"></script>
|
|
139
|
+
<script src ="dist/maptiler-sdk.umd.min.js"></script>
|
|
140
140
|
|
|
141
141
|
<script>
|
|
142
142
|
// Add your MapTiler Cloud API key to the config
|
|
@@ -1103,7 +1103,40 @@ Turning off *zoom compensation* allows for more accurate adjustments to the visu
|
|
|
1103
1103
|
|
|
1104
1104
|
All the other options are documented on [our reference page](https://docs.maptiler.com/sdk-js/api/helpers/#heatmap) and more examples are available [here](https://docs.maptiler.com/sdk-js/examples/?q=heatmap+helper).
|
|
1105
1105
|
|
|
1106
|
-
# Other
|
|
1106
|
+
# Other helpers
|
|
1107
|
+
## Convert GPX and KML to GeoJSON
|
|
1108
|
+
In the [Polyline helper section](#polyline-layer-helper) above, we have seen that one can feed the helper directly with a path to a GPX or KML file, that is then converted under the hood client-side into a GeoJSON `FeatureCollection` object. This conversion feature is also exposed and can be used as such:
|
|
1109
|
+
|
|
1110
|
+
```ts
|
|
1111
|
+
import { gpx } from "@maptiler/sdk";
|
|
1112
|
+
|
|
1113
|
+
// ... assuming inside an async function
|
|
1114
|
+
|
|
1115
|
+
// Fetching the GPX file as a string:
|
|
1116
|
+
const gpxFilePath = "some_gps_trace.gpx";
|
|
1117
|
+
const gpxResponse = await fetch(gpxFilePath);
|
|
1118
|
+
const gpxStr = await res.text();
|
|
1119
|
+
|
|
1120
|
+
// Converting the GPX payload into a GeoJSON FeatureCollection:
|
|
1121
|
+
const features = maptilersdk.gpx(gpxStr);
|
|
1122
|
+
```
|
|
1123
|
+
|
|
1124
|
+
And for KML files:
|
|
1125
|
+
```ts
|
|
1126
|
+
import { kml } from "@maptiler/sdk";
|
|
1127
|
+
|
|
1128
|
+
// ... assuming inside an async function
|
|
1129
|
+
|
|
1130
|
+
// Fetching the KML file as a string:
|
|
1131
|
+
const kmlFilePath = "some_gps_trace.kml";
|
|
1132
|
+
const kmlResponse = await fetch(kmlFilePath);
|
|
1133
|
+
const kmlStr = await res.text();
|
|
1134
|
+
|
|
1135
|
+
// Converting the KML payload into a GeoJSON FeatureCollection:
|
|
1136
|
+
const features = maptilersdk.gpx(kmlStr);
|
|
1137
|
+
```
|
|
1138
|
+
|
|
1139
|
+
|
|
1107
1140
|
## Take Screenshots, programmatically
|
|
1108
1141
|
There are two different ways to create screenshot, corresponding to two very different usecases. Note that screenshots will not contain *DOM elements* such as `Marker` and `Popup`, since those are not part of the rendering context.
|
|
1109
1142
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
plugins: [
|
|
5
|
+
{
|
|
6
|
+
name: 'url-override',
|
|
7
|
+
/**
|
|
8
|
+
* Changing logged URLs to include the path to the demo directory.
|
|
9
|
+
*/
|
|
10
|
+
configureServer: (server) => {
|
|
11
|
+
const printUrls = server.printUrls;
|
|
12
|
+
|
|
13
|
+
server.printUrls = () => {
|
|
14
|
+
if (server.resolvedUrls !== null) {
|
|
15
|
+
for (const [key, value] of Object.entries(server.resolvedUrls)) {
|
|
16
|
+
for (let i = 0; i < value.length; i++) {
|
|
17
|
+
server.resolvedUrls[key][i] += "demos/index.html";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
printUrls();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
});
|
package/vite.config-umd.ts
CHANGED
|
@@ -2,26 +2,20 @@ import { resolve } from 'path';
|
|
|
2
2
|
import { defineConfig } from 'vite';
|
|
3
3
|
|
|
4
4
|
const isProduction = process.env.NODE_ENV === "production";
|
|
5
|
-
const bundleFilename = isProduction ? "maptiler-sdk.umd.min.js" : "maptiler-sdk.umd.js"
|
|
6
|
-
|
|
7
|
-
const plugins = [];
|
|
8
|
-
|
|
9
5
|
|
|
10
6
|
export default defineConfig({
|
|
11
7
|
mode: isProduction ? "production" : "development",
|
|
12
8
|
build: {
|
|
13
9
|
outDir: "build",
|
|
14
|
-
minify:
|
|
10
|
+
minify: true,
|
|
15
11
|
emptyOutDir: isProduction,
|
|
16
12
|
sourcemap: true,
|
|
17
13
|
lib: {
|
|
18
|
-
// Could also be a dictionary or array of multiple entry points
|
|
19
14
|
entry: resolve(__dirname, 'src/index.ts'),
|
|
20
15
|
name: 'maptilersdk',
|
|
21
|
-
|
|
22
|
-
fileName: (format, entryName) => bundleFilename,
|
|
16
|
+
fileName: (format, entryName) => "maptiler-sdk.umd.min.js",
|
|
23
17
|
formats: ['umd'],
|
|
24
18
|
}
|
|
25
19
|
},
|
|
26
|
-
plugins,
|
|
27
|
-
})
|
|
20
|
+
plugins: [],
|
|
21
|
+
});
|
|
File without changes
|