@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,11 +1,110 @@
1
- import maplibregl__default from 'maplibre-gl';
2
- export * from 'maplibre-gl';
1
+ import maplibregl, { addProtocol as addProtocol$1 } from 'maplibre-gl';
3
2
  import { Base64 } from 'js-base64';
4
3
  import EventEmitter from 'events';
5
- import { config as config$1, MapStyle, mapStylePresetList, expandMapStyle, MapStyleVariant, ReferenceMapStyle, geolocation } from '@maptiler/client';
4
+ import { config as config$2, MapStyle, mapStylePresetList, expandMapStyle, MapStyleVariant, ReferenceMapStyle, geolocation } from '@maptiler/client';
6
5
  export { LanguageGeocoding, MapStyle, MapStyleVariant, ReferenceMapStyle, ServiceError, bufferToPixelDataBrowser, circumferenceAtLatitude, coordinates, data, elevation, expandMapStyle, geocoding, geolocation, getAutoLanguageGeocoding, getBufferToPixelDataParser, getTileCache, mapStylePresetList, math, misc, staticMaps, styleToStyle } from '@maptiler/client';
7
6
  import { v4 } from 'uuid';
8
7
 
8
+ var name = "@maptiler/sdk";
9
+ var version = "2.0.0";
10
+ var description = "The Javascript & TypeScript map SDK tailored for MapTiler Cloud";
11
+ var module = "dist/maptiler-sdk.mjs";
12
+ var types = "dist/maptiler-sdk.d.ts";
13
+ var style = "dist/maptiler-sdk.css";
14
+ var type = "module";
15
+ var exports = {
16
+ ".": {
17
+ "import": "./dist/maptiler-sdk.mjs",
18
+ types: "./dist/maptiler-sdk.d.ts"
19
+ },
20
+ "./dist/maptiler-sdk.css": {
21
+ "import": "./dist/maptiler-sdk.css"
22
+ },
23
+ "./style.css": {
24
+ "import": "./dist/maptiler-sdk.css"
25
+ }
26
+ };
27
+ var keywords = [
28
+ "maptiler",
29
+ "map",
30
+ "sdk",
31
+ "webmap",
32
+ "cloud",
33
+ "webGL",
34
+ "maplibre"
35
+ ];
36
+ var homepage = "https://docs.maptiler.com/sdk-js/";
37
+ var license = "BSD-3-Clause";
38
+ var repository = {
39
+ type: "git",
40
+ url: "https://github.com/maptiler/maptiler-sdk-js.git"
41
+ };
42
+ var scripts = {
43
+ build: "rm -rf dist/* && NODE_ENV=production rollup -c",
44
+ dev: "rm -rf dist/* && NODE_ENV=development rollup -c -w",
45
+ "format:fix": "prettier --write \"src/**/*.{js,ts,tsx}\"",
46
+ format: "prettier -c \"src/**/*.{js,ts,tsx}\"",
47
+ "lint:fix": "eslint --fix \"src/**/*.{js,ts}\"",
48
+ lint: "eslint \"src/**/*.{js,ts}\"",
49
+ doc: "rm -rf docs/* && typedoc --out docs && cp -r images docs/",
50
+ prepare: "npm run format:fix && npm run lint:fix && npm run build && npm run test",
51
+ "test:dev": "vitest dev",
52
+ test: "vitest run"
53
+ };
54
+ var author = "MapTiler";
55
+ var devDependencies = {
56
+ "@rollup/plugin-commonjs": "^24.1.0",
57
+ "@rollup/plugin-json": "^6.0.0",
58
+ "@rollup/plugin-node-resolve": "^15.0.2",
59
+ "@types/uuid": "^9.0.2",
60
+ "@types/xmldom": "^0.1.31",
61
+ "@typescript-eslint/eslint-plugin": "^6.9.0",
62
+ "@typescript-eslint/parser": "^6.9.0",
63
+ eslint: "^8.52.0",
64
+ "eslint-config-prettier": "^9.0.0",
65
+ "eslint-plugin-prettier": "^5.0.1",
66
+ prettier: "^3.0.3",
67
+ rollup: "^3.20.6",
68
+ "rollup-plugin-copy-merge": "^1.0.0",
69
+ "rollup-plugin-dts": "^5.3.0",
70
+ "rollup-plugin-esbuild": "^5.0.0",
71
+ "rollup-plugin-node-globals": "^1.4.0",
72
+ "rollup-plugin-shell": "^1.0.9",
73
+ "rollup-plugin-string": "^3.0.0",
74
+ "rollup-plugin-swc": "^0.2.1",
75
+ serve: "^14.2.0",
76
+ terser: "^5.17.1",
77
+ typedoc: "^0.24.8",
78
+ typescript: "^5.1.6",
79
+ vitest: "^0.34.2",
80
+ xmldom: "^0.6.0"
81
+ };
82
+ var dependencies = {
83
+ "@maptiler/client": "^1.8.1",
84
+ events: "^3.3.0",
85
+ "js-base64": "^3.7.4",
86
+ "maplibre-gl": "4.1.2",
87
+ uuid: "^9.0.0"
88
+ };
89
+ var packagejson = {
90
+ name: name,
91
+ version: version,
92
+ description: description,
93
+ module: module,
94
+ types: types,
95
+ style: style,
96
+ type: type,
97
+ exports: exports,
98
+ keywords: keywords,
99
+ homepage: homepage,
100
+ license: license,
101
+ repository: repository,
102
+ scripts: scripts,
103
+ author: author,
104
+ devDependencies: devDependencies,
105
+ dependencies: dependencies
106
+ };
107
+
9
108
  const Language = {
10
109
  /**
11
110
  * The visitor language mode concatenates the prefered language from the user settings and the "default name".
@@ -160,10 +259,10 @@ const defaults = {
160
259
  };
161
260
  Object.freeze(defaults);
162
261
 
163
- var __defProp$b = Object.defineProperty;
164
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
165
- var __publicField$8 = (obj, key, value) => {
166
- __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
262
+ var __defProp$a = Object.defineProperty;
263
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
264
+ var __publicField$7 = (obj, key, value) => {
265
+ __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
167
266
  return value;
168
267
  };
169
268
  const MAPTILER_SESSION_ID = v4();
@@ -173,12 +272,12 @@ class SdkConfig extends EventEmitter {
173
272
  /**
174
273
  * The primary language. By default, the language of the web browser is used.
175
274
  */
176
- __publicField$8(this, "primaryLanguage", defaults.primaryLanguage);
275
+ __publicField$7(this, "primaryLanguage", defaults.primaryLanguage);
177
276
  /**
178
277
  * The secondary language, to overwrite the default language defined in the map style.
179
278
  * This settings is highly dependant on the style compatibility and may not work in most cases.
180
279
  */
181
- __publicField$8(this, "secondaryLanguage");
280
+ __publicField$7(this, "secondaryLanguage");
182
281
  /**
183
282
  * Setting on whether of not the SDK runs with a session logic.
184
283
  * A "session" is started at the initialization of the SDK and finished when the browser
@@ -186,15 +285,21 @@ class SdkConfig extends EventEmitter {
186
285
  * When `session` is enabled (default: true), the extra URL param `mtsid` is added to queries
187
286
  * on the MapTiler Cloud API. This allows MapTiler to enable "session based billing".
188
287
  */
189
- __publicField$8(this, "session", true);
288
+ __publicField$7(this, "session", true);
289
+ /**
290
+ * Enables client-side caching of requests for tiles and fonts.
291
+ * The cached requests persist multiple browser sessions and will be reused when possible.
292
+ * Works only for requests to the MapTiler Cloud API when sessions are enabled.
293
+ */
294
+ __publicField$7(this, "caching", true);
190
295
  /**
191
296
  * Unit to be used
192
297
  */
193
- __publicField$8(this, "_unit", "metric");
298
+ __publicField$7(this, "_unit", "metric");
194
299
  /**
195
300
  * MapTiler Cloud API key
196
301
  */
197
- __publicField$8(this, "_apiKey", "");
302
+ __publicField$7(this, "_apiKey", "");
198
303
  }
