@maptiler/sdk 1.2.1 → 2.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.
Files changed (63) hide show
  1. package/.eslintrc.cjs +1 -0
  2. package/dist/maptiler-sdk.css +1 -1
  3. package/dist/maptiler-sdk.d.ts +171 -240
  4. package/dist/maptiler-sdk.min.mjs +3 -3
  5. package/dist/maptiler-sdk.mjs +462 -458
  6. package/dist/maptiler-sdk.mjs.map +1 -1
  7. package/package.json +3 -3
  8. package/readme.md +16 -1
  9. package/CHANGELOG.md +0 -168
  10. package/colorramp.md +0 -93
  11. package/dist/maptiler-sdk.umd.js +0 -7702
  12. package/dist/maptiler-sdk.umd.js.map +0 -1
  13. package/dist/maptiler-sdk.umd.min.js +0 -582
  14. package/src/AttributionControl.ts +0 -13
  15. package/src/CanvasSource.ts +0 -13
  16. package/src/FullscreenControl.ts +0 -13
  17. package/src/GeoJSONSource.ts +0 -13
  18. package/src/GeolocateControl.ts +0 -13
  19. package/src/ImageSource.ts +0 -13
  20. package/src/LogoControl.ts +0 -13
  21. package/src/Map.ts +0 -1352
  22. package/src/MaptilerGeolocateControl.ts +0 -207
  23. package/src/MaptilerLogoControl.ts +0 -58
  24. package/src/MaptilerNavigationControl.ts +0 -69
  25. package/src/MaptilerTerrainControl.ts +0 -72
  26. package/src/Marker.ts +0 -13
  27. package/src/Minimap.ts +0 -373
  28. package/src/NavigationControl.ts +0 -13
  29. package/src/Point.ts +0 -334
  30. package/src/Popup.ts +0 -13
  31. package/src/RasterDEMTileSource.ts +0 -13
  32. package/src/RasterTileSource.ts +0 -13
  33. package/src/ScaleControl.ts +0 -13
  34. package/src/Style.ts +0 -13
  35. package/src/TerrainControl.ts +0 -13
  36. package/src/VectorTileSource.ts +0 -13
  37. package/src/VideoSource.ts +0 -13
  38. package/src/colorramp.ts +0 -1216
  39. package/src/config.ts +0 -96
  40. package/src/converters/index.ts +0 -1
  41. package/src/converters/xml.ts +0 -681
  42. package/src/defaults.ts +0 -20
  43. package/src/helpers/index.ts +0 -27
  44. package/src/helpers/stylehelper.ts +0 -395
  45. package/src/helpers/vectorlayerhelpers.ts +0 -1511
  46. package/src/index.ts +0 -201
  47. package/src/language.ts +0 -183
  48. package/src/mapstyle.ts +0 -46
  49. package/src/style/style_template.css +0 -146
  50. package/src/style/svg/v6-compass.svg +0 -12
  51. package/src/style/svg/v6-fullscreen-off.svg +0 -7
  52. package/src/style/svg/v6-fullscreen.svg +0 -7
  53. package/src/style/svg/v6-geolocate-active-error.svg +0 -10
  54. package/src/style/svg/v6-geolocate-active.svg +0 -7
  55. package/src/style/svg/v6-geolocate-background.svg +0 -8
  56. package/src/style/svg/v6-geolocate-disabled.svg +0 -10
  57. package/src/style/svg/v6-geolocate.svg +0 -7
  58. package/src/style/svg/v6-terrain-on.svg +0 -7
  59. package/src/style/svg/v6-terrain.svg +0 -7
  60. package/src/style/svg/v6-zoom-minus.svg +0 -7
  61. package/src/style/svg/v6-zoom-plus.svg +0 -7
  62. package/src/tools.ts +0 -171
  63. package/src/unit.ts +0 -1
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
- <svg width="100%" height="100%" viewBox="0 0 33 33" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
4
- <g transform="matrix(1,0,0,1,7.99998,11)">
5
- <path d="M1.083,10.209C0.722,10.209 0.459,10.049 0.292,9.73C0.125,9.41 0.153,9.105 0.375,8.813L3.625,4.48C3.806,4.244 4.042,4.126 4.333,4.126C4.625,4.126 4.861,4.244 5.042,4.48L7.5,7.751C7.653,7.944 7.847,8.063 8.083,8.105C8.32,8.146 8.535,8.09 8.729,7.938C8.924,7.799 9.038,7.619 9.073,7.396C9.108,7.174 9.069,6.965 8.958,6.771L7.104,4.313L9.458,1.147C9.639,0.91 9.875,0.792 10.167,0.792C10.458,0.792 10.694,0.91 10.875,1.147L16.625,8.813C16.847,9.105 16.875,9.41 16.708,9.73C16.541,10.049 16.278,10.209 15.917,10.209L1.083,10.209Z" style="fill:rgb(68,73,82);fill-rule:nonzero;"/>
6
- </g>
7
- </svg>
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
- <svg width="100%" height="100%" viewBox="0 0 33 33" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
4
- <g transform="matrix(1,0,0,1,8.00023,11)">
5
- <path d="M1.083,10.209C0.722,10.209 0.458,10.049 0.292,9.73C0.125,9.41 0.153,9.105 0.375,8.813L3.625,4.48C3.805,4.244 4.041,4.126 4.333,4.126C4.625,4.126 4.861,4.244 5.042,4.48L8.021,8.459L14.167,8.459L10.167,3.147L8.188,5.751L7.104,4.313L9.458,1.147C9.638,0.91 9.875,0.792 10.167,0.792C10.458,0.792 10.694,0.91 10.875,1.147L16.625,8.813C16.847,9.105 16.874,9.41 16.708,9.73C16.541,10.049 16.277,10.209 15.917,10.209L1.083,10.209ZM2.833,8.459L5.833,8.459L4.333,6.459L2.833,8.459ZM2.833,8.459L5.833,8.459L2.833,8.459Z" style="fill:rgb(68,73,82);fill-rule:nonzero;"/>
6
- </g>
7
- </svg>
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
- <svg width="100%" height="100%" viewBox="0 0 33 33" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
4
- <g transform="matrix(1,0,0,1,9.5,15.25)">
5
- <path d="M1.475,2.225C1.212,2.225 0.984,2.128 0.79,1.935C0.597,1.741 0.5,1.513 0.5,1.25C0.5,0.987 0.597,0.759 0.79,0.566C0.984,0.372 1.212,0.275 1.475,0.275L12.525,0.275C12.788,0.275 13.016,0.372 13.21,0.566C13.403,0.759 13.5,0.987 13.5,1.25C13.5,1.513 13.403,1.741 13.21,1.935C13.016,2.128 12.788,2.225 12.525,2.225L1.475,2.225Z" style="fill:rgb(68,73,82);fill-rule:nonzero;"/>
6
- </g>
7
- </svg>
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
- <svg width="100%" height="100%" viewBox="0 0 33 33" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
4
- <g transform="matrix(1,0,0,1,9.5,9.25)">
5
- <path d="M7,13.75C6.737,13.75 6.509,13.653 6.315,13.46C6.122,13.266 6.025,13.038 6.025,12.775L6.025,8.225L1.475,8.225C1.212,8.225 0.984,8.128 0.79,7.935C0.597,7.741 0.5,7.513 0.5,7.25C0.5,6.987 0.597,6.759 0.79,6.565C0.984,6.372 1.212,6.275 1.475,6.275L6.025,6.275L6.025,1.725C6.025,1.462 6.122,1.234 6.315,1.04C6.509,0.847 6.737,0.75 7,0.75C7.263,0.75 7.491,0.847 7.685,1.04C7.878,1.234 7.975,1.462 7.975,1.725L7.975,6.275L12.525,6.275C12.788,6.275 13.016,6.372 13.21,6.565C13.403,6.759 13.5,6.987 13.5,7.25C13.5,7.513 13.403,7.741 13.21,7.935C13.016,8.128 12.788,8.225 12.525,8.225L7.975,8.225L7.975,12.775C7.975,13.038 7.878,13.266 7.685,13.46C7.491,13.653 7.263,13.75 7,13.75Z" style="fill:rgb(68,73,82);fill-rule:nonzero;"/>
6
- </g>
7
- </svg>
package/src/tools.ts DELETED
@@ -1,171 +0,0 @@
1
- import maplibregl from "maplibre-gl";
2
- import type {
3
- RequestParameters,
4
- ResourceType,
5
- RequestTransformFunction,
6
- } from "maplibre-gl";
7
- import { defaults } from "./defaults";
8
- import { config } from "./config";
9
- import { MAPTILER_SESSION_ID } from "./config";
10
-
11
- export function enableRTL() {
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- if (maplibregl.getRTLTextPluginStatus() === "unavailable") {
14
- maplibregl.setRTLTextPlugin(
15
- defaults.rtlPluginURL,
16
- (err?: Error | undefined) => {
17
- if (err) console.error(err);
18
- },
19
- true, // Lazy load the plugin
20
- );
21
- }
22
- }
23
-
24
- // This comes from:
25
- // https://github.com/maplibre/maplibre-gl-js/blob/v2.4.0/src/util/util.ts#L223
26
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
- export function bindAll(fns: Array<string>, context: any): void {
28
- fns.forEach((fn) => {
29
- if (typeof context[fn] !== "function") return;
30
- context[fn] = context[fn].bind(context);
31
- });
32
- }
33
-
34
- // This comes from:
35
- // https://github.com/maplibre/maplibre-gl-js/blob/v2.4.0/src/util/dom.ts#L22
36
- export function DOMcreate<K extends keyof HTMLElementTagNameMap>(
37
- tagName: K,
38
- className?: string,
39
- container?: HTMLElement,
40
- ): HTMLElementTagNameMap[K] {
41
- const el = window.document.createElement(tagName);
42
- if (className !== undefined) el.className = className;
43
- if (container) container.appendChild(el);
44
- return el;
45
- }
46
-
47
- // This comes from:
48
- // https://github.com/maplibre/maplibre-gl-js/blob/v2.4.0/src/util/dom.ts#L111
49
- export function DOMremove(node: HTMLElement) {
50
- if (node.parentNode) {
51
- node.parentNode.removeChild(node);
52
- }
53
- }
54
-
55
- /**
56
- * This function is meant to be used as transformRequest by any Map instance created.
57
- * It adds the session ID as well as the MapTiler Cloud key from the config to all the requests
58
- * performed on MapTiler Cloud servers.
59
- */
60
- export function maptilerCloudTransformRequest(
61
- url: string,
62
- // keep incase we need it in the future
63
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
64
- _resourceType?: ResourceType,
65
- ): RequestParameters {
66
- let reqUrl = null;
67
-
68
- try {
69
- // The URL is expected to be absolute.
70
- // Yet, if it's local we just return it without assuming a 'base' url (in the URL constructor)
71
- // and we let the URL be locally resolved with a potential base path.
72
- reqUrl = new URL(url);
73
- } catch (e) {
74
- return {
75
- url,
76
- };
77
- }
78
-
79
- if (reqUrl.host === defaults.maptilerApiHost) {
80
- if (!reqUrl.searchParams.has("key")) {
81
- reqUrl.searchParams.append("key", config.apiKey);
82
- }
83
-
84
- if (config.session) {
85
- reqUrl.searchParams.append("mtsid", MAPTILER_SESSION_ID);
86
- }
87
- }
88
-
89
- return {
90
- url: reqUrl.href,
91
- };
92
- }
93
-
94
- /**
95
- * This combines a user-defined tranformRequest function (optionnal)
96
- * with the MapTiler Cloud-specific one: maptilerCloudTransformRequest
97
- */
98
- export function combineTransformRequest(
99
- userDefinedRTF?: RequestTransformFunction,
100
- ): RequestTransformFunction {
101
- return function (
102
- url: string,
103
- resourceType?: ResourceType,
104
- ): RequestParameters {
105
- if (userDefinedRTF !== undefined) {
106
- const rp = userDefinedRTF(url, resourceType);
107
- const rp2 = maptilerCloudTransformRequest(rp?.url ?? "");
108
-
109
- return {
110
- ...rp,
111
- ...rp2,
112
- };
113
- } else {
114
- return maptilerCloudTransformRequest(url);
115
- }
116
- };
117
- }
118
-
119
- /**
120
- * Generate a random string. Handy to create random IDs
121
- */
122
- export function generateRandomString(): string {
123
- return Math.random().toString(36).substring(2);
124
- }
125
-
126
- /**
127
- * Check if a given string is in a uuid format
128
- */
129
- export function isUUID(s: string): boolean {
130
- // Regular expression to check if string is a valid UUID
131
- const regexExp =
132
- /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi;
133
- return regexExp.test(s);
134
- }
135
-
136
- /**
137
- * Attempt a JSON parse of a string but does not throw if the string is not valid JSON, returns `null` instead.
138
- */
139
- export function jsonParseNoThrow<T>(doc: string): T | null {
140
- try {
141
- return JSON.parse(doc);
142
- } catch (e) {
143
- // pass
144
- }
145
-
146
- return null;
147
- }
148
-
149
- /**
150
- * Simple function to check if an object is a GeoJSON
151
- */
152
- export function isValidGeoJSON<T>(obj: T & { type: string }): boolean {
153
- if (typeof obj !== "object" || Array.isArray(obj) || obj === null)
154
- return false;
155
- if (!("type" in obj)) return false;
156
-
157
- const validTypes = [
158
- "Feature",
159
- "FeatureCollection",
160
- "Point",
161
- "MultiPoint",
162
- "LineString",
163
- "MultiLineString",
164
- "Polygon",
165
- "MultiPolygon",
166
- "GeometryCollection",
167
- ];
168
-
169
- if (validTypes.includes(obj.type)) return true;
170
- return false;
171
- }
package/src/unit.ts DELETED
@@ -1 +0,0 @@
1
- export type Unit = "imperial" | "metric" | "nautical";