@maptiler/sdk 2.2.2 → 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/dist/maptiler-sdk.mjs +874 -920
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/src/Map.d.ts +4 -4
- package/dist/src/MaptilerGeolocateControl.d.ts +1 -1
- package/dist/src/MaptilerNavigationControl.d.ts +2 -1
- package/dist/src/config.d.ts +3 -3
- package/dist/src/defaults.d.ts +2 -2
- package/dist/src/helpers/index.d.ts +2 -0
- package/dist/src/helpers/screenshot.d.ts +19 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/language.d.ts +96 -130
- package/package.json +12 -10
- package/readme.md +31 -0
- package/vite.config-es.ts +1 -1
- package/vite.config-umd.ts +3 -1
package/dist/src/Map.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as maplibregl, StyleSpecification, MapOptions as MapOptionsML, ControlPosition, StyleSwapOptions, StyleOptions, RequestTransformFunction, LayerSpecification, SourceSpecification, CustomLayerInterface, FilterSpecification, StyleSetterOptions } from 'maplibre-gl';
|
|
2
2
|
import { ReferenceMapStyle, MapStyleVariant } from '@maptiler/client';
|
|
3
3
|
import { SdkConfig } from './config';
|
|
4
|
-
import {
|
|
4
|
+
import { LanguageInfo } from './language';
|
|
5
5
|
import { MinimapOptionsInput } from './Minimap';
|
|
6
6
|
|
|
7
7
|
export type LoadWithTerrainEvent = {
|
|
@@ -32,7 +32,7 @@ export type MapOptions = Omit<MapOptionsML, "style" | "maplibreLogo"> & {
|
|
|
32
32
|
* or with a built-in shorthand (eg. Language.ENGLISH).
|
|
33
33
|
* Note that this is equivalent to setting the `config.primaryLanguage` and will overwrite it.
|
|
34
34
|
*/
|
|
35
|
-
language?:
|
|
35
|
+
language?: LanguageInfo;
|
|
36
36
|
/**
|
|
37
37
|
* Define the MapTiler Cloud API key to be used. This is strictly equivalent to setting
|
|
38
38
|
* `config.apiKey` and will overwrite it.
|
|
@@ -277,7 +277,7 @@ export declare class Map extends maplibregl.Map {
|
|
|
277
277
|
/**
|
|
278
278
|
* Define the primary language of the map. Note that not all the languages shorthands provided are available.
|
|
279
279
|
*/
|
|
280
|
-
setLanguage(language:
|
|
280
|
+
setLanguage(language: LanguageInfo | string): void;
|
|
281
281
|
/**
|
|
282
282
|
* Define the primary language of the map. Note that not all the languages shorthands provided are available.
|
|
283
283
|
*/
|
|
@@ -286,7 +286,7 @@ export declare class Map extends maplibregl.Map {
|
|
|
286
286
|
* Get the primary language
|
|
287
287
|
* @returns
|
|
288
288
|
*/
|
|
289
|
-
getPrimaryLanguage():
|
|
289
|
+
getPrimaryLanguage(): LanguageInfo;
|
|
290
290
|
/**
|
|
291
291
|
* Get the exaggeration factor applied to the terrain
|
|
292
292
|
* @returns
|
|
@@ -15,7 +15,7 @@ export declare class MaptilerGeolocateControl extends GeolocateControl {
|
|
|
15
15
|
* @private
|
|
16
16
|
*/
|
|
17
17
|
_updateCamera: (position: GeolocationPosition) => void;
|
|
18
|
-
|
|
18
|
+
_finishSetupUI: (supported: boolean) => void;
|
|
19
19
|
_updateCircleRadius(): void;
|
|
20
20
|
_onZoom: () => void;
|
|
21
21
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { NavigationControlOptions } from 'maplibre-gl';
|
|
1
2
|
import { NavigationControl } from './MLAdapters/NavigationControl';
|
|
2
3
|
|
|
3
4
|
type HTMLButtonElementPlus = HTMLButtonElement & {
|
|
4
5
|
clickFunction: (e?: Event) => unknown;
|
|
5
6
|
};
|
|
6
7
|
export declare class MaptilerNavigationControl extends NavigationControl {
|
|
7
|
-
constructor();
|
|
8
|
+
constructor(options?: NavigationControlOptions);
|
|
8
9
|
/**
|
|
9
10
|
* Overloading: the button now stores its click callback so that we can later on delete it and replace it
|
|
10
11
|
*/
|
package/dist/src/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as EventEmitter } from 'events';
|
|
2
|
-
import {
|
|
2
|
+
import { LanguageInfo } from './language';
|
|
3
3
|
import { FetchFunction } from '@maptiler/client';
|
|
4
4
|
import { Unit } from './unit';
|
|
5
5
|
|
|
@@ -11,12 +11,12 @@ declare class SdkConfig extends EventEmitter {
|
|
|
11
11
|
/**
|
|
12
12
|
* The primary language. By default, the language of the web browser is used.
|
|
13
13
|
*/
|
|
14
|
-
primaryLanguage:
|
|
14
|
+
primaryLanguage: LanguageInfo;
|
|
15
15
|
/**
|
|
16
16
|
* The secondary language, to overwrite the default language defined in the map style.
|
|
17
17
|
* This settings is highly dependant on the style compatibility and may not work in most cases.
|
|
18
18
|
*/
|
|
19
|
-
secondaryLanguage?:
|
|
19
|
+
secondaryLanguage?: LanguageInfo;
|
|
20
20
|
/**
|
|
21
21
|
* Setting on whether of not the SDK runs with a session logic.
|
|
22
22
|
* A "session" is started at the initialization of the SDK and finished when the browser
|
package/dist/src/defaults.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ declare const defaults: {
|
|
|
6
6
|
maptilerURL: string;
|
|
7
7
|
maptilerApiHost: string;
|
|
8
8
|
rtlPluginURL: string;
|
|
9
|
-
primaryLanguage:
|
|
10
|
-
secondaryLanguage:
|
|
9
|
+
primaryLanguage: import('@maptiler/client').LanguageInfo;
|
|
10
|
+
secondaryLanguage: import('@maptiler/client').LanguageInfo;
|
|
11
11
|
terrainSourceURL: string;
|
|
12
12
|
terrainSourceId: string;
|
|
13
13
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { takeScreenshot } from './screenshot';
|
|
1
2
|
import { addPolyline, addPolygon, addPoint, addHeatmap } from './vectorlayerhelpers';
|
|
2
3
|
|
|
3
4
|
export type { ZoomStringValues, ZoomNumberValues, PropertyValues, CommonShapeLayerOptions, PolylineLayerOptions, PolygonLayerOptions, PointLayerOptions, HeatmapLayerOptions, } from './vectorlayerhelpers';
|
|
@@ -9,4 +10,5 @@ export declare const helpers: {
|
|
|
9
10
|
addPolygon: typeof addPolygon;
|
|
10
11
|
addPoint: typeof addPoint;
|
|
11
12
|
addHeatmap: typeof addHeatmap;
|
|
13
|
+
takeScreenshot: typeof takeScreenshot;
|
|
12
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>;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -79,7 +79,7 @@ export * from './MaptilerGeolocateControl';
|
|
|
79
79
|
export * from './MaptilerLogoControl';
|
|
80
80
|
export * from './MaptilerTerrainControl';
|
|
81
81
|
export * from './MaptilerNavigationControl';
|
|
82
|
-
export { type AutomaticStaticMapOptions, type BoundedStaticMapOptions, type BufferToPixelDataFunction, type ByIdGeocodingOptions, type CenteredStaticMapOptions, type CommonForwardAndReverseGeocodingOptions, type CoordinateExport, type CoordinateGrid, type CoordinateId, type CoordinateSearch, type CoordinateSearchResult, type CoordinateTransformResult, type CoordinateTransformation, type Coordinates, type CoordinatesSearchOptions, type CoordinatesTransformOptions, type DefaultTransformation, type ElevationAtOptions, type ElevationBatchOptions, type FeatureHierarchy, type FetchFunction, type GeocodingFeature, type GeocodingOptions, type GeocodingSearchResult, type GeolocationInfoOptions, type GeolocationResult, type GetDataOptions,
|
|
82
|
+
export { type AutomaticStaticMapOptions, type BoundedStaticMapOptions, type BufferToPixelDataFunction, type ByIdGeocodingOptions, type CenteredStaticMapOptions, type CommonForwardAndReverseGeocodingOptions, type CoordinateExport, type CoordinateGrid, type CoordinateId, type CoordinateSearch, type CoordinateSearchResult, type CoordinateTransformResult, type CoordinateTransformation, type Coordinates, type CoordinatesSearchOptions, type CoordinatesTransformOptions, type DefaultTransformation, type ElevationAtOptions, type ElevationBatchOptions, type FeatureHierarchy, type FetchFunction, type GeocodingFeature, type GeocodingOptions, type GeocodingSearchResult, type GeolocationInfoOptions, type GeolocationResult, type GetDataOptions, type LanguageGeocodingOptions, MapStyle, type MapStylePreset, type MapStyleType, MapStyleVariant, type PixelData, ReferenceMapStyle, type ReverseGeocodingOptions, ServiceError, type StaticMapBaseOptions, type StaticMapMarker, type TileJSON, type XYZ, bufferToPixelDataBrowser, circumferenceAtLatitude, coordinates, data, elevation, expandMapStyle, geocoding, geolocation, getBufferToPixelDataParser, getTileCache, mapStylePresetList, math, misc, staticMaps, styleToStyle, type LanguageInfo, areSameLanguages, toLanguageInfo, isLanguageInfo, getAutoLanguage, getLanguageInfoFromFlag, getLanguageInfoFromCode, getLanguageInfoFromKey, } from '@maptiler/client';
|
|
83
83
|
export { config, SdkConfig } from './config';
|
|
84
84
|
export * from './language';
|
|
85
85
|
export { type Unit } from './unit';
|
package/dist/src/language.d.ts
CHANGED
|
@@ -1,142 +1,108 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
1
|
+
import { LanguageInfo } from '@maptiler/client';
|
|
2
|
+
|
|
4
3
|
declare const Language: {
|
|
4
|
+
readonly AUTO: LanguageInfo;
|
|
5
|
+
readonly LATIN: LanguageInfo;
|
|
6
|
+
readonly NON_LATIN: LanguageInfo;
|
|
7
|
+
readonly LOCAL: LanguageInfo;
|
|
8
|
+
readonly AMHARIC: LanguageInfo;
|
|
9
|
+
readonly ARABIC: LanguageInfo;
|
|
10
|
+
readonly AZERBAIJANI: LanguageInfo;
|
|
11
|
+
readonly BELARUSIAN: LanguageInfo;
|
|
12
|
+
readonly BULGARIAN: LanguageInfo;
|
|
13
|
+
readonly BENGALI: LanguageInfo;
|
|
14
|
+
readonly BRETON: LanguageInfo;
|
|
15
|
+
readonly BOSNIAN: LanguageInfo;
|
|
16
|
+
readonly CATALAN: LanguageInfo;
|
|
17
|
+
readonly CHINESE: LanguageInfo;
|
|
18
|
+
readonly TRADITIONAL_CHINESE: LanguageInfo;
|
|
19
|
+
readonly SIMPLIFIED_CHINESE: LanguageInfo;
|
|
20
|
+
readonly CORSICAN: LanguageInfo;
|
|
21
|
+
readonly CZECH: LanguageInfo;
|
|
22
|
+
readonly WELSH: LanguageInfo;
|
|
23
|
+
readonly DANISH: LanguageInfo;
|
|
24
|
+
readonly GERMAN: LanguageInfo;
|
|
25
|
+
readonly GREEK: LanguageInfo;
|
|
26
|
+
readonly ENGLISH: LanguageInfo;
|
|
27
|
+
readonly ESPERANTO: LanguageInfo;
|
|
28
|
+
readonly SPANISH: LanguageInfo;
|
|
29
|
+
readonly ESTONIAN: LanguageInfo;
|
|
30
|
+
readonly BASQUE: LanguageInfo;
|
|
31
|
+
readonly FINNISH: LanguageInfo;
|
|
32
|
+
readonly FRENCH: LanguageInfo;
|
|
33
|
+
readonly FRISIAN: LanguageInfo;
|
|
34
|
+
readonly IRISH: LanguageInfo;
|
|
35
|
+
readonly SCOTTISH_GAELIC: LanguageInfo;
|
|
36
|
+
readonly HEBREW: LanguageInfo;
|
|
37
|
+
readonly HINDI: LanguageInfo;
|
|
38
|
+
readonly CROATIAN: LanguageInfo;
|
|
39
|
+
readonly HUNGARIAN: LanguageInfo;
|
|
40
|
+
readonly ARMENIAN: LanguageInfo;
|
|
41
|
+
readonly INDONESIAN: LanguageInfo;
|
|
42
|
+
readonly ICELANDIC: LanguageInfo;
|
|
43
|
+
readonly ITALIAN: LanguageInfo;
|
|
44
|
+
readonly JAPANESE: LanguageInfo;
|
|
45
|
+
readonly JAPANESE_HIRAGANA: LanguageInfo;
|
|
46
|
+
readonly JAPANESE_2018: LanguageInfo;
|
|
47
|
+
readonly JAPANESE_KANA: LanguageInfo;
|
|
48
|
+
readonly JAPANESE_LATIN: LanguageInfo;
|
|
49
|
+
readonly GEORGIAN: LanguageInfo;
|
|
50
|
+
readonly KAZAKH: LanguageInfo;
|
|
51
|
+
readonly KANNADA: LanguageInfo;
|
|
52
|
+
readonly KOREAN: LanguageInfo;
|
|
53
|
+
readonly KOREAN_LATIN: LanguageInfo;
|
|
54
|
+
readonly KURDISH: LanguageInfo;
|
|
55
|
+
readonly CLASSICAL_LATIN: LanguageInfo;
|
|
56
|
+
readonly LUXEMBOURGISH: LanguageInfo;
|
|
57
|
+
readonly LITHUANIAN: LanguageInfo;
|
|
58
|
+
readonly LATVIAN: LanguageInfo;
|
|
59
|
+
readonly MACEDONIAN: LanguageInfo;
|
|
60
|
+
readonly MALAYALAM: LanguageInfo;
|
|
61
|
+
readonly MALTESE: LanguageInfo;
|
|
62
|
+
readonly DUTCH: LanguageInfo;
|
|
63
|
+
readonly NORWEGIAN: LanguageInfo;
|
|
64
|
+
readonly OCCITAN: LanguageInfo;
|
|
65
|
+
readonly POLISH: LanguageInfo;
|
|
66
|
+
readonly PERSIAN: LanguageInfo;
|
|
67
|
+
readonly PUNJABI: LanguageInfo;
|
|
68
|
+
readonly WESTERN_PUNJABI: LanguageInfo;
|
|
69
|
+
readonly PORTUGUESE: LanguageInfo;
|
|
70
|
+
readonly ROMANSH: LanguageInfo;
|
|
71
|
+
readonly ROMANIAN: LanguageInfo;
|
|
72
|
+
readonly RUSSIAN: LanguageInfo;
|
|
73
|
+
readonly SLOVAK: LanguageInfo;
|
|
74
|
+
readonly SLOVENE: LanguageInfo;
|
|
75
|
+
readonly ALBANIAN: LanguageInfo;
|
|
76
|
+
readonly SERBIAN_CYRILLIC: LanguageInfo;
|
|
77
|
+
readonly SERBIAN_LATIN: LanguageInfo;
|
|
78
|
+
readonly SWEDISH: LanguageInfo;
|
|
79
|
+
readonly TAMIL: LanguageInfo;
|
|
80
|
+
readonly TELUGU: LanguageInfo;
|
|
81
|
+
readonly THAI: LanguageInfo;
|
|
82
|
+
readonly TURKISH: LanguageInfo;
|
|
83
|
+
readonly UKRAINIAN: LanguageInfo;
|
|
84
|
+
readonly VIETNAMESE: LanguageInfo;
|
|
5
85
|
/**
|
|
6
|
-
*
|
|
7
|
-
* Note
|
|
8
|
-
* scale or the local name.
|
|
9
|
-
* This mode is helpful in the context where a user needs to access both the local names and the names in their
|
|
10
|
-
* own language, for instance when traveling abroad, where signs likely to be only available in the local language.
|
|
11
|
-
*/
|
|
12
|
-
readonly VISITOR: "visitor";
|
|
13
|
-
/**
|
|
14
|
-
* The visitor language mode concatenates English and the "default name".
|
|
15
|
-
* Note: The "default name" is equivalent to OSM's `{name}`, which can be the most recognized names a global
|
|
16
|
-
* scale or the local name.
|
|
17
|
-
* This mode is helpful in the context where a user needs to access both the local names and the names in their
|
|
18
|
-
* own language, for instance when traveling abroad, where signs likely to be only available in the local language.
|
|
19
|
-
*/
|
|
20
|
-
readonly VISITOR_ENGLISH: "visitor_en";
|
|
21
|
-
/**
|
|
22
|
-
* Language as the style is designed. Not that this is the default state and one
|
|
23
|
-
* the language has been changed to another than `STYLE`, then it cannot be set back to `STYLE`.
|
|
24
|
-
*/
|
|
25
|
-
readonly STYLE: "style";
|
|
26
|
-
/**
|
|
27
|
-
* AUTO mode uses the language of the browser
|
|
28
|
-
*/
|
|
29
|
-
readonly AUTO: "auto";
|
|
30
|
-
/**
|
|
31
|
-
* STYLE is a custom flag to keep the language of the map as defined into the style.
|
|
32
|
-
* If STYLE is set in the constructor, then further modification of the language
|
|
33
|
-
* with `.setLanguage()` is not possible.
|
|
86
|
+
* Language mode to display labels in both the local language and the language of the visitor's device, concatenated.
|
|
87
|
+
* Note that if those two languages are the same, labels won't be duplicated.
|
|
34
88
|
*/
|
|
35
|
-
readonly
|
|
89
|
+
readonly VISITOR: LanguageInfo;
|
|
36
90
|
/**
|
|
37
|
-
*
|
|
91
|
+
* Language mode to display labels in both the local language and English, concatenated.
|
|
92
|
+
* Note that if those two languages are the same, labels won't be duplicated.
|
|
38
93
|
*/
|
|
39
|
-
readonly
|
|
94
|
+
readonly VISITOR_ENGLISH: LanguageInfo;
|
|
40
95
|
/**
|
|
41
|
-
*
|
|
96
|
+
* Language mode to display labels in a language enforced in the style.
|
|
42
97
|
*/
|
|
43
|
-
readonly
|
|
98
|
+
readonly STYLE: LanguageInfo;
|
|
44
99
|
/**
|
|
45
|
-
*
|
|
100
|
+
* Language mode to display labels in a language enforced in the style. The language cannot be further modified.
|
|
46
101
|
*/
|
|
47
|
-
readonly
|
|
48
|
-
/**
|
|
49
|
-
* International name
|
|
50
|
-
*/
|
|
51
|
-
readonly INTERNATIONAL: "name_int";
|
|
52
|
-
readonly ALBANIAN: "name:sq";
|
|
53
|
-
readonly AMHARIC: "name:am";
|
|
54
|
-
readonly ARABIC: "name:ar";
|
|
55
|
-
readonly ARMENIAN: "name:hy";
|
|
56
|
-
readonly AZERBAIJANI: "name:az";
|
|
57
|
-
readonly BASQUE: "name:eu";
|
|
58
|
-
readonly BELORUSSIAN: "name:be";
|
|
59
|
-
readonly BENGALI: "name:bn";
|
|
60
|
-
readonly BOSNIAN: "name:bs";
|
|
61
|
-
readonly BRETON: "name:br";
|
|
62
|
-
readonly BULGARIAN: "name:bg";
|
|
63
|
-
readonly CATALAN: "name:ca";
|
|
64
|
-
readonly CHINESE: "name:zh";
|
|
65
|
-
readonly TRADITIONAL_CHINESE: "name:zh-Hant";
|
|
66
|
-
readonly SIMPLIFIED_CHINESE: "name:zh-Hans";
|
|
67
|
-
readonly CORSICAN: "name:co";
|
|
68
|
-
readonly CROATIAN: "name:hr";
|
|
69
|
-
readonly CZECH: "name:cs";
|
|
70
|
-
readonly DANISH: "name:da";
|
|
71
|
-
readonly DUTCH: "name:nl";
|
|
72
|
-
readonly ENGLISH: "name:en";
|
|
73
|
-
readonly ESPERANTO: "name:eo";
|
|
74
|
-
readonly ESTONIAN: "name:et";
|
|
75
|
-
readonly FINNISH: "name:fi";
|
|
76
|
-
readonly FRENCH: "name:fr";
|
|
77
|
-
readonly FRISIAN: "name:fy";
|
|
78
|
-
readonly GEORGIAN: "name:ka";
|
|
79
|
-
readonly GERMAN: "name:de";
|
|
80
|
-
readonly GREEK: "name:el";
|
|
81
|
-
readonly HEBREW: "name:he";
|
|
82
|
-
readonly HINDI: "name:hi";
|
|
83
|
-
readonly HUNGARIAN: "name:hu";
|
|
84
|
-
readonly ICELANDIC: "name:is";
|
|
85
|
-
readonly INDONESIAN: "name:id";
|
|
86
|
-
readonly IRISH: "name:ga";
|
|
87
|
-
readonly ITALIAN: "name:it";
|
|
88
|
-
readonly JAPANESE: "name:ja";
|
|
89
|
-
readonly JAPANESE_HIRAGANA: "name:ja-Hira";
|
|
90
|
-
readonly JAPANESE_KANA: "name:ja_kana";
|
|
91
|
-
readonly JAPANESE_LATIN: "name:ja_rm";
|
|
92
|
-
readonly JAPANESE_2018: "name:ja-Latn";
|
|
93
|
-
readonly KANNADA: "name:kn";
|
|
94
|
-
readonly KAZAKH: "name:kk";
|
|
95
|
-
readonly KOREAN: "name:ko";
|
|
96
|
-
readonly KOREAN_LATIN: "name:ko-Latn";
|
|
97
|
-
readonly KURDISH: "name:ku";
|
|
98
|
-
readonly ROMAN_LATIN: "name:la";
|
|
99
|
-
readonly LATVIAN: "name:lv";
|
|
100
|
-
readonly LITHUANIAN: "name:lt";
|
|
101
|
-
readonly LUXEMBOURGISH: "name:lb";
|
|
102
|
-
readonly MACEDONIAN: "name:mk";
|
|
103
|
-
readonly MALAYALAM: "name:ml";
|
|
104
|
-
readonly MALTESE: "name:mt";
|
|
105
|
-
readonly NORWEGIAN: "name:no";
|
|
106
|
-
readonly OCCITAN: "name:oc";
|
|
107
|
-
readonly PERSIAN: "name:fa";
|
|
108
|
-
readonly POLISH: "name:pl";
|
|
109
|
-
readonly PORTUGUESE: "name:pt";
|
|
110
|
-
readonly PUNJABI: "name:pa";
|
|
111
|
-
readonly WESTERN_PUNJABI: "name:pnb";
|
|
112
|
-
readonly ROMANIAN: "name:ro";
|
|
113
|
-
readonly ROMANSH: "name:rm";
|
|
114
|
-
readonly RUSSIAN: "name:ru";
|
|
115
|
-
readonly SCOTTISH_GAELIC: "name:gd";
|
|
116
|
-
readonly SERBIAN_CYRILLIC: "name:sr";
|
|
117
|
-
readonly SERBIAN_LATIN: "name:sr-Latn";
|
|
118
|
-
readonly SLOVAK: "name:sk";
|
|
119
|
-
readonly SLOVENE: "name:sl";
|
|
120
|
-
readonly SPANISH: "name:es";
|
|
121
|
-
readonly SWEDISH: "name:sv";
|
|
122
|
-
readonly TAMIL: "name:ta";
|
|
123
|
-
readonly TELUGU: "name:te";
|
|
124
|
-
readonly THAI: "name:th";
|
|
125
|
-
readonly TURKISH: "name:tr";
|
|
126
|
-
readonly UKRAINIAN: "name:uk";
|
|
127
|
-
readonly URDU: "name:ur";
|
|
128
|
-
readonly VIETNAMIAN_LATIN: "name:vi";
|
|
129
|
-
readonly WELSH: "name:cy";
|
|
102
|
+
readonly STYLE_LOCK: LanguageInfo;
|
|
130
103
|
};
|
|
131
|
-
declare function isLanguageSupported(lang: string): boolean;
|
|
132
|
-
/**
|
|
133
|
-
* Type representing the key of the Language object
|
|
134
|
-
*/
|
|
135
|
-
type LanguageKey = keyof typeof Language;
|
|
136
|
-
type Values<T> = T[keyof T];
|
|
137
104
|
/**
|
|
138
|
-
*
|
|
105
|
+
* Get the browser language
|
|
139
106
|
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
export { Language, type LanguageString, type LanguageKey, getBrowserLanguage, isLanguageSupported };
|
|
107
|
+
export declare function getBrowserLanguage(): LanguageInfo;
|
|
108
|
+
export { Language, type LanguageInfo };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maptiler/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.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",
|
|
@@ -39,30 +39,32 @@
|
|
|
39
39
|
"doc": "rm -rf docs/* && typedoc --out docs && cp -r images docs/",
|
|
40
40
|
"test": "vitest run",
|
|
41
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",
|
|
42
|
-
"build-umd": "NODE_ENV=production
|
|
43
|
-
"build-es": "NODE_ENV=production
|
|
42
|
+
"build-umd": "tsc && NODE_ENV=production vite build -c vite.config-umd.ts",
|
|
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
|
-
"make": "npm run biome:fix && npm run build"
|
|
45
|
+
"make": "npm run biome:fix && npm run build",
|
|
46
|
+
"dev-umd": "npm run build-css && tsc && NODE_ENV=dev vite build -w -c vite.config-umd.ts",
|
|
47
|
+
"help": "vite build --help"
|
|
46
48
|
},
|
|
47
49
|
"author": "MapTiler",
|
|
48
50
|
"devDependencies": {
|
|
49
51
|
"@biomejs/biome": "1.8.3",
|
|
50
52
|
"@types/uuid": "^9.0.2",
|
|
51
53
|
"@types/xmldom": "^0.1.31",
|
|
54
|
+
"@xmldom/xmldom": "^0.8.10",
|
|
52
55
|
"serve": "^14.2.0",
|
|
53
56
|
"terser": "^5.17.1",
|
|
54
57
|
"typedoc": "^0.24.8",
|
|
55
58
|
"typescript": "^5.1.6",
|
|
56
|
-
"vitest": "^0.34.2",
|
|
57
59
|
"vite": "^5.3.4",
|
|
58
|
-
"vite-plugin-dts": "^4.0.0-beta.0"
|
|
60
|
+
"vite-plugin-dts": "^4.0.0-beta.0",
|
|
61
|
+
"vitest": "^0.34.2"
|
|
59
62
|
},
|
|
60
63
|
"dependencies": {
|
|
61
|
-
"@maptiler/client": "^
|
|
64
|
+
"@maptiler/client": "^2.0.0",
|
|
62
65
|
"events": "^3.3.0",
|
|
63
66
|
"js-base64": "^3.7.4",
|
|
64
|
-
"maplibre-gl": "4.
|
|
65
|
-
"uuid": "^9.0.0"
|
|
66
|
-
"xmldom": "^0.6.0"
|
|
67
|
+
"maplibre-gl": "^4.7.0",
|
|
68
|
+
"uuid": "^9.0.0"
|
|
67
69
|
}
|
|
68
70
|
}
|
package/readme.md
CHANGED
|
@@ -862,6 +862,37 @@ Turning off *zoom compensation* allows for more accurate adjustments to the visu
|
|
|
862
862
|
|
|
863
863
|
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).
|
|
864
864
|
|
|
865
|
+
# Other helper
|
|
866
|
+
## Take Screenshots, programmatically
|
|
867
|
+
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.
|
|
868
|
+
|
|
869
|
+
**1. Get a `blob` of a screenshot, PNG encoded:**
|
|
870
|
+
```ts
|
|
871
|
+
import { Map, helpers } from "@maptiler/sdk";
|
|
872
|
+
|
|
873
|
+
// ... initialize a Map instance, wait for the "load" or "ready" event ...
|
|
874
|
+
|
|
875
|
+
// Inside an async function, or with using .then()
|
|
876
|
+
const blob = await helpers.takeScreenshot(map);
|
|
877
|
+
```
|
|
878
|
+
The returned `Blob` of a PNG image file can be very handy if the goal is to programmatically further manipulate the screenshot, such as sending it to some feedback endpoint with a POST request.
|
|
879
|
+
|
|
880
|
+
**2. Download a PNG file:**
|
|
881
|
+
```ts
|
|
882
|
+
import { Map, helpers } from "@maptiler/sdk";
|
|
883
|
+
|
|
884
|
+
// ... initialize a Map instance, wait for the "load" or "ready" event ...
|
|
885
|
+
|
|
886
|
+
// No need to be inside an async function, the download will be triggered when the file is ready
|
|
887
|
+
maptilersdk.helpers.takeScreenshot(map, {
|
|
888
|
+
download: true,
|
|
889
|
+
filename: "map_screenshot.png"
|
|
890
|
+
});
|
|
891
|
+
```
|
|
892
|
+
Getting a file directly is a nice option that can be useful to share some debugging context with colleagues, compare multiple styles, or share your creation on social media.
|
|
893
|
+
|
|
894
|
+
> 📣 *__Note:__* Keep in mind that MapTiler Cloud data are copyrighted and their usage is restricted. This include MapTiler built-in styles and tilesets, among others. In case of doubt, do not hesitate to read our [terms](https://www.maptiler.com/terms/) or to ask our [support team](https://www.maptiler.com/contacts/).
|
|
895
|
+
|
|
865
896
|
# Caching
|
|
866
897
|
Starting from v2, MapTiler SDK introduced the **caching** of tiles and fonts served by MapTiler Cloud, which can represent a large chunk of the data being fetched when browsing a map. This caching leverages modern browsers caching API so it's well-managed and there is no risk of bloating! When we update **MapTiler Planet** or our **official styles**, the caching logic will detect it and automatically invalidate older versions of the tiles that were previously cached.
|
|
867
898
|
|
package/vite.config-es.ts
CHANGED
|
@@ -12,6 +12,7 @@ export default defineConfig({
|
|
|
12
12
|
mode: isProduction ? "production" : "development",
|
|
13
13
|
build: {
|
|
14
14
|
minify: isProduction,
|
|
15
|
+
emptyOutDir: isProduction,
|
|
15
16
|
outDir: "dist",
|
|
16
17
|
sourcemap: true,
|
|
17
18
|
lib: {
|
|
@@ -35,7 +36,6 @@ export default defineConfig({
|
|
|
35
36
|
"events",
|
|
36
37
|
"js-base64",
|
|
37
38
|
"geojson-validation",
|
|
38
|
-
"xmldom",
|
|
39
39
|
],
|
|
40
40
|
output: {
|
|
41
41
|
// Provide global variables to use in the UMD build
|
package/vite.config-umd.ts
CHANGED
|
@@ -2,6 +2,7 @@ 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"
|
|
5
6
|
|
|
6
7
|
const plugins = [];
|
|
7
8
|
|
|
@@ -11,13 +12,14 @@ export default defineConfig({
|
|
|
11
12
|
build: {
|
|
12
13
|
outDir: "build",
|
|
13
14
|
minify: isProduction,
|
|
15
|
+
emptyOutDir: isProduction,
|
|
14
16
|
sourcemap: true,
|
|
15
17
|
lib: {
|
|
16
18
|
// Could also be a dictionary or array of multiple entry points
|
|
17
19
|
entry: resolve(__dirname, 'src/index.ts'),
|
|
18
20
|
name: 'maptilersdk',
|
|
19
21
|
// the proper extensions will be added
|
|
20
|
-
fileName: (format, entryName) =>
|
|
22
|
+
fileName: (format, entryName) => bundleFilename,
|
|
21
23
|
formats: ['umd'],
|
|
22
24
|
}
|
|
23
25
|
},
|