199
304
  /**
200
305
  * Set the unit system
@@ -214,7 +319,7 @@ class SdkConfig extends EventEmitter {
214
319
  */
215
320
  set apiKey(k) {
216
321
  this._apiKey = k;
217
- config$1.apiKey = k;
322
+ config$2.apiKey = k;
218
323
  this.emit("apiKey", k);
219
324
  }
220
325
  /**
@@ -227,35 +332,35 @@ class SdkConfig extends EventEmitter {
227
332
  * Set a the custom fetch function to replace the default one
228
333
  */
229
334
  set fetch(f) {
230
- config$1.fetch = f;
335
+ config$2.fetch = f;
231
336
  }
232
337
  /**
233
338
  * Get the fetch fucntion
234
339
  */
235
340
  get fetch() {
236
- return config$1.fetch;
341
+ return config$2.fetch;
237
342
  }
238
343
  }
239
- const config = new SdkConfig();
344
+ const config$1 = new SdkConfig();
240
345
 
241
- class LogoControl extends maplibregl__default.LogoControl {
346
+ class LogoControl extends maplibregl.LogoControl {
242
347
  onAdd(map) {
243
348
  return super.onAdd(map);
244
349
  }
245
350
  }
246
351
 
247
- var __defProp$a = Object.defineProperty;
248
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
249
- var __publicField$7 = (obj, key, value) => {
250
- __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
352
+ var __defProp$9 = Object.defineProperty;
353
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
354
+ var __publicField$6 = (obj, key, value) => {
355
+ __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
251
356
  return value;
252
357
  };
253
358
  class MaptilerLogoControl extends LogoControl {
254
359
  constructor(options = {}) {
255
360
  var _a, _b;
256
361
  super(options);
257
- __publicField$7(this, "logoURL", "");
258
- __publicField$7(this, "linkURL", "");
362
+ __publicField$6(this, "logoURL", "");
363
+ __publicField$6(this, "linkURL", "");
259
364
  this.logoURL = (_a = options.logoURL) != null ? _a : defaults.maptilerLogoURL;
260
365
  this.linkURL = (_b = options.linkURL) != null ? _b : defaults.maptilerURL;
261
366
  }
@@ -290,25 +395,151 @@ class MaptilerLogoControl extends LogoControl {
290
395
  }
291
396
  }
292
397
 
293
- var __defProp$9 = Object.defineProperty;
398
+ var __async$2 = (__this, __arguments, generator) => {
399
+ return new Promise((resolve, reject) => {
400
+ var fulfilled = (value) => {
401
+ try {
402
+ step(generator.next(value));
403
+ } catch (e) {
404
+ reject(e);
405
+ }
406
+ };
407
+ var rejected = (value) => {
408
+ try {
409
+ step(generator.throw(value));
410
+ } catch (e) {
411
+ reject(e);
412
+ }
413
+ };
414
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
415
+ step((generator = generator.apply(__this, __arguments)).next());
416
+ });
417
+ };
418
+ const LOCAL_CACHE_PROTOCOL_SOURCE = "localcache_source";
419
+ const LOCAL_CACHE_PROTOCOL_DATA = "localcache";
420
+ const LOCAL_CACHE_NAME = "maptiler_sdk";
421
+ const CACHE_LIMIT_ITEMS = 1e3;
422
+ const CACHE_LIMIT_CHECK_INTERVAL = 100;
423
+ function localCacheTransformRequest(reqUrl, resourceType) {
424
+ if (config$1.caching && config$1.session && reqUrl.host === defaults.maptilerApiHost) {
425
+ if (resourceType == "Source") {
426
+ return reqUrl.href.replace(
427
+ "https://",
428
+ `${LOCAL_CACHE_PROTOCOL_SOURCE}://`
429
+ );
430
+ } else if (resourceType == "Tile" || resourceType == "Glyphs") {
431
+ return reqUrl.href.replace("https://", `${LOCAL_CACHE_PROTOCOL_DATA}://`);
432
+ }
433
+ }
434
+ return reqUrl.href;
435
+ }
436
+ let cacheInstance;
437
+ function getCache() {
438
+ return __async$2(this, null, function* () {
439
+ if (!cacheInstance) {
440
+ cacheInstance = yield caches.open(LOCAL_CACHE_NAME);
441
+ }
442
+ return cacheInstance;
443
+ });
444
+ }
445
+ let cachePutCounter = 0;
446
+ function limitCache() {
447
+ return __async$2(this, null, function* () {
448
+ const cache = yield getCache();
449
+ const keys = yield cache.keys();
450
+ const toPurge = keys.slice(0, Math.max(keys.length - CACHE_LIMIT_ITEMS, 0));
451
+ for (const key of toPurge) {
452
+ cache.delete(key);
453
+ }
454
+ });
455
+ }
456
+ function registerLocalCacheProtocol() {
457
+ addProtocol$1(
458
+ LOCAL_CACHE_PROTOCOL_SOURCE,
459
+ (params, abortController) => __async$2(this, null, function* () {
460
+ if (!params.url)
461
+ throw new Error("");
462
+ params.url = params.url.replace(
463
+ `${LOCAL_CACHE_PROTOCOL_SOURCE}://`,
464
+ "https://"
465
+ );
466
+ const requestInit = params;
467
+ requestInit.signal = abortController.signal;
468
+ const response = yield fetch(params.url, requestInit);
469
+ const json = yield response.json();
470
+ json.tiles[0] += "&last-modified=" + response.headers.get("Last-Modified");
471
+ return {
472
+ data: json,
473
+ cacheControl: response.headers.get("Cache-Control"),
474
+ expires: response.headers.get("Expires")
475
+ };
476
+ })
477
+ );
478
+ addProtocol$1(
479
+ LOCAL_CACHE_PROTOCOL_DATA,
480
+ (params, abortController) => __async$2(this, null, function* () {
481
+ if (!params.url)
482
+ throw new Error("");
483
+ params.url = params.url.replace(
484
+ `${LOCAL_CACHE_PROTOCOL_DATA}://`,
485
+ "https://"
486
+ );
487
+ const url = new URL(params.url);
488
+ const cacheableUrl = new URL(url);
489
+ cacheableUrl.searchParams.delete("mtsid");
490
+ cacheableUrl.searchParams.delete("key");
491
+ const cacheKey = cacheableUrl.toString();
492
+ const fetchableUrl = new URL(url);
493
+ fetchableUrl.searchParams.delete("last-modified");
494
+ const fetchUrl = fetchableUrl.toString();
495
+ const respond = (response) => __async$2(this, null, function* () {
496
+ return {
497
+ data: yield response.arrayBuffer(),
498
+ cacheControl: response.headers.get("Cache-Control"),
499
+ expires: response.headers.get("Expires")
500
+ };
501
+ });
502
+ const cache = yield getCache();
503
+ const cacheMatch = yield cache.match(cacheKey);
504
+ if (cacheMatch) {
505
+ return respond(cacheMatch);
506
+ } else {
507
+ const requestInit = params;
508
+ requestInit.signal = abortController.signal;
509
+ const response = yield fetch(fetchUrl, requestInit);
510
+ if (response.status >= 200 && response.status < 300) {
511
+ cache.put(cacheKey, response.clone()).catch(() => {
512
+ });
513
+ if (++cachePutCounter > CACHE_LIMIT_CHECK_INTERVAL) {
514
+ limitCache();
515
+ cachePutCounter = 0;
516
+ }
517
+ }
518
+ return respond(response);
519
+ }
520
+ })
521
+ );
522
+ }
523
+
524
+ var __defProp$8 = Object.defineProperty;
294
525
  var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
295
526
  var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
296
527
  var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
297
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
528
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
298
529
  var __spreadValues$5 = (a, b) => {
299
530
  for (var prop in b || (b = {}))
300
531
  if (__hasOwnProp$5.call(b, prop))
301
- __defNormalProp$9(a, prop, b[prop]);
532
+ __defNormalProp$8(a, prop, b[prop]);
302
533
  if (__getOwnPropSymbols$5)
303
534
  for (var prop of __getOwnPropSymbols$5(b)) {
304
535
  if (__propIsEnum$5.call(b, prop))
305
- __defNormalProp$9(a, prop, b[prop]);
536
+ __defNormalProp$8(a, prop, b[prop]);
306
537
  }
307
538
  return a;
308
539
  };
309
540
  function enableRTL() {
310
- if (maplibregl__default.getRTLTextPluginStatus() === "unavailable") {
311
- maplibregl__default.setRTLTextPlugin(
541
+ if (maplibregl.getRTLTextPluginStatus() === "unavailable") {
542
+ maplibregl.setRTLTextPlugin(
312
543
  defaults.rtlPluginURL,
313
544
  (err) => {
314
545
  if (err)
@@ -339,7 +570,7 @@ function DOMremove(node) {
339
570
  node.parentNode.removeChild(node);
340
571
  }
341
572
  }
342
- function maptilerCloudTransformRequest(url, _resourceType) {
573
+ function maptilerCloudTransformRequest(url, resourceType) {
343
574
  let reqUrl = null;
344
575
  try {
345
576
  reqUrl = new URL(url);
@@ -350,14 +581,14 @@ function maptilerCloudTransformRequest(url, _resourceType) {
350
581
  }
351
582
  if (reqUrl.host === defaults.maptilerApiHost) {
352
583
  if (!reqUrl.searchParams.has("key")) {
353
- reqUrl.searchParams.append("key", config.apiKey);
584
+ reqUrl.searchParams.append("key", config$1.apiKey);
354
585
  }
355
- if (config.session) {
586
+ if (config$1.session) {
356
587
  reqUrl.searchParams.append("mtsid", MAPTILER_SESSION_ID);
357
588
  }
358
589
  }
359
590
  return {
360
- url: reqUrl.href
591
+ url: localCacheTransformRequest(reqUrl, resourceType)
361
592
  };
362
593
  }
363
594
  function combineTransformRequest(userDefinedRTF) {
@@ -365,10 +596,10 @@ function combineTransformRequest(userDefinedRTF) {
365
596
  var _a;
366
597
  if (userDefinedRTF !== void 0) {
367
598
  const rp = userDefinedRTF(url, resourceType);
368
- const rp2 = maptilerCloudTransformRequest((_a = rp == null ? void 0 : rp.url) != null ? _a : "");
599
+ const rp2 = maptilerCloudTransformRequest((_a = rp == null ? void 0 : rp.url) != null ? _a : "", resourceType);
369
600
  return __spreadValues$5(__spreadValues$5({}, rp), rp2);
370
601
  } else {
371
- return maptilerCloudTransformRequest(url);
602
+ return maptilerCloudTransformRequest(url, resourceType);
372
603
  }
373
604
  };
374
605
  }
@@ -407,17 +638,17 @@ function styleToStyle(style) {
407
638
  return style;
408
639
  }
409
640
 
410
- var __defProp$8 = Object.defineProperty;
411
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
412
- var __publicField$6 = (obj, key, value) => {
413
- __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
641
+ var __defProp$7 = Object.defineProperty;
642
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
643
+ var __publicField$5 = (obj, key, value) => {
644
+ __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
414
645
  return value;
415
646
  };
416
647
  class MaptilerTerrainControl {
417
648
  constructor() {
418
- __publicField$6(this, "_map");
419
- __publicField$6(this, "_container");
420
- __publicField$6(this, "_terrainButton");
649
+ __publicField$5(this, "_map");
650
+ __publicField$5(this, "_container");
651
+ __publicField$5(this, "_terrainButton");
421
652
  bindAll(["_toggleTerrain", "_updateTerrainIcon"], this);
422
653
  }
423
654
  onAdd(map) {
@@ -457,27 +688,27 @@ class MaptilerTerrainControl {
457
688
  if (this._map.hasTerrain()) {
458
689
  this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled");
459
690
  this._terrainButton.title = this._map._getUIString(
460
- "TerrainControl.disableTerrain"
691
+ "TerrainControl.Disable"
461
692
  );
462
693
  } else {
463
694
  this._terrainButton.classList.add("maplibregl-ctrl-terrain");
464
695
  this._terrainButton.title = this._map._getUIString(
465
- "TerrainControl.enableTerrain"
696
+ "TerrainControl.Enable"
466
697
  );
467
698
  }
468
699
  }
469
700
  }
470
701
 
471
- class NavigationControl extends maplibregl__default.NavigationControl {
702
+ class NavigationControl extends maplibregl.NavigationControl {
472
703
  onAdd(map) {
473
704
  return super.onAdd(map);
474
705
  }
475
706
  }
476
707
 
477
- var __defProp$7 = Object.defineProperty;
478
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
479
- var __publicField$5 = (obj, key, value) => {
480
- __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
708
+ var __defProp$6 = Object.defineProperty;
709
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
710
+ var __publicField$4 = (obj, key, value) => {
711
+ __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
481
712
  return value;
482
713
  };
483
714
  class MaptilerNavigationControl extends NavigationControl {
@@ -490,7 +721,7 @@ class MaptilerNavigationControl extends NavigationControl {
490
721
  /**
491
722
  * Overloading: Limit how flat the compass icon can get
492
723
  */
493
- __publicField$5(this, "_rotateCompassArrow", () => {
724
+ __publicField$4(this, "_rotateCompassArrow", () => {
494
725
  const rotate = this.options.visualizePitch ? `scale(${Math.min(
495
726
  1.5,
496
727
  1 / Math.pow(
@@ -529,49 +760,49 @@ class MaptilerNavigationControl extends NavigationControl {
529
760
  }
530
761
  }
531
762
 
532
- class GeolocateControl extends maplibregl__default.GeolocateControl {
763
+ class GeolocateControl extends maplibregl.GeolocateControl {
533
764
  onAdd(map) {
534
765
  return super.onAdd(map);
535
766
  }
536
767
  }
537
768
 
538
- var __defProp$6 = Object.defineProperty;
769
+ var __defProp$5 = Object.defineProperty;
539
770
  var __defProps$3 = Object.defineProperties;
540
771
  var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
541
772
  var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
542
773
  var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
543
774
  var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
544
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
775
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
545
776
  var __spreadValues$4 = (a, b) => {
546
777
  for (var prop in b || (b = {}))
547
778
  if (__hasOwnProp$4.call(b, prop))
548
- __defNormalProp$6(a, prop, b[prop]);
779
+ __defNormalProp$5(a, prop, b[prop]);
549
780
  if (__getOwnPropSymbols$4)
550
781
  for (var prop of __getOwnPropSymbols$4(b)) {
551
782
  if (__propIsEnum$4.call(b, prop))
552
- __defNormalProp$6(a, prop, b[prop]);
783
+ __defNormalProp$5(a, prop, b[prop]);
553
784
  }
554
785
  return a;
555
786
  };
556
787
  var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
557
- var __publicField$4 = (obj, key, value) => {
558
- __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
788
+ var __publicField$3 = (obj, key, value) => {
789
+ __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
559
790
  return value;
560
791
  };
561
- const Marker$1 = maplibregl__default.Marker;
562
- const LngLat$1 = maplibregl__default.LngLat;
563
- const LngLatBounds$1 = maplibregl__default.LngLatBounds;
792
+ const Marker$1 = maplibregl.Marker;
793
+ const LngLat$1 = maplibregl.LngLat;
794
+ const LngLatBounds$1 = maplibregl.LngLatBounds;
564
795
  class MaptilerGeolocateControl extends GeolocateControl {
565
796
  constructor() {
566
797
  super(...arguments);
567
- __publicField$4(this, "lastUpdatedCenter", new LngLat$1(0, 0));
798
+ __publicField$3(this, "lastUpdatedCenter", new LngLat$1(0, 0));
568
799
  /**
569
800
  * Update the camera location to center on the current position
570
801
  *
571
802
  * @param {Position} position the Geolocation API Position
572
803
  * @private
573
804
  */
574
- __publicField$4(this, "_updateCamera", (position) => {
805
+ __publicField$3(this, "_updateCamera", (position) => {
575
806
  var _a, _b, _c;
576
807
  const center = new LngLat$1(
577
808
  position.coords.longitude,
@@ -615,7 +846,7 @@ class MaptilerGeolocateControl extends GeolocateControl {
615
846
  this.lastUpdatedCenter = this._map.getCenter();
616
847
  });
617
848
  });
618
- __publicField$4(this, "_setupUI", (supported) => {
849
+ __publicField$3(this, "_setupUI", (supported) => {
619
850
  this.lastUpdatedCenter = this._map.getCenter();
620
851
  this._container.addEventListener(
621
852
  "contextmenu",
@@ -684,7 +915,7 @@ class MaptilerGeolocateControl extends GeolocateControl {
684
915
  });
685
916
  }
686
917
  });
687
- __publicField$4(this, "_onZoom", () => {
918
+ __publicField$3(this, "_onZoom", () => {
688
919
  if (this.options.showUserLocation && this.options.showAccuracyCircle) {
689
920
  this._updateCircleRadius();
690
921
  }
@@ -711,45 +942,45 @@ class MaptilerGeolocateControl extends GeolocateControl {
711
942
  }
712
943
  }
713
944
 
714
- class AttributionControl extends maplibregl__default.AttributionControl {
945
+ class AttributionControl extends maplibregl.AttributionControl {
715
946
  onAdd(map) {
716
947
  return super.onAdd(map);
717
948
  }
718
949
  }
719
950
 
720
- class ScaleControl extends maplibregl__default.ScaleControl {
951
+ class ScaleControl extends maplibregl.ScaleControl {
721
952
  onAdd(map) {
722
953
  return super.onAdd(map);
723
954
  }
724
955
  }
725
956
 
726
- class FullscreenControl extends maplibregl__default.FullscreenControl {
957
+ class FullscreenControl extends maplibregl.FullscreenControl {
727
958
  onAdd(map) {
728
959
  return super.onAdd(map);
729
960
  }
730
961
  }
731
962
 
732
- var __defProp$5 = Object.defineProperty;
963
+ var __defProp$4 = Object.defineProperty;
733
964
  var __defProps$2 = Object.defineProperties;
734
965
  var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
735
966
  var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
736
967
  var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
737
968
  var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
738
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
969
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
739
970
  var __spreadValues$3 = (a, b) => {
740
971
  for (var prop in b || (b = {}))
741
972
  if (__hasOwnProp$3.call(b, prop))
742
- __defNormalProp$5(a, prop, b[prop]);
973
+ __defNormalProp$4(a, prop, b[prop]);
743
974
  if (__getOwnPropSymbols$3)
744
975
  for (var prop of __getOwnPropSymbols$3(b)) {
745
976
  if (__propIsEnum$3.call(b, prop))
746
- __defNormalProp$5(a, prop, b[prop]);
977
+ __defNormalProp$4(a, prop, b[prop]);
747
978
  }
748
979
  return a;
749
980
  };
750
981
  var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
751
- var __publicField$3 = (obj, key, value) => {
752
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
982
+ var __publicField$2 = (obj, key, value) => {
983
+ __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
753
984
  return value;
754
985
  };
755
986
  var __accessCheck = (obj, member, msg) => {
@@ -781,7 +1012,7 @@ class Minimap {
781
1012
  __privateAdd(this, _setParentBounds);
782
1013
  __privateAdd(this, _syncMaps);
783
1014
  __privateAdd(this, _options, void 0);
784
- __publicField$3(this, "map");
1015
+ __publicField$2(this, "map");
785
1016
  __privateAdd(this, _parentMap, void 0);
786
1017
  __privateAdd(this, _container, void 0);
787
1018
  __privateAdd(this, _canvasContainer, void 0);
@@ -1013,27 +1244,27 @@ syncMaps_fn = function() {
1013
1244
  };
1014
1245
  };
1015
1246
 
1016
- var __defProp$4 = Object.defineProperty;
1247
+ var __defProp$3 = Object.defineProperty;
1017
1248
  var __defProps$1 = Object.defineProperties;
1018
1249
  var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
1019
1250
  var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
1020
1251
  var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
1021
1252
  var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
1022
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1253
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1023
1254
  var __spreadValues$2 = (a, b) => {
1024
1255
  for (var prop in b || (b = {}))
1025
1256
  if (__hasOwnProp$2.call(b, prop))
1026
- __defNormalProp$4(a, prop, b[prop]);
1257
+ __defNormalProp$3(a, prop, b[prop]);
1027
1258
  if (__getOwnPropSymbols$2)
1028
1259
  for (var prop of __getOwnPropSymbols$2(b)) {
1029
1260
  if (__propIsEnum$2.call(b, prop))
1030
- __defNormalProp$4(a, prop, b[prop]);
1261
+ __defNormalProp$3(a, prop, b[prop]);
1031
1262
  }
1032
1263
  return a;
1033
1264
  };
1034
1265
  var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
1035
- var __publicField$2 = (obj, key, value) => {
1036
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
1266
+ var __publicField$1 = (obj, key, value) => {
1267
+ __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
1037
1268
  return value;
1038
1269
  };
1039
1270
  var __async$1 = (__this, __arguments, generator) => {
@@ -1060,15 +1291,15 @@ const GeolocationType = {
1060
1291
  POINT: "POINT",
1061
1292
  COUNTRY: "COUNTRY"
1062
1293
  };
1063
- class Map extends maplibregl__default.Map {
1294
+ class Map extends maplibregl.Map {
1064
1295
  constructor(options) {
1065
1296
  var _a, _b, _c;
1066
1297
  if (options.apiKey) {
1067
- config.apiKey = options.apiKey;
1298
+ config$1.apiKey = options.apiKey;
1068
1299
  }
1069
1300
  const style = styleToStyle(options.style);
1070
1301
  const hashPreConstructor = location.hash;
1071
- if (!config.apiKey) {
1302
+ if (!config$1.apiKey) {
1072
1303
  console.warn(
1073
1304
  "MapTiler Cloud API key is not set. Visit https://maptiler.com and try Cloud for free!"
1074
1305
  );
@@ -1078,16 +1309,19 @@ class Map extends maplibregl__default.Map {
1078
1309
  maplibreLogo: false,
1079
1310
  transformRequest: combineTransformRequest(options.transformRequest)
1080
1311
  }));
1081
- __publicField$2(this, "isTerrainEnabled", false);
1082
- __publicField$2(this, "terrainExaggeration", 1);
1083
- __publicField$2(this, "primaryLanguage");
1084
- __publicField$2(this, "terrainGrowing", false);
1085
- __publicField$2(this, "terrainFlattening", false);
1086
- __publicField$2(this, "minimap");
1087
- __publicField$2(this, "forceLanguageUpdate");
1088
- __publicField$2(this, "languageAlwaysBeenStyle");
1089
- __publicField$2(this, "isReady", false);
1090
- this.primaryLanguage = (_a = options.language) != null ? _a : config.primaryLanguage;
1312
+ __publicField$1(this, "isTerrainEnabled", false);
1313
+ __publicField$1(this, "terrainExaggeration", 1);
1314
+ __publicField$1(this, "primaryLanguage");
1315
+ __publicField$1(this, "terrainGrowing", false);
1316
+ __publicField$1(this, "terrainFlattening", false);
1317
+ __publicField$1(this, "minimap");
1318
+ __publicField$1(this, "forceLanguageUpdate");
1319
+ __publicField$1(this, "languageAlwaysBeenStyle");
1320
+ __publicField$1(this, "isReady", false);
1321
+ if (config$1.caching) {
1322
+ registerLocalCacheProtocol();
1323
+ }
1324
+ this.primaryLanguage = (_a = options.language) != null ? _a : config$1.primaryLanguage;
1091
1325
  this.forceLanguageUpdate = this.primaryLanguage === Language.STYLE || this.primaryLanguage === Language.STYLE_LOCK ? false : true;
1092
1326
  this.languageAlwaysBeenStyle = this.primaryLanguage === Language.STYLE;
1093
1327
  this.terrainExaggeration = (_b = options.terrainExaggeration) != null ? _b : this.terrainExaggeration;
@@ -1176,7 +1410,7 @@ class Map extends maplibregl__default.Map {
1176
1410
  possibleSources[0].url
1177
1411
  );
1178
1412
  if (!styleUrl.searchParams.has("key")) {
1179
- styleUrl.searchParams.append("key", config.apiKey);
1413
+ styleUrl.searchParams.append("key", config$1.apiKey);
1180
1414
  }
1181
1415
  const tileJsonRes = yield fetch(styleUrl.href);
1182
1416
  tileJsonContent = yield tileJsonRes.json();
@@ -1202,9 +1436,9 @@ class Map extends maplibregl__default.Map {
1202
1436
  }
1203
1437
  if (options.scaleControl) {
1204
1438
  const position = options.scaleControl === true || options.scaleControl === void 0 ? "bottom-right" : options.scaleControl;
1205
- const scaleControl = new ScaleControl({ unit: config.unit });
1439
+ const scaleControl = new ScaleControl({ unit: config$1.unit });
1206
1440
  this.addControl(scaleControl, position);
1207
- config.on("unit", (unit) => {
1441
+ config$1.on("unit", (unit) => {
1208
1442
  scaleControl.setUnit(unit);
1209
1443
  });
1210
1444
  }
@@ -1675,7 +1909,23 @@ class Map extends maplibregl__default.Map {
1675
1909
  ];
1676
1910
  }
1677
1911
  const { layers } = this.getStyle();
1678
- for (const { id, layout } of layers) {
1912
+ for (const genericLayer of layers) {
1913
+ if (genericLayer.type !== "symbol") {
1914
+ continue;
1915
+ }
1916
+ const layer = genericLayer;
1917
+ const source = this.getSource(layer.source);
1918
+ if (!source) {
1919
+ continue;
1920
+ }
1921
+ if (!("url" in source && typeof source.url === "string")) {
1922
+ continue;
1923
+ }
1924
+ const sourceURL = new URL(source.url);
1925
+ if (sourceURL.host !== defaults.maptilerApiHost) {
1926
+ continue;
1927
+ }
1928
+ const { id, layout } = layer;
1679
1929
  if (!layout) {
1680
1930
  continue;
1681
1931
  }
@@ -1907,7 +2157,7 @@ class Map extends maplibregl__default.Map {
1907
2157
  * that do not directly have access to the SDK configuration but do have access to a Map instance.
1908
2158
  */
1909
2159
  getSdkConfig() {
1910
- return config;
2160
+ return config$1;
1911
2161
  }
1912
2162
  /**
1913
2163
  * Get the MapTiler session ID. Convenient to dispatch to externaly built component
@@ -1932,383 +2182,119 @@ class Map extends maplibregl__default.Map {
1932
2182
  super.setTransformRequest(combineTransformRequest(transformRequest));
1933
2183
  return this;
1934
2184
  }
1935
- /**
1936
- * Loads an image. This is an async equivalent of `Map.loadImage`
1937
- */
1938
- loadImageAsync(url) {
1939
- return __async$1(this, null, function* () {
1940
- return new Promise((resolve, reject) => {
1941
- this.loadImage(
1942
- url,
1943
- (error, image) => {
1944
- if (error) {
1945
- reject(error);
1946
- return;
1947
- }
1948
- resolve(image);
1949
- }
1950
- );
1951
- });
1952
- });
1953
- }
1954
2185
  }
1955
2186
 
1956
- class Marker extends maplibregl__default.Marker {
2187
+ class Marker extends maplibregl.Marker {
1957
2188
  addTo(map) {
1958
2189
  return super.addTo(map);
1959
2190
  }
1960
2191
  }
1961
2192
 
1962
- class Popup extends maplibregl__default.Popup {
2193
+ class Popup extends maplibregl.Popup {
1963
2194
  addTo(map) {
1964
2195
  return super.addTo(map);
1965
2196
  }
1966
2197
  }
1967
2198
 
1968
- class Style extends maplibregl__default.Style {
2199
+ class Style extends maplibregl.Style {
1969
2200
  constructor(map, options = {}) {
1970
2201
  super(map, options);
1971
2202
  }
1972
2203
  }
1973
2204
 
1974
- class CanvasSource extends maplibregl__default.CanvasSource {
2205
+ class CanvasSource extends maplibregl.CanvasSource {
1975
2206
  onAdd(map) {
1976
2207
  super.onAdd(map);
1977
2208
  }
1978
2209
  }
1979
2210
 
1980
- class GeoJSONSource extends maplibregl__default.GeoJSONSource {
2211
+ class GeoJSONSource extends maplibregl.GeoJSONSource {
1981
2212
  onAdd(map) {
1982
2213
  super.onAdd(map);
1983
2214
  }
1984
2215
  }
1985
2216
 
1986
- class ImageSource extends maplibregl__default.ImageSource {
2217
+ class ImageSource extends maplibregl.ImageSource {
1987
2218
  onAdd(map) {
1988
2219
  super.onAdd(map);
1989
2220
  }
1990
2221
  }
1991
2222
 
1992
- class RasterTileSource extends maplibregl__default.RasterTileSource {
2223
+ class RasterTileSource extends maplibregl.RasterTileSource {
1993
2224
  onAdd(map) {
1994
2225
  super.onAdd(map);
1995
2226
  }
1996
2227
  }
1997
2228
 
1998
- class RasterDEMTileSource extends maplibregl__default.RasterDEMTileSource {
2229
+ class RasterDEMTileSource extends maplibregl.RasterDEMTileSource {
1999
2230
  onAdd(map) {
2000
2231
  super.onAdd(map);
2001
2232
  }
2002
2233
  }
2003
2234
 
2004
- class VectorTileSource extends maplibregl__default.VectorTileSource {
2235
+ class VectorTileSource extends maplibregl.VectorTileSource {
2005
2236
  onAdd(map) {
2006
2237
  super.onAdd(map);
2007
2238
  }
2008
2239
  }
2009
2240
 
2010
- class VideoSource extends maplibregl__default.VideoSource {
2241
+ class VideoSource extends maplibregl.VideoSource {
2011
2242
  onAdd(map) {
2012
2243
  super.onAdd(map);
2013
2244
  }
2014
2245
  }
2015
2246
 
2016
- class TerrainControl extends maplibregl__default.TerrainControl {
2247
+ class TerrainControl extends maplibregl.TerrainControl {
2017
2248
  onAdd(map) {
2018
2249
  return super.onAdd(map);
2019
2250
  }
2020
2251
  }
2021
2252
 
2022
- var __defProp$3 = Object.defineProperty;
2023
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2024
- var __publicField$1 = (obj, key, value) => {
2025
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
2026
- return value;
2027
- };
2028
- class Point {
2029
- constructor(x, y) {
2030
- __publicField$1(this, "x");
2031
- __publicField$1(this, "y");
2032
- this.x = x;
2033
- this.y = y;
2034
- }
2035
- _matMult(m) {
2036
- const x = m[0] * this.x + m[1] * this.y;
2037
- const y = m[2] * this.x + m[3] * this.y;
2038
- this.x = x;
2039
- this.y = y;
2040
- return this;
2041
- }
2042
- _add(p) {
2043
- this.x += p.x;
2044
- this.y += p.y;
2045
- return this;
2046
- }
2047
- _sub(p) {
2048
- this.x -= p.x;
2049
- this.y -= p.y;
2050
- return this;
2051
- }
2052
- _mult(k) {
2053
- this.x *= k;
2054
- this.y *= k;
2055
- return this;
2056
- }
2057
- _div(k) {
2058
- this.x /= k;
2059
- this.y /= k;
2060
- return this;
2061
- }
2062
- _multByPoint(p) {
2063
- this.x *= p.x;
2064
- this.y *= p.y;
2065
- return this;
2066
- }
2067
- _divByPoint(p) {
2068
- this.x /= p.x;
2069
- this.y /= p.y;
2070
- return this;
2071
- }
2072
- _unit() {
2073
- this._div(this.mag());
2074
- return this;
2075
- }
2076
- _perp() {
2077
- const y = this.y;
2078
- this.y = this.x;
2079
- this.x = -y;
2080
- return this;
2081
- }
2082
- _rotate(angle) {
2083
- const cos = Math.cos(angle);
2084
- const sin = Math.sin(angle);
2085
- const x = cos * this.x - sin * this.y;
2086
- const y = sin * this.x + cos * this.y;
2087
- this.x = x;
2088
- this.y = y;
2089
- return this;
2090
- }
2091
- _rotateAround(angle, p) {
2092
- const cos = Math.cos(angle);
2093
- const sin = Math.sin(angle);
2094
- const x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y);
2095
- const y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);
2096
- this.x = x;
2097
- this.y = y;
2098
- return this;
2099
- }
2100
- _round() {
2101
- this.x = Math.round(this.x);
2102
- this.y = Math.round(this.y);
2103
- return this;
2104
- }
2105
- /**
2106
- * Clone this point, returning a new point that can be modified
2107
- * without affecting the old one.
2108
- * @return {Point} the clone
2109
- */
2110
- clone() {
2111
- return new Point(this.x, this.y);
2112
- }
2113
- /**
2114
- * Add this point's x & y coordinates to another point,
2115
- * yielding a new point.
2116
- * @param {Point} p the other point
2117
- * @return {Point} output point
2118
- */
2119
- add(p) {
2120
- return this.clone()._add(p);
2121
- }
2122
- /**
2123
- * Subtract this point's x & y coordinates to from point,
2124
- * yielding a new point.
2125
- * @param {Point} p the other point
2126
- * @return {Point} output point
2127
- */
2128
- sub(p) {
2129
- return this.clone()._sub(p);
2130
- }
2131
- /**
2132
- * Multiply this point's x & y coordinates by point,
2133
- * yielding a new point.
2134
- * @param {Point} p the other point
2135
- * @return {Point} output point
2136
- */
2137
- multByPoint(p) {
2138
- return this.clone()._multByPoint(p);
2139
- }
2140
- /**
2141
- * Divide this point's x & y coordinates by point,
2142
- * yielding a new point.
2143
- * @param {Point} p the other point
2144
- * @return {Point} output point
2145
- */
2146
- divByPoint(p) {
2147
- return this.clone()._divByPoint(p);
2148
- }
2149
- /**
2150
- * Multiply this point's x & y coordinates by a factor,
2151
- * yielding a new point.
2152
- * @param {Number} k factor
2153
- * @return {Point} output point
2154
- */
2155
- mult(k) {
2156
- return this.clone()._mult(k);
2157
- }
2158
- /**
2159
- * Divide this point's x & y coordinates by a factor,
2160
- * yielding a new point.
2161
- * @param {Point} k factor
2162
- * @return {Point} output point
2163
- */
2164
- div(k) {
2165
- return this.clone()._div(k);
2166
- }
2167
- /**
2168
- * Rotate this point around the 0, 0 origin by an angle a,
2169
- * given in radians
2170
- * @param {Number} a angle to rotate around, in radians
2171
- * @return {Point} output point
2172
- */
2173
- rotate(a) {
2174
- return this.clone()._rotate(a);
2175
- }
2176
- /**
2177
- * Rotate this point around p point by an angle a,
2178
- * given in radians
2179
- * @param {Number} a angle to rotate around, in radians
2180
- * @param {Point} p Point to rotate around
2181
- * @return {Point} output point
2182
- */
2183
- rotateAround(a, p) {
2184
- return this.clone()._rotateAround(a, p);
2185
- }
2186
- /**
2187
- * Multiply this point by a 4x1 transformation matrix
2188
- * @param {Array<Number>} m transformation matrix
2189
- * @return {Point} output point
2190
- */
2191
- matMult(m) {
2192
- return this.clone()._matMult(m);
2193
- }
2194
- /**
2195
- * Calculate this point but as a unit vector from 0, 0, meaning
2196
- * that the distance from the resulting point to the 0, 0
2197
- * coordinate will be equal to 1 and the angle from the resulting
2198
- * point to the 0, 0 coordinate will be the same as before.
2199
- * @return {Point} unit vector point
2200
- */
2201
- unit() {
2202
- return this.clone()._unit();
2203
- }
2204
- /**
2205
- * Compute a perpendicular point, where the new y coordinate
2206
- * is the old x coordinate and the new x coordinate is the old y
2207
- * coordinate multiplied by -1
2208
- * @return {Point} perpendicular point
2209
- */
2210
- perp() {
2211
- return this.clone()._perp();
2212
- }
2213
- /**
2214
- * Return a version of this point with the x & y coordinates
2215
- * rounded to integers.
2216
- * @return {Point} rounded point
2217
- */
2218
- round() {
2219
- return this.clone()._round();
2220
- }
2221
- /**
2222
- * Return the magnitude of this point: this is the Euclidean
2223
- * distance from the 0, 0 coordinate to this point's x and y
2224
- * coordinates.
2225
- * @return {Number} magnitude
2226
- */
2227
- mag() {
2228
- return Math.sqrt(this.x * this.x + this.y * this.y);
2253
+ class BoxZoomHandler extends maplibregl.BoxZoomHandler {
2254
+ constructor(map, options) {
2255
+ super(map, options);
2229
2256
  }
2230
- /**
2231
- * Judge whether this point is equal to another point, returning
2232
- * true or false.
2233
- * @param {Point} other the other point
2234
- * @return {boolean} whether the points are equal
2235
- */
2236
- equals(other) {
2237
- return this.x === other.x && this.y === other.y;
2257
+ }
2258
+
2259
+ class ScrollZoomHandler extends maplibregl.ScrollZoomHandler {
2260
+ constructor(map, triggerRenderFrame) {
2261
+ super(map, triggerRenderFrame);
2238
2262
  }
2239
- /**
2240
- * Calculate the distance from this point to another point
2241
- * @param {Point} p the other point
2242
- * @return {Number} distance
2243
- */
2244
- dist(p) {
2245
- return Math.sqrt(this.distSqr(p));
2263
+ }
2264
+
2265
+ class CooperativeGesturesHandler extends maplibregl.CooperativeGesturesHandler {
2266
+ constructor(map, options) {
2267
+ super(map, options);
2246
2268
  }
2247
- /**
2248
- * Calculate the distance from this point to another point,
2249
- * without the square root step. Useful if you're comparing
2250
- * relative distances.
2251
- * @param {Point} p the other point
2252
- * @return {Number} distance
2253
- */
2254
- distSqr(p) {
2255
- const dx = p.x - this.x;
2256
- const dy = p.y - this.y;
2257
- return dx * dx + dy * dy;
2269
+ }
2270
+
2271
+ class KeyboardHandler extends maplibregl.KeyboardHandler {
2272
+ constructor(map) {
2273
+ super(map);
2258
2274
  }
2259
- /**
2260
- * Get the angle from the 0, 0 coordinate to this point, in radians
2261
- * coordinates.
2262
- * @return {Number} angle
2263
- */
2264
- angle() {
2265
- return Math.atan2(this.y, this.x);
2275
+ }
2276
+
2277
+ class TwoFingersTouchPitchHandler extends maplibregl.TwoFingersTouchPitchHandler {
2278
+ constructor(map) {
2279
+ super(map);
2266
2280
  }
2267
- /**
2268
- * Get the angle from this point to another point, in radians
2269
- * @param {Point} b the other point
2270
- * @return {Number} angle
2271
- */
2272
- angleTo(b) {
2273
- return Math.atan2(this.y - b.y, this.x - b.x);
2281
+ }
2282
+
2283
+ class MapWheelEvent extends maplibregl.MapWheelEvent {
2284
+ constructor(type, map, originalEvent) {
2285
+ super(type, map, originalEvent);
2274
2286
  }
2275
- /**
2276
- * Get the angle between this point and another point, in radians
2277
- * @param {Point} b the other point
2278
- * @return {Number} angle
2279
- */
2280
- angleWith(b) {
2281
- return this.angleWithSep(b.x, b.y);
2282
- }
2283
- /*
2284
- * Find the angle of the two vectors, solving the formula for
2285
- * the cross product a x b = |a||b|sin(θ) for θ.
2286
- * @param {Number} x the x-coordinate
2287
- * @param {Number} y the y-coordinate
2288
- * @return {Number} the angle in radians
2289
- */
2290
- angleWithSep(x, y) {
2291
- return Math.atan2(this.x * y - this.y * x, this.x * x + this.y * y);
2287
+ }
2288
+
2289
+ class MapTouchEvent extends maplibregl.MapTouchEvent {
2290
+ constructor(type, map, originalEvent) {
2291
+ super(type, map, originalEvent);
2292
2292
  }
2293
- /**
2294
- * Construct a point from an array if necessary, otherwise if the input
2295
- * is already a Point, or an unknown type, return it unchanged
2296
- * @param {Array<number> | Point} a any kind of input value
2297
- * @return {Point} constructed point, or passed-through value.
2298
- * @example
2299
- * // this
2300
- * var point = Point.convert([0, 1]);
2301
- * // is equivalent to
2302
- * var point = new Point(0, 1);
2303
- */
2304
- static convert(a) {
2305
- if (a instanceof Point) {
2306
- return a;
2307
- }
2308
- if (Array.isArray(a)) {
2309
- return new Point(a[0], a[1]);
2310
- }
2311
- return a;
2293
+ }
2294
+
2295
+ class MapMouseEvent extends maplibregl.MapMouseEvent {
2296
+ constructor(type, map, originalEvent, data = {}) {
2297
+ super(type, map, originalEvent, data);
2312
2298
  }
2313
2299
  }
2314
2300
 
@@ -4223,7 +4209,7 @@ function addPolyline(_0, _1) {
4223
4209
  let data = options.data;
4224
4210
  if (typeof data === "string") {
4225
4211
  if (isUUID(data)) {
4226
- data = `https://api.maptiler.com/data/${options.data}/features.json?key=${config.apiKey}`;
4212
+ data = `https://api.maptiler.com/data/${options.data}/features.json?key=${config$1.apiKey}`;
4227
4213
  } else if (((_a = data.split(".").pop()) == null ? void 0 : _a.toLowerCase().trim()) === "gpx") {
4228
4214
  const res = yield fetch(data, fetchOptions);
4229
4215
  const gpxStr = yield res.text();
@@ -4347,7 +4333,7 @@ function addPolygon(map, options) {
4347
4333
  if (options.data && !map.getSource(sourceId)) {
4348
4334
  let data = options.data;
4349
4335
  if (typeof data === "string" && isUUID(data)) {
4350
- data = `https://api.maptiler.com/data/${data}/features.json?key=${config.apiKey}`;
4336
+ data = `https://api.maptiler.com/data/${data}/features.json?key=${config$1.apiKey}`;
4351
4337
  }
4352
4338
  map.addSource(sourceId, {
4353
4339
  type: "geojson",
@@ -4438,24 +4424,13 @@ function addPolygon(map, options) {
4438
4424
  if (map.hasImage(pattern)) {
4439
4425
  addLayers(pattern);
4440
4426
  } else {
4441
- map.loadImage(
4442
- pattern,
4443
- // (error?: Error | null, image?: HTMLImageElement | ImageBitmap | null, expiry?: ExpiryData | null)
4444
- (error, image) => {
4445
- if (error) {
4446
- console.error("Could not load the pattern image.", error.message);
4447
- return addLayers();
4448
- }
4449
- if (!image) {
4450
- console.error(
4451
- `An image cannot be created from the pattern URL ${pattern}.`
4452
- );
4453
- return addLayers();
4454
- }
4455
- map.addImage(pattern, image);
4456
- addLayers(pattern);
4457
- }
4458
- );
4427
+ map.loadImage(pattern).then((value) => {
4428
+ map.addImage(pattern, value.data);
4429
+ addLayers(pattern);
4430
+ }).catch((err) => {
4431
+ console.error("Could not load the pattern image.", err.message);
4432
+ return addLayers();
4433
+ });
4459
4434
  }
4460
4435
  } else {
4461
4436
  addLayers();
@@ -4515,7 +4490,7 @@ function addPoint(map, options) {
4515
4490
  if (options.data && !map.getSource(sourceId)) {
4516
4491
  let data = options.data;
4517
4492
  if (typeof data === "string" && isUUID(data)) {
4518
- data = `https://api.maptiler.com/data/${data}/features.json?key=${config.apiKey}`;
4493
+ data = `https://api.maptiler.com/data/${data}/features.json?key=${config$1.apiKey}`;
4519
4494
  }
4520
4495
  map.addSource(sourceId, {
4521
4496
  type: "geojson",
@@ -4781,7 +4756,7 @@ function addHeatmap(map, options) {
4781
4756
  if (options.data && !map.getSource(sourceId)) {
4782
4757
  let data = options.data;
4783
4758
  if (typeof data === "string" && isUUID(data)) {
4784
- data = `https://api.maptiler.com/data/${data}/features.json?key=${config.apiKey}`;
4759
+ data = `https://api.maptiler.com/data/${data}/features.json?key=${config$1.apiKey}`;
4785
4760
  }
4786
4761
  map.addSource(sourceId, {
4787
4762
  type: "geojson",
@@ -4827,31 +4802,60 @@ const {
4827
4802
  AJAXError,
4828
4803
  prewarm,
4829
4804
  clearPrewarmedResources,
4830
- version,
4831
- workerCount,
4832
- maxParallelImageRequests,
4833
- workerUrl,
4834
4805
  addProtocol,
4835
- removeProtocol
4836
- } = maplibregl__default;
4837
- const MapMLGL = maplibregl__default.Map;
4838
- const MarkerMLGL = maplibregl__default.Marker;
4839
- const PopupMLGL = maplibregl__default.Popup;
4840
- const StyleMLGL = maplibregl__default.Style;
4841
- const CanvasSourceMLGL = maplibregl__default.CanvasSource;
4842
- const GeoJSONSourceMLGL = maplibregl__default.GeoJSONSource;
4843
- const ImageSourceMLGL = maplibregl__default.ImageSource;
4844
- const RasterTileSourceMLGL = maplibregl__default.RasterTileSource;
4845
- const RasterDEMTileSourceMLGL = maplibregl__default.RasterDEMTileSource;
4846
- const VectorTileSourceMLGL = maplibregl__default.VectorTileSource;
4847
- const VideoSourceMLGL = maplibregl__default.VideoSource;
4848
- maplibregl__default.NavigationControl;
4849
- maplibregl__default.GeolocateControl;
4850
- maplibregl__default.AttributionControl;
4851
- maplibregl__default.LogoControl;
4852
- maplibregl__default.ScaleControl;
4853
- maplibregl__default.FullscreenControl;
4854
- maplibregl__default.TerrainControl;
4806
+ removeProtocol,
4807
+ Hash,
4808
+ Point,
4809
+ config,
4810
+ EdgeInsets,
4811
+ DragRotateHandler,
4812
+ DragPanHandler,
4813
+ TwoFingersTouchZoomRotateHandler,
4814
+ DoubleClickZoomHandler,
4815
+ TwoFingersTouchZoomHandler,
4816
+ TwoFingersTouchRotateHandler,
4817
+ getWorkerCount,
4818
+ setWorkerCount,
4819
+ getMaxParallelImageRequests,
4820
+ setMaxParallelImageRequests,
4821
+ getWorkerUrl,
4822
+ setWorkerUrl,
4823
+ addSourceType,
4824
+ importScriptInWorkers
4825
+ } = maplibregl;
4826
+ function getVersion() {
4827
+ return packagejson.version;
4828
+ }
4829
+ function getMapLibreVersion() {
4830
+ return maplibregl.getVersion();
4831
+ }
4832
+ console.log("maplibregl", maplibregl);
4833
+ const MapMLGL = maplibregl.Map;
4834
+ const MarkerMLGL = maplibregl.Marker;
4835
+ const PopupMLGL = maplibregl.Popup;
4836
+ const StyleMLGL = maplibregl.Style;
4837
+ const CanvasSourceMLGL = maplibregl.CanvasSource;
4838
+ const GeoJSONSourceMLGL = maplibregl.GeoJSONSource;
4839
+ const ImageSourceMLGL = maplibregl.ImageSource;
4840
+ const RasterTileSourceMLGL = maplibregl.RasterTileSource;
4841
+ const RasterDEMTileSourceMLGL = maplibregl.RasterDEMTileSource;
4842
+ const VectorTileSourceMLGL = maplibregl.VectorTileSource;
4843
+ const VideoSourceMLGL = maplibregl.VideoSource;
4844
+ maplibregl.NavigationControl;
4845
+ maplibregl.GeolocateControl;
4846
+ maplibregl.AttributionControl;
4847
+ maplibregl.LogoControl;
4848
+ maplibregl.ScaleControl;
4849
+ maplibregl.FullscreenControl;
4850
+ maplibregl.TerrainControl;
4851
+ const BoxZoomHandlerMLGL = maplibregl.BoxZoomHandler;
4852
+ const ScrollZoomHandlerMLGL = maplibregl.ScrollZoomHandler;
4853
+ const CooperativeGesturesHandlerMLGL = maplibregl.CooperativeGesturesHandler;
4854
+ const KeyboardHandlerMLGL = maplibregl.KeyboardHandler;
4855
+ const TwoFingersTouchPitchHandlerMLGL = maplibregl.TwoFingersTouchPitchHandler;
4856
+ const MapWheelEventMLGL = maplibregl.MapWheelEvent;
4857
+ const MapTouchEventMLGL = maplibregl.MapTouchEvent;
4858
+ const MapMouseEventMLGL = maplibregl.MapMouseEvent;
4855
4859
 
4856
- export { AJAXError, AttributionControl, CanvasSource, CanvasSourceMLGL, ColorRamp, ColorRampCollection, Evented, FullscreenControl, GeoJSONSource, GeoJSONSourceMLGL, GeolocateControl, GeolocationType, ImageSource, ImageSourceMLGL, Language, LngLat, LngLatBounds, LogoControl, Map, MapMLGL, MaptilerGeolocateControl, MaptilerLogoControl, MaptilerNavigationControl, MaptilerTerrainControl, Marker, MarkerMLGL, MercatorCoordinate, NavigationControl, Point, Popup, PopupMLGL, RasterDEMTileSource, RasterDEMTileSourceMLGL, RasterTileSource, RasterTileSourceMLGL, ScaleControl, SdkConfig, Style, StyleMLGL, TerrainControl, VectorTileSource, VectorTileSourceMLGL, VideoSource, VideoSourceMLGL, addProtocol, clearPrewarmedResources, config, getBrowserLanguage, getRTLTextPluginStatus, gpx, gpxOrKml, hasChildNodeWithName, helpers, isLanguageSupported, kml, maxParallelImageRequests, prewarm, removeProtocol, setRTLTextPlugin, str2xml, version, workerCount, workerUrl, xml2str };
4860
+ export { AJAXError, AttributionControl, BoxZoomHandler, BoxZoomHandlerMLGL, CanvasSource, CanvasSourceMLGL, ColorRamp, ColorRampCollection, CooperativeGesturesHandler, CooperativeGesturesHandlerMLGL, DoubleClickZoomHandler, DragPanHandler, DragRotateHandler, EdgeInsets, Evented, FullscreenControl, GeoJSONSource, GeoJSONSourceMLGL, GeolocateControl, GeolocationType, Hash, ImageSource, ImageSourceMLGL, KeyboardHandler, KeyboardHandlerMLGL, Language, LngLat, LngLatBounds, LogoControl, Map, MapMLGL, MapMouseEvent, MapMouseEventMLGL, MapTouchEvent, MapTouchEventMLGL, MapWheelEvent, MapWheelEventMLGL, MaptilerGeolocateControl, MaptilerLogoControl, MaptilerNavigationControl, MaptilerTerrainControl, Marker, MarkerMLGL, MercatorCoordinate, NavigationControl, Point, Popup, PopupMLGL, RasterDEMTileSource, RasterDEMTileSourceMLGL, RasterTileSource, RasterTileSourceMLGL, ScaleControl, ScrollZoomHandler, ScrollZoomHandlerMLGL, SdkConfig, Style, StyleMLGL, TerrainControl, TwoFingersTouchPitchHandler, TwoFingersTouchPitchHandlerMLGL, TwoFingersTouchRotateHandler, TwoFingersTouchZoomHandler, TwoFingersTouchZoomRotateHandler, VectorTileSource, VectorTileSourceMLGL, VideoSource, VideoSourceMLGL, addProtocol, addSourceType, clearPrewarmedResources, config$1 as config, config as configMLGL, getBrowserLanguage, getMapLibreVersion, getMaxParallelImageRequests, getRTLTextPluginStatus, getVersion, getWorkerCount, getWorkerUrl, gpx, gpxOrKml, hasChildNodeWithName, helpers, importScriptInWorkers, isLanguageSupported, kml, prewarm, removeProtocol, setMaxParallelImageRequests, setRTLTextPlugin, setWorkerCount, setWorkerUrl, str2xml, xml2str };
4857
4861
  //# sourceMappingURL=maptiler-sdk.mjs.map