@maptiler/sdk 2.2.0 → 2.2.1

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.
@@ -1,12 +1,13 @@
1
- import maplibregl from 'maplibre-gl';
2
- import { Base64 } from 'js-base64';
1
+ import maplibregl, { addProtocol } from 'maplibre-gl';
2
+ export { AJAXError, AttributionControl as AttributionControlMLGL, BoxZoomHandler as BoxZoomHandlerMLGL, CanvasSource as CanvasSourceMLGL, CooperativeGesturesHandler as CooperativeGesturesHandlerMLGL, DoubleClickZoomHandler, DragPanHandler, DragRotateHandler, EdgeInsets, Evented, FullscreenControl as FullscreenControlMLGL, GeoJSONSource as GeoJSONSourceMLGL, GeolocateControl as GeolocateControlMLGL, Hash, ImageSource as ImageSourceMLGL, KeyboardHandler as KeyboardHandlerMLGL, LngLat, LngLatBounds, LogoControl as LogoControlMLGL, Map as MapMLGL, MapMouseEvent as MapMouseEventMLGL, MapTouchEvent as MapTouchEventMLGL, MapWheelEvent as MapWheelEventMLGL, Marker as MarkerMLGL, MercatorCoordinate, NavigationControl as NavigationControlMLGL, Point, Popup as PopupMLGL, RasterDEMTileSource as RasterDEMTileSourceMLGL, RasterTileSource as RasterTileSourceMLGL, ScaleControl as ScaleControlMLGL, ScrollZoomHandler as ScrollZoomHandlerMLGL, Style as StyleMLGL, TerrainControl as TerrainControlMLGL, TwoFingersTouchPitchHandler as TwoFingersTouchPitchHandlerMLGL, TwoFingersTouchRotateHandler, TwoFingersTouchZoomHandler, TwoFingersTouchZoomRotateHandler, VectorTileSource as VectorTileSourceMLGL, VideoSource as VideoSourceMLGL, addProtocol, addSourceType, clearPrewarmedResources, config as configMLGL, getVersion as getMapLibreVersion, getMaxParallelImageRequests, getRTLTextPluginStatus, getWorkerCount, getWorkerUrl, importScriptInWorkers, prewarm, removeProtocol, setMaxParallelImageRequests, setRTLTextPlugin, setWorkerCount, setWorkerUrl } from 'maplibre-gl';
3
3
  import EventEmitter from 'events';
4
- import { config as config$2, MapStyle, mapStylePresetList, expandMapStyle, MapStyleVariant, ReferenceMapStyle, geolocation } from '@maptiler/client';
4
+ import { config as config$1, MapStyle, mapStylePresetList, expandMapStyle, MapStyleVariant, ReferenceMapStyle, geolocation } from '@maptiler/client';
5
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';
6
6
  import { v4 } from 'uuid';
7
+ import { Base64 } from 'js-base64';
7
8
 
8
9
  var name = "@maptiler/sdk";
9
- var version = "2.2.0";
10
+ var version = "2.2.1";
10
11
  var description = "The Javascript & TypeScript map SDK tailored for MapTiler Cloud";
11
12
  var module = "dist/maptiler-sdk.mjs";
12
13
  var types = "dist/maptiler-sdk.d.ts";
@@ -301,7 +302,7 @@ class SdkConfig extends EventEmitter {
301
302
  */
302
303
  set apiKey(k) {
303
304
  this._apiKey = k;
304
- config$2.apiKey = k;
305
+ config$1.apiKey = k;
305
306
  this.emit("apiKey", k);
306
307
  }
307
308
  /**
@@ -314,60 +315,16 @@ class SdkConfig extends EventEmitter {
314
315
  * Set a the custom fetch function to replace the default one
315
316
  */
316
317
  set fetch(f) {
317
- config$2.fetch = f;
318
+ config$1.fetch = f;
318
319
  }
319
320
  /**
320
321
  * Get the fetch fucntion
321
322
  */
322
323
  get fetch() {
323
- return config$2.fetch;
324
- }
325
- }
326
- const config$1 = new SdkConfig();
327
-
328
- class LogoControl extends maplibregl.LogoControl {
329
- onAdd(map) {
330
- return super.onAdd(map);
331
- }
332
- }
333
-
334
- class MaptilerLogoControl extends LogoControl {
335
- constructor(options = {}) {
336
- super(options);
337
- this.logoURL = "";
338
- this.linkURL = "";
339
- this.logoURL = options.logoURL ?? defaults.maptilerLogoURL;
340
- this.linkURL = options.linkURL ?? defaults.maptilerURL;
341
- }
342
- onAdd(map) {
343
- this._map = map;
344
- this._compact = this.options.compact ?? false;
345
- this._container = window.document.createElement("div");
346
- this._container.className = "maplibregl-ctrl";
347
- const anchor = window.document.createElement("a");
348
- anchor.style.backgroundRepeat = "no-repeat";
349
- anchor.style.cursor = "pointer";
350
- anchor.style.display = "block";
351
- anchor.style.height = "23px";
352
- anchor.style.margin = "0 0 -4px -4px";
353
- anchor.style.overflow = "hidden";
354
- anchor.style.width = "88px";
355
- anchor.style.backgroundImage = `url(${this.logoURL})`;
356
- anchor.style.backgroundSize = "100px 30px";
357
- anchor.style.width = "100px";
358
- anchor.style.height = "30px";
359
- anchor.target = "_blank";
360
- anchor.rel = "noopener";
361
- anchor.href = this.linkURL;
362
- anchor.setAttribute("aria-label", "MapTiler logo");
363
- anchor.setAttribute("rel", "noopener");
364
- this._container.appendChild(anchor);
365
- this._container.style.display = "block";
366
- this._map.on("resize", this._updateCompact);
367
- this._updateCompact();
368
- return this._container;
324
+ return config$1.fetch;
369
325
  }
370
326
  }
327
+ const config = new SdkConfig();
371
328
 
372
329
  const LOCAL_CACHE_PROTOCOL_SOURCE = "localcache_source";
373
330
  const LOCAL_CACHE_PROTOCOL_DATA = "localcache";
@@ -376,7 +333,7 @@ const CACHE_LIMIT_ITEMS = 1e3;
376
333
  const CACHE_LIMIT_CHECK_INTERVAL = 100;
377
334
  const CACHE_API_AVAILABLE = typeof caches !== "undefined";
378
335
  function localCacheTransformRequest(reqUrl, resourceType) {
379
- if (CACHE_API_AVAILABLE && config$1.caching && config$1.session && reqUrl.host === defaults.maptilerApiHost) {
336
+ if (CACHE_API_AVAILABLE && config.caching && config.session && reqUrl.host === defaults.maptilerApiHost) {
380
337
  if (resourceType === "Source" && reqUrl.href.includes("tiles.json")) {
381
338
  return reqUrl.href.replace("https://", `${LOCAL_CACHE_PROTOCOL_SOURCE}://`);
382
339
  }
@@ -406,8 +363,7 @@ function registerLocalCacheProtocol() {
406
363
  addProtocol(
407
364
  LOCAL_CACHE_PROTOCOL_SOURCE,
408
365
  async (params, abortController) => {
409
- if (!params.url)
410
- throw new Error("");
366
+ if (!params.url) throw new Error("");
411
367
  params.url = params.url.replace(`${LOCAL_CACHE_PROTOCOL_SOURCE}://`, "https://");
412
368
  const requestInit = params;
413
369
  requestInit.signal = abortController.signal;
@@ -426,8 +382,7 @@ function registerLocalCacheProtocol() {
426
382
  addProtocol(
427
383
  LOCAL_CACHE_PROTOCOL_DATA,
428
384
  async (params, abortController) => {
429
- if (!params.url)
430
- throw new Error("");
385
+ if (!params.url) throw new Error("");
431
386
  params.url = params.url.replace(`${LOCAL_CACHE_PROTOCOL_DATA}://`, "https://");
432
387
  const url = new URL(params.url);
433
388
  const cacheableUrl = new URL(url);
@@ -466,6 +421,7 @@ function registerLocalCacheProtocol() {
466
421
  }
467
422
 
468
423
  function enableRTL() {
424
+ if (typeof window === "undefined") return;
469
425
  const status = maplibregl.getRTLTextPluginStatus();
470
426
  if (status === "unavailable" || status === "requested") {
471
427
  try {
@@ -476,17 +432,14 @@ function enableRTL() {
476
432
  }
477
433
  function bindAll(fns, context) {
478
434
  for (const fn of fns) {
479
- if (typeof context[fn] !== "function")
480
- continue;
435
+ if (typeof context[fn] !== "function") continue;
481
436
  context[fn] = context[fn].bind(context);
482
437
  }
483
438
  }
484
439
  function DOMcreate(tagName, className, container) {
485
440
  const el = window.document.createElement(tagName);
486
- if (className !== void 0)
487
- el.className = className;
488
- if (container)
489
- container.appendChild(el);
441
+ if (className !== void 0) el.className = className;
442
+ if (container) container.appendChild(el);
490
443
  return el;
491
444
  }
492
445
  function DOMremove(node) {
@@ -505,9 +458,9 @@ function maptilerCloudTransformRequest(url, resourceType) {
505
458
  }
506
459
  if (reqUrl.host === defaults.maptilerApiHost) {
507
460
  if (!reqUrl.searchParams.has("key")) {
508
- reqUrl.searchParams.append("key", config$1.apiKey);
461
+ reqUrl.searchParams.append("key", config.apiKey);
509
462
  }
510
- if (config$1.session) {
463
+ if (config.session) {
511
464
  reqUrl.searchParams.append("mtsid", MAPTILER_SESSION_ID);
512
465
  }
513
466
  }
@@ -554,8 +507,7 @@ function getWebGLSupportError() {
554
507
  }
555
508
  function displayNoWebGlWarning(container) {
556
509
  const webglError = getWebGLSupportError();
557
- if (!webglError)
558
- return;
510
+ if (!webglError) return;
559
511
  let actualContainer = null;
560
512
  if (typeof container === "string") {
561
513
  actualContainer = document.getElementById(container);
@@ -572,6 +524,194 @@ function displayNoWebGlWarning(container) {
572
524
  throw new Error(webglError);
573
525
  }
574
526
 
527
+ let Marker$1 = class Marker extends maplibregl.Marker {
528
+ addTo(map) {
529
+ return super.addTo(map);
530
+ }
531
+ };
532
+
533
+ class Popup extends maplibregl.Popup {
534
+ addTo(map) {
535
+ return super.addTo(map);
536
+ }
537
+ }
538
+
539
+ class Style extends maplibregl.Style {
540
+ constructor(map, options = {}) {
541
+ super(map, options);
542
+ }
543
+ }
544
+
545
+ class CanvasSource extends maplibregl.CanvasSource {
546
+ onAdd(map) {
547
+ super.onAdd(map);
548
+ }
549
+ }
550
+
551
+ class GeoJSONSource extends maplibregl.GeoJSONSource {
552
+ onAdd(map) {
553
+ super.onAdd(map);
554
+ }
555
+ }
556
+
557
+ class ImageSource extends maplibregl.ImageSource {
558
+ onAdd(map) {
559
+ super.onAdd(map);
560
+ }
561
+ }
562
+
563
+ class RasterTileSource extends maplibregl.RasterTileSource {
564
+ onAdd(map) {
565
+ super.onAdd(map);
566
+ }
567
+ }
568
+
569
+ class RasterDEMTileSource extends maplibregl.RasterDEMTileSource {
570
+ onAdd(map) {
571
+ super.onAdd(map);
572
+ }
573
+ }
574
+
575
+ class VectorTileSource extends maplibregl.VectorTileSource {
576
+ onAdd(map) {
577
+ super.onAdd(map);
578
+ }
579
+ }
580
+
581
+ class VideoSource extends maplibregl.VideoSource {
582
+ onAdd(map) {
583
+ super.onAdd(map);
584
+ }
585
+ }
586
+
587
+ class NavigationControl extends maplibregl.NavigationControl {
588
+ onAdd(map) {
589
+ return super.onAdd(map);
590
+ }
591
+ }
592
+
593
+ class GeolocateControl extends maplibregl.GeolocateControl {
594
+ onAdd(map) {
595
+ return super.onAdd(map);
596
+ }
597
+ }
598
+
599
+ class AttributionControl extends maplibregl.AttributionControl {
600
+ onAdd(map) {
601
+ return super.onAdd(map);
602
+ }
603
+ }
604
+
605
+ class LogoControl extends maplibregl.LogoControl {
606
+ onAdd(map) {
607
+ return super.onAdd(map);
608
+ }
609
+ }
610
+
611
+ class ScaleControl extends maplibregl.ScaleControl {
612
+ onAdd(map) {
613
+ return super.onAdd(map);
614
+ }
615
+ }
616
+
617
+ class FullscreenControl extends maplibregl.FullscreenControl {
618
+ onAdd(map) {
619
+ return super.onAdd(map);
620
+ }
621
+ }
622
+
623
+ class TerrainControl extends maplibregl.TerrainControl {
624
+ onAdd(map) {
625
+ return super.onAdd(map);
626
+ }
627
+ }
628
+
629
+ class BoxZoomHandler extends maplibregl.BoxZoomHandler {
630
+ constructor(map, options) {
631
+ super(map, options);
632
+ }
633
+ }
634
+
635
+ class ScrollZoomHandler extends maplibregl.ScrollZoomHandler {
636
+ constructor(map, triggerRenderFrame) {
637
+ super(map, triggerRenderFrame);
638
+ }
639
+ }
640
+
641
+ class CooperativeGesturesHandler extends maplibregl.CooperativeGesturesHandler {
642
+ constructor(map, options) {
643
+ super(map, options);
644
+ }
645
+ }
646
+
647
+ class KeyboardHandler extends maplibregl.KeyboardHandler {
648
+ constructor(map) {
649
+ super(map);
650
+ }
651
+ }
652
+
653
+ class TwoFingersTouchPitchHandler extends maplibregl.TwoFingersTouchPitchHandler {
654
+ constructor(map) {
655
+ super(map);
656
+ }
657
+ }
658
+
659
+ class MapWheelEvent extends maplibregl.MapWheelEvent {
660
+ constructor(type, map, originalEvent) {
661
+ super(type, map, originalEvent);
662
+ }
663
+ }
664
+
665
+ class MapTouchEvent extends maplibregl.MapTouchEvent {
666
+ constructor(type, map, originalEvent) {
667
+ super(type, map, originalEvent);
668
+ }
669
+ }
670
+
671
+ class MapMouseEvent extends maplibregl.MapMouseEvent {
672
+ constructor(type, map, originalEvent, data = {}) {
673
+ super(type, map, originalEvent, data);
674
+ }
675
+ }
676
+
677
+ class MaptilerLogoControl extends LogoControl {
678
+ constructor(options = {}) {
679
+ super(options);
680
+ this.logoURL = "";
681
+ this.linkURL = "";
682
+ this.logoURL = options.logoURL ?? defaults.maptilerLogoURL;
683
+ this.linkURL = options.linkURL ?? defaults.maptilerURL;
684
+ }
685
+ onAdd(map) {
686
+ this._map = map;
687
+ this._compact = this.options.compact ?? false;
688
+ this._container = window.document.createElement("div");
689
+ this._container.className = "maplibregl-ctrl";
690
+ const anchor = window.document.createElement("a");
691
+ anchor.style.backgroundRepeat = "no-repeat";
692
+ anchor.style.cursor = "pointer";
693
+ anchor.style.display = "block";
694
+ anchor.style.height = "23px";
695
+ anchor.style.margin = "0 0 -4px -4px";
696
+ anchor.style.overflow = "hidden";
697
+ anchor.style.width = "88px";
698
+ anchor.style.backgroundImage = `url(${this.logoURL})`;
699
+ anchor.style.backgroundSize = "100px 30px";
700
+ anchor.style.width = "100px";
701
+ anchor.style.height = "30px";
702
+ anchor.target = "_blank";
703
+ anchor.rel = "noopener";
704
+ anchor.href = this.linkURL;
705
+ anchor.setAttribute("aria-label", "MapTiler logo");
706
+ anchor.setAttribute("rel", "noopener");
707
+ this._container.appendChild(anchor);
708
+ this._container.style.display = "block";
709
+ this._map.on("resize", this._updateCompact);
710
+ this._updateCompact();
711
+ return this._container;
712
+ }
713
+ }
714
+
575
715
  function styleToStyle(style) {
576
716
  if (!style) {
577
717
  return MapStyle[mapStylePresetList[0].referenceStyleID].getDefaultVariant().getExpandedStyleURL();
@@ -632,12 +772,6 @@ class MaptilerTerrainControl {
632
772
  }
633
773
  }
634
774
 
635
- class NavigationControl extends maplibregl.NavigationControl {
636
- onAdd(map) {
637
- return super.onAdd(map);
638
- }
639
- }
640
-
641
775
  class MaptilerNavigationControl extends NavigationControl {
642
776
  constructor() {
643
777
  super({
@@ -681,19 +815,13 @@ class MaptilerNavigationControl extends NavigationControl {
681
815
  }
682
816
  }
683
817
 
684
- class GeolocateControl extends maplibregl.GeolocateControl {
685
- onAdd(map) {
686
- return super.onAdd(map);
687
- }
688
- }
689
-
690
- const Marker$1 = maplibregl.Marker;
691
- const LngLat$1 = maplibregl.LngLat;
692
- const LngLatBounds$1 = maplibregl.LngLatBounds;
818
+ const Marker = maplibregl.Marker;
819
+ const LngLat = maplibregl.LngLat;
820
+ const LngLatBounds = maplibregl.LngLatBounds;
693
821
  class MaptilerGeolocateControl extends GeolocateControl {
694
822
  constructor() {
695
823
  super(...arguments);
696
- this.lastUpdatedCenter = new LngLat$1(0, 0);
824
+ this.lastUpdatedCenter = new LngLat(0, 0);
697
825
  /**
698
826
  * Update the camera location to center on the current position
699
827
  *
@@ -701,7 +829,7 @@ class MaptilerGeolocateControl extends GeolocateControl {
701
829
  * @private
702
830
  */
703
831
  this._updateCamera = (position) => {
704
- const center = new LngLat$1(position.coords.longitude, position.coords.latitude);
832
+ const center = new LngLat(position.coords.longitude, position.coords.latitude);
705
833
  const radius = position.coords.accuracy;
706
834
  const bearing = this._map.getBearing();
707
835
  const options = {
@@ -713,7 +841,7 @@ class MaptilerGeolocateControl extends GeolocateControl {
713
841
  if (currentMapZoom > (this.options?.fitBoundsOptions?.maxZoom ?? 30)) {
714
842
  options.zoom = currentMapZoom;
715
843
  }
716
- this._map.fitBounds(LngLatBounds$1.fromLngLat(center, radius), options, {
844
+ this._map.fitBounds(LngLatBounds.fromLngLat(center, radius), options, {
717
845
  geolocateSource: true
718
846
  // tag this camera change so it won't cause the control to change to background state
719
847
  });
@@ -762,14 +890,13 @@ class MaptilerGeolocateControl extends GeolocateControl {
762
890
  }
763
891
  if (this.options.showUserLocation) {
764
892
  this._dotElement = DOMcreate("div", "maplibregl-user-location-dot");
765
- this._userLocationDotMarker = new Marker$1({ element: this._dotElement });
893
+ this._userLocationDotMarker = new Marker({ element: this._dotElement });
766
894
  this._circleElement = DOMcreate("div", "maplibregl-user-location-accuracy-circle");
767
- this._accuracyCircleMarker = new Marker$1({
895
+ this._accuracyCircleMarker = new Marker({
768
896
  element: this._circleElement,
769
897
  pitchAlignment: "map"
770
898
  });
771
- if (this.options.trackUserLocation)
772
- this._watchState = "OFF";
899
+ if (this.options.trackUserLocation) this._watchState = "OFF";
773
900
  this._map.on("move", this._onZoom);
774
901
  }
775
902
  this._geolocateButton.addEventListener("click", this.trigger.bind(this));
@@ -811,55 +938,26 @@ class MaptilerGeolocateControl extends GeolocateControl {
811
938
  }
812
939
  }
813
940
 
814
- class ScaleControl extends maplibregl.ScaleControl {
815
- onAdd(map) {
816
- return super.onAdd(map);
817
- }
818
- }
819
-
820
- class FullscreenControl extends maplibregl.FullscreenControl {
821
- onAdd(map) {
822
- return super.onAdd(map);
823
- }
824
- }
825
-
826
- var __accessCheck = (obj, member, msg) => {
827
- if (!member.has(obj))
828
- throw TypeError("Cannot " + msg);
829
- };
830
- var __privateGet = (obj, member, getter) => {
831
- __accessCheck(obj, member, "read from private field");
832
- return getter ? getter.call(obj) : member.get(obj);
833
- };
834
- var __privateAdd = (obj, member, value) => {
835
- if (member.has(obj))
836
- throw TypeError("Cannot add the same private member more than once");
837
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
838
- };
839
- var __privateSet = (obj, member, value, setter) => {
840
- __accessCheck(obj, member, "write to private field");
841
- member.set(obj, value);
842
- return value;
941
+ var __typeError = (msg) => {
942
+ throw TypeError(msg);
843
943
  };
844
- var __privateMethod = (obj, member, method) => {
845
- __accessCheck(obj, member, "access private method");
846
- return method;
847
- };
848
- var _options, _parentMap, _container, _canvasContainer, _parentRect, _differentStyle, _desync, _addParentRect, addParentRect_fn, _setParentBounds, setParentBounds_fn, _syncMaps, syncMaps_fn;
944
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
945
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
946
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
947
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
948
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
949
+ var _options, _parentMap, _container, _canvasContainer, _parentRect, _differentStyle, _desync, _Minimap_instances, addParentRect_fn, setParentBounds_fn, syncMaps_fn;
849
950
  class Minimap {
850
951
  constructor(options, mapOptions) {
851
- __privateAdd(this, _addParentRect);
852
- __privateAdd(this, _setParentBounds);
853
- __privateAdd(this, _syncMaps);
854
- __privateAdd(this, _options, void 0);
855
- __privateAdd(this, _parentMap, void 0);
856
- __privateAdd(this, _container, void 0);
857
- __privateAdd(this, _canvasContainer, void 0);
858
- __privateAdd(this, _parentRect, void 0);
952
+ __privateAdd(this, _Minimap_instances);
953
+ __privateAdd(this, _options);
954
+ __privateAdd(this, _parentMap);
955
+ __privateAdd(this, _container);
956
+ __privateAdd(this, _canvasContainer);
957
+ __privateAdd(this, _parentRect);
859
958
  __privateAdd(this, _differentStyle, false);
860
- __privateAdd(this, _desync, void 0);
861
- if (options.style !== void 0)
862
- __privateSet(this, _differentStyle, true);
959
+ __privateAdd(this, _desync);
960
+ if (options.style !== void 0) __privateSet(this, _differentStyle, true);
863
961
  __privateSet(this, _options, {
864
962
  // set defaults
865
963
  zoomAdjust: -4,
@@ -890,56 +988,47 @@ class Minimap {
890
988
  }
891
989
  }
892
990
  setStyle(style, options) {
893
- if (!__privateGet(this, _differentStyle))
894
- this.map.setStyle(style, options);
895
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
991
+ if (!__privateGet(this, _differentStyle)) this.map.setStyle(style, options);
992
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
896
993
  }
897
994
  addLayer(layer, beforeId) {
898
- if (!__privateGet(this, _differentStyle))
899
- this.map.addLayer(layer, beforeId);
900
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
995
+ if (!__privateGet(this, _differentStyle)) this.map.addLayer(layer, beforeId);
996
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
901
997
  return this.map;
902
998
  }
903
999
  moveLayer(id, beforeId) {
904
- if (!__privateGet(this, _differentStyle))
905
- this.map.moveLayer(id, beforeId);
906
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
1000
+ if (!__privateGet(this, _differentStyle)) this.map.moveLayer(id, beforeId);
1001
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
907
1002
  return this.map;
908
1003
  }
909
1004
  removeLayer(id) {
910
- if (!__privateGet(this, _differentStyle))
911
- this.map.removeLayer(id);
912
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
1005
+ if (!__privateGet(this, _differentStyle)) this.map.removeLayer(id);
1006
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
913
1007
  return this;
914
1008
  }
915
1009
  setLayerZoomRange(layerId, minzoom, maxzoom) {
916
- if (!__privateGet(this, _differentStyle))
917
- this.map.setLayerZoomRange(layerId, minzoom, maxzoom);
918
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
1010
+ if (!__privateGet(this, _differentStyle)) this.map.setLayerZoomRange(layerId, minzoom, maxzoom);
1011
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
919
1012
  return this;
920
1013
  }
921
1014
  setFilter(layerId, filter, options) {
922
- if (!__privateGet(this, _differentStyle))
923
- this.map.setFilter(layerId, filter, options);
924
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
1015
+ if (!__privateGet(this, _differentStyle)) this.map.setFilter(layerId, filter, options);
1016
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
925
1017
  return this;
926
1018
  }
927
1019
  setPaintProperty(layerId, name, value, options) {
928
- if (!__privateGet(this, _differentStyle))
929
- this.map.setPaintProperty(layerId, name, value, options);
930
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
1020
+ if (!__privateGet(this, _differentStyle)) this.map.setPaintProperty(layerId, name, value, options);
1021
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
931
1022
  return this;
932
1023
  }
933
1024
  setLayoutProperty(layerId, name, value, options) {
934
- if (!__privateGet(this, _differentStyle))
935
- this.map.setLayoutProperty(layerId, name, value, options);
936
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
1025
+ if (!__privateGet(this, _differentStyle)) this.map.setLayoutProperty(layerId, name, value, options);
1026
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
937
1027
  return this;
938
1028
  }
939
1029
  setGlyphs(glyphsUrl, options) {
940
- if (!__privateGet(this, _differentStyle))
941
- this.map.setGlyphs(glyphsUrl, options);
942
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
1030
+ if (!__privateGet(this, _differentStyle)) this.map.setGlyphs(glyphsUrl, options);
1031
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
943
1032
  return this;
944
1033
  }
945
1034
  onAdd(parentMap) {
@@ -955,8 +1044,8 @@ class Minimap {
955
1044
  this.map.resize();
956
1045
  });
957
1046
  this.map.once("load", () => {
958
- __privateMethod(this, _addParentRect, addParentRect_fn).call(this, __privateGet(this, _options).parentRect);
959
- __privateSet(this, _desync, __privateMethod(this, _syncMaps, syncMaps_fn).call(this));
1047
+ __privateMethod(this, _Minimap_instances, addParentRect_fn).call(this, __privateGet(this, _options).parentRect);
1048
+ __privateSet(this, _desync, __privateMethod(this, _Minimap_instances, syncMaps_fn).call(this));
960
1049
  });
961
1050
  return __privateGet(this, _container);
962
1051
  }
@@ -973,7 +1062,7 @@ _canvasContainer = new WeakMap();
973
1062
  _parentRect = new WeakMap();
974
1063
  _differentStyle = new WeakMap();
975
1064
  _desync = new WeakMap();
976
- _addParentRect = new WeakSet();
1065
+ _Minimap_instances = new WeakSet();
977
1066
  addParentRect_fn = function(rect) {
978
1067
  if (rect === void 0 || rect.linePaint === void 0 && rect.fillPaint === void 0) {
979
1068
  return;
@@ -1021,12 +1110,10 @@ addParentRect_fn = function(rect) {
1021
1110
  }
1022
1111
  });
1023
1112
  }
1024
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
1113
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
1025
1114
  };
1026
- _setParentBounds = new WeakSet();
1027
1115
  setParentBounds_fn = function() {
1028
- if (__privateGet(this, _parentRect) === void 0)
1029
- return;
1116
+ if (__privateGet(this, _parentRect) === void 0) return;
1030
1117
  const { devicePixelRatio } = window;
1031
1118
  const canvas = __privateGet(this, _parentMap).getCanvas();
1032
1119
  const width = canvas.width / devicePixelRatio;
@@ -1042,7 +1129,6 @@ setParentBounds_fn = function() {
1042
1129
  const source = this.map.getSource("parentRect");
1043
1130
  source.setData(__privateGet(this, _parentRect));
1044
1131
  };
1045
- _syncMaps = new WeakSet();
1046
1132
  syncMaps_fn = function() {
1047
1133
  const { pitchAdjust } = __privateGet(this, _options);
1048
1134
  const parentCallback = () => {
@@ -1073,7 +1159,7 @@ syncMaps_fn = function() {
1073
1159
  bearing,
1074
1160
  pitch: pitchAdjust ? pitch : 0
1075
1161
  });
1076
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
1162
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
1077
1163
  on();
1078
1164
  };
1079
1165
  on();
@@ -1090,11 +1176,11 @@ class Map extends maplibregl.Map {
1090
1176
  constructor(options) {
1091
1177
  displayNoWebGlWarning(options.container);
1092
1178
  if (options.apiKey) {
1093
- config$1.apiKey = options.apiKey;
1179
+ config.apiKey = options.apiKey;
1094
1180
  }
1095
1181
  const style = styleToStyle(options.style);
1096
1182
  const hashPreConstructor = location.hash;
1097
- if (!config$1.apiKey) {
1183
+ if (!config.apiKey) {
1098
1184
  console.warn("MapTiler Cloud API key is not set. Visit https://maptiler.com and try Cloud for free!");
1099
1185
  }
1100
1186
  let attributionControlOptions = {
@@ -1120,15 +1206,15 @@ class Map extends maplibregl.Map {
1120
1206
  this.terrainGrowing = false;
1121
1207
  this.terrainFlattening = false;
1122
1208
  this.isReady = false;
1123
- if (config$1.caching && !CACHE_API_AVAILABLE) {
1209
+ if (config.caching && !CACHE_API_AVAILABLE) {
1124
1210
  console.warn(
1125
1211
  "The cache API is only available in secure contexts. More info at https://developer.mozilla.org/en-US/docs/Web/API/Cache"
1126
1212
  );
1127
1213
  }
1128
- if (config$1.caching && CACHE_API_AVAILABLE) {
1214
+ if (config.caching && CACHE_API_AVAILABLE) {
1129
1215
  registerLocalCacheProtocol();
1130
1216
  }
1131
- this.primaryLanguage = options.language ?? config$1.primaryLanguage;
1217
+ this.primaryLanguage = options.language ?? config.primaryLanguage;
1132
1218
  this.forceLanguageUpdate = this.primaryLanguage === Language.STYLE || this.primaryLanguage === Language.STYLE_LOCK ? false : true;
1133
1219
  this.languageAlwaysBeenStyle = this.primaryLanguage === Language.STYLE;
1134
1220
  this.terrainExaggeration = options.terrainExaggeration ?? this.terrainExaggeration;
@@ -1204,9 +1290,6 @@ class Map extends maplibregl.Map {
1204
1290
  this.enableTerrain(this.terrainExaggeration);
1205
1291
  }
1206
1292
  });
1207
- this.once("load", () => {
1208
- enableRTL();
1209
- });
1210
1293
  this.once("load", async () => {
1211
1294
  let tileJsonContent = { logo: null };
1212
1295
  try {
@@ -1215,7 +1298,7 @@ class Map extends maplibregl.Map {
1215
1298
  );
1216
1299
  const styleUrl = new URL(possibleSources[0].url);
1217
1300
  if (!styleUrl.searchParams.has("key")) {
1218
- styleUrl.searchParams.append("key", config$1.apiKey);
1301
+ styleUrl.searchParams.append("key", config.apiKey);
1219
1302
  }
1220
1303
  const tileJsonRes = await fetch(styleUrl.href);
1221
1304
  tileJsonContent = await tileJsonRes.json();
@@ -1231,9 +1314,9 @@ class Map extends maplibregl.Map {
1231
1314
  }
1232
1315
  if (options.scaleControl) {
1233
1316
  const position = options.scaleControl === true || options.scaleControl === void 0 ? "bottom-right" : options.scaleControl;
1234
- const scaleControl = new ScaleControl({ unit: config$1.unit });
1317
+ const scaleControl = new ScaleControl({ unit: config.unit });
1235
1318
  this.addControl(scaleControl, position);
1236
- config$1.on("unit", (unit) => {
1319
+ config.on("unit", (unit) => {
1237
1320
  scaleControl.setUnit(unit);
1238
1321
  });
1239
1322
  }
@@ -1341,8 +1424,7 @@ class Map extends maplibregl.Map {
1341
1424
  }
1342
1425
  });
1343
1426
  const terrainCallback = (evt) => {
1344
- if (!evt.terrain)
1345
- return;
1427
+ if (!evt.terrain) return;
1346
1428
  terrainEventTriggered = true;
1347
1429
  terrainEventData = {
1348
1430
  type: "loadWithTerrain",
@@ -1564,10 +1646,8 @@ class Map extends maplibregl.Map {
1564
1646
  return super.setGlyphs(glyphsUrl, options);
1565
1647
  }
1566
1648
  getStyleLanguage() {
1567
- if (!this.style.stylesheet.metadata)
1568
- return null;
1569
- if (typeof this.style.stylesheet.metadata !== "object")
1570
- return null;
1649
+ if (!this.style.stylesheet.metadata) return null;
1650
+ if (typeof this.style.stylesheet.metadata !== "object") return null;
1571
1651
  if ("maptiler:language" in this.style.stylesheet.metadata && typeof this.style.stylesheet.metadata["maptiler:language"] === "string") {
1572
1652
  return this.style.stylesheet.metadata["maptiler:language"];
1573
1653
  }
@@ -1897,7 +1977,7 @@ class Map extends maplibregl.Map {
1897
1977
  * that do not directly have access to the SDK configuration but do have access to a Map instance.
1898
1978
  */
1899
1979
  getSdkConfig() {
1900
- return config$1;
1980
+ return config;
1901
1981
  }
1902
1982
  /**
1903
1983
  * Get the MapTiler session ID. Convenient to dispatch to externaly built component
@@ -1924,126 +2004,6 @@ class Map extends maplibregl.Map {
1924
2004
  }
1925
2005
  }
1926
2006
 
1927
- class Marker extends maplibregl.Marker {
1928
- addTo(map) {
1929
- return super.addTo(map);
1930
- }
1931
- }
1932
-
1933
- class Popup extends maplibregl.Popup {
1934
- addTo(map) {
1935
- return super.addTo(map);
1936
- }
1937
- }
1938
-
1939
- class Style extends maplibregl.Style {
1940
- constructor(map, options = {}) {
1941
- super(map, options);
1942
- }
1943
- }
1944
-
1945
- class CanvasSource extends maplibregl.CanvasSource {
1946
- onAdd(map) {
1947
- super.onAdd(map);
1948
- }
1949
- }
1950
-
1951
- class GeoJSONSource extends maplibregl.GeoJSONSource {
1952
- onAdd(map) {
1953
- super.onAdd(map);
1954
- }
1955
- }
1956
-
1957
- class ImageSource extends maplibregl.ImageSource {
1958
- onAdd(map) {
1959
- super.onAdd(map);
1960
- }
1961
- }
1962
-
1963
- class RasterTileSource extends maplibregl.RasterTileSource {
1964
- onAdd(map) {
1965
- super.onAdd(map);
1966
- }
1967
- }
1968
-
1969
- class RasterDEMTileSource extends maplibregl.RasterDEMTileSource {
1970
- onAdd(map) {
1971
- super.onAdd(map);
1972
- }
1973
- }
1974
-
1975
- class VectorTileSource extends maplibregl.VectorTileSource {
1976
- onAdd(map) {
1977
- super.onAdd(map);
1978
- }
1979
- }
1980
-
1981
- class VideoSource extends maplibregl.VideoSource {
1982
- onAdd(map) {
1983
- super.onAdd(map);
1984
- }
1985
- }
1986
-
1987
- class AttributionControl extends maplibregl.AttributionControl {
1988
- onAdd(map) {
1989
- return super.onAdd(map);
1990
- }
1991
- }
1992
-
1993
- class TerrainControl extends maplibregl.TerrainControl {
1994
- onAdd(map) {
1995
- return super.onAdd(map);
1996
- }
1997
- }
1998
-
1999
- class BoxZoomHandler extends maplibregl.BoxZoomHandler {
2000
- constructor(map, options) {
2001
- super(map, options);
2002
- }
2003
- }
2004
-
2005
- class ScrollZoomHandler extends maplibregl.ScrollZoomHandler {
2006
- constructor(map, triggerRenderFrame) {
2007
- super(map, triggerRenderFrame);
2008
- }
2009
- }
2010
-
2011
- class CooperativeGesturesHandler extends maplibregl.CooperativeGesturesHandler {
2012
- constructor(map, options) {
2013
- super(map, options);
2014
- }
2015
- }
2016
-
2017
- class KeyboardHandler extends maplibregl.KeyboardHandler {
2018
- constructor(map) {
2019
- super(map);
2020
- }
2021
- }
2022
-
2023
- class TwoFingersTouchPitchHandler extends maplibregl.TwoFingersTouchPitchHandler {
2024
- constructor(map) {
2025
- super(map);
2026
- }
2027
- }
2028
-
2029
- class MapWheelEvent extends maplibregl.MapWheelEvent {
2030
- constructor(type, map, originalEvent) {
2031
- super(type, map, originalEvent);
2032
- }
2033
- }
2034
-
2035
- class MapTouchEvent extends maplibregl.MapTouchEvent {
2036
- constructor(type, map, originalEvent) {
2037
- super(type, map, originalEvent);
2038
- }
2039
- }
2040
-
2041
- class MapMouseEvent extends maplibregl.MapMouseEvent {
2042
- constructor(type, map, originalEvent, data = {}) {
2043
- super(type, map, originalEvent, data);
2044
- }
2045
- }
2046
-
2047
2007
  function str2xml(str) {
2048
2008
  if (typeof DOMParser !== "undefined") {
2049
2009
  const doc = new DOMParser().parseFromString(str, "application/xml");
@@ -2086,13 +2046,11 @@ function gpx(doc) {
2086
2046
  };
2087
2047
  for (const track of Array.from(tracks)) {
2088
2048
  const feature = getTrack(track);
2089
- if (feature)
2090
- gj.features.push(feature);
2049
+ if (feature) gj.features.push(feature);
2091
2050
  }
2092
2051
  for (const route of Array.from(routes)) {
2093
2052
  const feature = getRoute(route);
2094
- if (feature)
2095
- gj.features.push(feature);
2053
+ if (feature) gj.features.push(feature);
2096
2054
  }
2097
2055
  for (const waypoint of Array.from(waypoints)) {
2098
2056
  gj.features.push(getPoint(waypoint));
@@ -2101,8 +2059,7 @@ function gpx(doc) {
2101
2059
  }
2102
2060
  function kml(doc, xml2string) {
2103
2061
  let actualDoc = doc;
2104
- if (typeof actualDoc === "string")
2105
- actualDoc = str2xml(actualDoc);
2062
+ if (typeof actualDoc === "string") actualDoc = str2xml(actualDoc);
2106
2063
  if (!hasChildNodeWithName(actualDoc, "kml")) {
2107
2064
  throw new Error("The XML document is not valid KML");
2108
2065
  }
@@ -2138,15 +2095,12 @@ function kml(doc, xml2string) {
2138
2095
  return gj;
2139
2096
  }
2140
2097
  function kmlColor(v) {
2141
- if (v === null)
2142
- return ["#000000", 1];
2098
+ if (v === null) return ["#000000", 1];
2143
2099
  let color = "";
2144
2100
  let opacity = 1;
2145
2101
  let validV = v;
2146
- if (validV.substring(0, 1) === "#")
2147
- validV = validV.substring(1);
2148
- if (validV.length === 6 || validV.length === 3)
2149
- color = validV;
2102
+ if (validV.substring(0, 1) === "#") validV = validV.substring(1);
2103
+ if (validV.length === 6 || validV.length === 3) color = validV;
2150
2104
  if (validV.length === 8) {
2151
2105
  opacity = Number.parseInt(validV.substring(0, 2), 16) / 255;
2152
2106
  color = `#${validV.substring(6, 8)}${validV.substring(4, 6)}${validV.substring(2, 4)}`;
@@ -2160,14 +2114,12 @@ function gxCoords(root) {
2160
2114
  let elems = get(root, "coord");
2161
2115
  const coords = [];
2162
2116
  const times = [];
2163
- if (elems.length === 0)
2164
- elems = get(root, "gx:coord");
2117
+ if (elems.length === 0) elems = get(root, "gx:coord");
2165
2118
  for (const elem of Array.from(elems)) {
2166
2119
  coords.push(gxCoord(nodeVal(elem) ?? ""));
2167
2120
  }
2168
2121
  const timeElems = get(root, "when");
2169
- for (const timeElem of Array.from(timeElems))
2170
- times.push(nodeVal(timeElem));
2122
+ for (const timeElem of Array.from(timeElems)) times.push(nodeVal(timeElem));
2171
2123
  return {
2172
2124
  coords,
2173
2125
  times
@@ -2222,8 +2174,7 @@ function getGeometry(root) {
2222
2174
  type: "LineString",
2223
2175
  coordinates: track.coords
2224
2176
  });
2225
- if (track.times.length)
2226
- coordTimes.push(track.times);
2177
+ if (track.times.length) coordTimes.push(track.times);
2227
2178
  }
2228
2179
  }
2229
2180
  }
@@ -2244,15 +2195,11 @@ function getPlacemark(root, styleIndex, styleByHash, styleMapIndex) {
2244
2195
  let styleUrl = nodeVal(get1(root, "styleUrl"));
2245
2196
  let lineStyle = get1(root, "LineStyle");
2246
2197
  let polyStyle = get1(root, "PolyStyle");
2247
- if (!geomsAndTimes.geoms.length)
2248
- return [];
2249
- if (name)
2250
- properties.name = name;
2251
- if (address)
2252
- properties.address = address;
2198
+ if (!geomsAndTimes.geoms.length) return [];
2199
+ if (name) properties.name = name;
2200
+ if (address) properties.address = address;
2253
2201
  if (styleUrl) {
2254
- if (styleUrl[0] !== "#")
2255
- styleUrl = `#${styleUrl}`;
2202
+ if (styleUrl[0] !== "#") styleUrl = `#${styleUrl}`;
2256
2203
  properties.styleUrl = styleUrl;
2257
2204
  if (styleIndex[styleUrl]) {
2258
2205
  properties.styleHash = styleIndex[styleUrl];
@@ -2263,28 +2210,23 @@ function getPlacemark(root, styleIndex, styleByHash, styleMapIndex) {
2263
2210
  }
2264
2211
  const style = styleByHash[properties.styleHash ?? ""];
2265
2212
  if (style) {
2266
- if (!lineStyle)
2267
- lineStyle = get1(style, "LineStyle");
2268
- if (!polyStyle)
2269
- polyStyle = get1(style, "PolyStyle");
2213
+ if (!lineStyle) lineStyle = get1(style, "LineStyle");
2214
+ if (!polyStyle) polyStyle = get1(style, "PolyStyle");
2270
2215
  const iconStyle = get1(style, "IconStyle");
2271
2216
  if (iconStyle) {
2272
2217
  const icon = get1(iconStyle, "Icon");
2273
2218
  if (icon) {
2274
2219
  const href = nodeVal(get1(icon, "href"));
2275
- if (href)
2276
- properties.icon = href;
2220
+ if (href) properties.icon = href;
2277
2221
  }
2278
2222
  }
2279
2223
  }
2280
2224
  }
2281
- if (description)
2282
- properties.description = description;
2225
+ if (description) properties.description = description;
2283
2226
  if (timeSpan) {
2284
2227
  const begin = nodeVal(get1(timeSpan, "begin"));
2285
2228
  const end = nodeVal(get1(timeSpan, "end"));
2286
- if (begin && end)
2287
- properties.timespan = { begin, end };
2229
+ if (begin && end) properties.timespan = { begin, end };
2288
2230
  }
2289
2231
  if (timeStamp !== null) {
2290
2232
  properties.timestamp = nodeVal(get1(timeStamp, "when")) ?? (/* @__PURE__ */ new Date()).toISOString();
@@ -2294,12 +2236,9 @@ function getPlacemark(root, styleIndex, styleByHash, styleMapIndex) {
2294
2236
  const color = linestyles[0];
2295
2237
  const opacity = linestyles[1];
2296
2238
  const width = Number.parseFloat(nodeVal(get1(lineStyle, "width")) ?? "");
2297
- if (color)
2298
- properties.stroke = color;
2299
- if (!Number.isNaN(opacity))
2300
- properties["stroke-opacity"] = opacity;
2301
- if (!Number.isNaN(width))
2302
- properties["stroke-width"] = width;
2239
+ if (color) properties.stroke = color;
2240
+ if (!Number.isNaN(opacity)) properties["stroke-opacity"] = opacity;
2241
+ if (!Number.isNaN(width)) properties["stroke-width"] = width;
2303
2242
  }
2304
2243
  if (polyStyle) {
2305
2244
  const polystyles = kmlColor(nodeVal(get1(polyStyle, "color")));
@@ -2307,14 +2246,10 @@ function getPlacemark(root, styleIndex, styleByHash, styleMapIndex) {
2307
2246
  const popacity = polystyles[1];
2308
2247
  const fill = nodeVal(get1(polyStyle, "fill"));
2309
2248
  const outline = nodeVal(get1(polyStyle, "outline"));
2310
- if (pcolor)
2311
- properties.fill = pcolor;
2312
- if (!Number.isNaN(popacity))
2313
- properties["fill-opacity"] = popacity;
2314
- if (fill)
2315
- properties["fill-opacity"] = fill === "1" ? properties["fill-opacity"] || 1 : 0;
2316
- if (outline)
2317
- properties["stroke-opacity"] = outline === "1" ? properties["stroke-opacity"] || 1 : 0;
2249
+ if (pcolor) properties.fill = pcolor;
2250
+ if (!Number.isNaN(popacity)) properties["fill-opacity"] = popacity;
2251
+ if (fill) properties["fill-opacity"] = fill === "1" ? properties["fill-opacity"] || 1 : 0;
2252
+ if (outline) properties["stroke-opacity"] = outline === "1" ? properties["stroke-opacity"] || 1 : 0;
2318
2253
  }
2319
2254
  if (extendedData) {
2320
2255
  const datas = get(extendedData, "Data");
@@ -2340,8 +2275,7 @@ function getPlacemark(root, styleIndex, styleByHash, styleMapIndex) {
2340
2275
  },
2341
2276
  properties
2342
2277
  };
2343
- if (attr(root, "id"))
2344
- feature.id = attr(root, "id") ?? void 0;
2278
+ if (attr(root, "id")) feature.id = attr(root, "id") ?? void 0;
2345
2279
  return [feature];
2346
2280
  }
2347
2281
  function getPoints(node, pointname) {
@@ -2350,16 +2284,13 @@ function getPoints(node, pointname) {
2350
2284
  const times = [];
2351
2285
  let heartRates = [];
2352
2286
  const ptsLength = pts.length;
2353
- if (ptsLength < 2)
2354
- return;
2287
+ if (ptsLength < 2) return;
2355
2288
  for (let i = 0; i < ptsLength; i++) {
2356
2289
  const cPair = coordPair(pts[i]);
2357
2290
  line.push(cPair.coordinates);
2358
- if (cPair.time)
2359
- times.push(cPair.time);
2291
+ if (cPair.time) times.push(cPair.time);
2360
2292
  if (cPair.heartRate || heartRates.length) {
2361
- if (heartRates.length === 0)
2362
- heartRates = new Array(i).fill(null);
2293
+ if (heartRates.length === 0) heartRates = new Array(i).fill(null);
2363
2294
  heartRates.push(cPair.heartRate);
2364
2295
  }
2365
2296
  }
@@ -2378,10 +2309,8 @@ function getTrack(node) {
2378
2309
  for (let i = 0; i < segments.length; i++) {
2379
2310
  line = getPoints(segments[i], "trkpt");
2380
2311
  if (line !== void 0) {
2381
- if (line.line)
2382
- track.push(line.line);
2383
- if (line.times && line.times.length)
2384
- times.push(line.times);
2312
+ if (line.line) track.push(line.line);
2313
+ if (line.times && line.times.length) times.push(line.times);
2385
2314
  if (heartRates.length || line.heartRates && line.heartRates.length) {
2386
2315
  if (!heartRates.length) {
2387
2316
  for (let s = 0; s < i; s++) {
@@ -2396,14 +2325,12 @@ function getTrack(node) {
2396
2325
  }
2397
2326
  }
2398
2327
  }
2399
- if (track.length === 0)
2400
- return;
2328
+ if (track.length === 0) return;
2401
2329
  const properties = {
2402
2330
  ...getProperties(node),
2403
2331
  ...getLineStyle(get1(node, "extensions"))
2404
2332
  };
2405
- if (times.length !== 0)
2406
- properties.coordTimes = track.length === 1 ? times[0] : times;
2333
+ if (times.length !== 0) properties.coordTimes = track.length === 1 ? times[0] : times;
2407
2334
  if (heartRates.length !== 0) {
2408
2335
  properties.heartRates = track.length === 1 ? heartRates[0] : heartRates;
2409
2336
  }
@@ -2428,8 +2355,7 @@ function getTrack(node) {
2428
2355
  }
2429
2356
  function getRoute(node) {
2430
2357
  const line = getPoints(node, "rtept");
2431
- if (line === void 0)
2432
- return;
2358
+ if (line === void 0) return;
2433
2359
  const prop = {
2434
2360
  ...getProperties(node),
2435
2361
  ...getLineStyle(get1(node, "extensions"))
@@ -2462,12 +2388,9 @@ function getLineStyle(extensions) {
2462
2388
  const color = nodeVal(get1(lineStyle, "color"));
2463
2389
  const opacity = Number.parseFloat(nodeVal(get1(lineStyle, "opacity")) ?? "0");
2464
2390
  const width = Number.parseFloat(nodeVal(get1(lineStyle, "width")) ?? "0");
2465
- if (color)
2466
- style.stroke = color;
2467
- if (!Number.isNaN(opacity))
2468
- style["stroke-opacity"] = opacity;
2469
- if (!Number.isNaN(width))
2470
- style["stroke-width"] = width * 96 / 25.4;
2391
+ if (color) style.stroke = color;
2392
+ if (!Number.isNaN(opacity)) style["stroke-opacity"] = opacity;
2393
+ if (!Number.isNaN(width)) style["stroke-width"] = width * 96 / 25.4;
2471
2394
  }
2472
2395
  }
2473
2396
  return style;
@@ -2496,8 +2419,7 @@ function getProperties(node) {
2496
2419
  }
2497
2420
  function okhash(x) {
2498
2421
  let h = 0;
2499
- if (!x || !x.length)
2500
- return h;
2422
+ if (!x || !x.length) return h;
2501
2423
  for (let i = 0; i < x.length; i++) {
2502
2424
  h = (h << 5) - h + x.charCodeAt(i) | 0;
2503
2425
  }
@@ -2517,16 +2439,14 @@ function get1(x, y) {
2517
2439
  return n.length ? n[0] : null;
2518
2440
  }
2519
2441
  function norm(el) {
2520
- if (el.normalize)
2521
- el.normalize();
2442
+ if (el.normalize) el.normalize();
2522
2443
  return el;
2523
2444
  }
2524
2445
  function numarray(x) {
2525
2446
  return x.map(Number.parseFloat).map((n) => Number.isNaN(n) ? null : n);
2526
2447
  }
2527
2448
  function nodeVal(x) {
2528
- if (x)
2529
- norm(x);
2449
+ if (x) norm(x);
2530
2450
  return x && x.textContent;
2531
2451
  }
2532
2452
  function getMulti(x, ys) {
@@ -2535,8 +2455,7 @@ function getMulti(x, ys) {
2535
2455
  let k;
2536
2456
  for (k = 0; k < ys.length; k++) {
2537
2457
  n = get1(x, ys[k]);
2538
- if (n)
2539
- o[ys[k]] = nodeVal(n) ?? "";
2458
+ if (n) o[ys[k]] = nodeVal(n) ?? "";
2540
2459
  }
2541
2460
  return o;
2542
2461
  }
@@ -2546,8 +2465,7 @@ function coord1(v) {
2546
2465
  function coord(v) {
2547
2466
  const coords = v.replace(/^\s*|\s*$/g, "").split(/\s+/);
2548
2467
  const out = [];
2549
- for (const coord2 of coords)
2550
- out.push(coord1(coord2));
2468
+ for (const coord2 of coords) out.push(coord1(coord2));
2551
2469
  return out;
2552
2470
  }
2553
2471
  function coordPair(x) {
@@ -2558,8 +2476,7 @@ function coordPair(x) {
2558
2476
  let e;
2559
2477
  if (ele) {
2560
2478
  e = Number.parseFloat(nodeVal(ele) ?? "0");
2561
- if (!Number.isNaN(e))
2562
- ll.push(e);
2479
+ if (!Number.isNaN(e)) ll.push(e);
2563
2480
  }
2564
2481
  return {
2565
2482
  coordinates: ll,
@@ -2570,8 +2487,7 @@ function coordPair(x) {
2570
2487
  function gpxOrKml(doc) {
2571
2488
  let actualDoc = doc;
2572
2489
  try {
2573
- if (typeof actualDoc === "string")
2574
- actualDoc = str2xml(actualDoc);
2490
+ if (typeof actualDoc === "string") actualDoc = str2xml(actualDoc);
2575
2491
  } catch (e) {
2576
2492
  return null;
2577
2493
  }
@@ -2744,8 +2660,7 @@ class ColorRamp extends Array {
2744
2660
  canvas.width = options.horizontal ? options.size : 1;
2745
2661
  canvas.height = options.horizontal ? 1 : options.size;
2746
2662
  const ctx = canvas.getContext("2d");
2747
- if (!ctx)
2748
- throw new Error("Canvs context is missing");
2663
+ if (!ctx) throw new Error("Canvs context is missing");
2749
2664
  const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
2750
2665
  const imageDataArray = imageData.data;
2751
2666
  const size = options.size;
@@ -3782,7 +3697,7 @@ async function addPolyline(map, options, fetchOptions = {}) {
3782
3697
  let data = options.data;
3783
3698
  if (typeof data === "string") {
3784
3699
  if (isUUID(data)) {
3785
- data = `https://api.maptiler.com/data/${options.data}/features.json?key=${config$1.apiKey}`;
3700
+ data = `https://api.maptiler.com/data/${options.data}/features.json?key=${config.apiKey}`;
3786
3701
  } else if (data.split(".").pop()?.toLowerCase().trim() === "gpx") {
3787
3702
  const res = await fetch(data, fetchOptions);
3788
3703
  const gpxStr = await res.text();
@@ -3793,8 +3708,7 @@ async function addPolyline(map, options, fetchOptions = {}) {
3793
3708
  data = kml(kmlStr);
3794
3709
  } else {
3795
3710
  const tmpData = jsonParseNoThrow(data) ?? gpxOrKml(data);
3796
- if (tmpData)
3797
- data = tmpData;
3711
+ if (tmpData) data = tmpData;
3798
3712
  }
3799
3713
  if (!data) {
3800
3714
  throw new Error("Polyline data was provided as string but is incompatible with valid formats.");
@@ -3902,7 +3816,7 @@ function addPolygon(map, options) {
3902
3816
  if (options.data && !map.getSource(sourceId)) {
3903
3817
  let data = options.data;
3904
3818
  if (typeof data === "string" && isUUID(data)) {
3905
- data = `https://api.maptiler.com/data/${data}/features.json?key=${config$1.apiKey}`;
3819
+ data = `https://api.maptiler.com/data/${data}/features.json?key=${config.apiKey}`;
3906
3820
  }
3907
3821
  map.addSource(sourceId, {
3908
3822
  type: "geojson",
@@ -4060,7 +3974,7 @@ function addPoint(map, options) {
4060
3974
  if (options.data && !map.getSource(sourceId)) {
4061
3975
  let data = options.data;
4062
3976
  if (typeof data === "string" && isUUID(data)) {
4063
- data = `https://api.maptiler.com/data/${data}/features.json?key=${config$1.apiKey}`;
3977
+ data = `https://api.maptiler.com/data/${data}/features.json?key=${config.apiKey}`;
4064
3978
  }
4065
3979
  map.addSource(sourceId, {
4066
3980
  type: "geojson",
@@ -4294,7 +4208,7 @@ function addHeatmap(map, options) {
4294
4208
  if (options.data && !map.getSource(sourceId)) {
4295
4209
  let data = options.data;
4296
4210
  if (typeof data === "string" && isUUID(data)) {
4297
- data = `https://api.maptiler.com/data/${data}/features.json?key=${config$1.apiKey}`;
4211
+ data = `https://api.maptiler.com/data/${data}/features.json?key=${config.apiKey}`;
4298
4212
  }
4299
4213
  map.addSource(sourceId, {
4300
4214
  type: "geojson",
@@ -4325,70 +4239,10 @@ const helpers = {
4325
4239
  addHeatmap
4326
4240
  };
4327
4241
 
4328
- const {
4329
- // supported,
4330
- setRTLTextPlugin,
4331
- getRTLTextPluginStatus,
4332
- LngLat,
4333
- LngLatBounds,
4334
- MercatorCoordinate,
4335
- Evented,
4336
- AJAXError,
4337
- prewarm,
4338
- clearPrewarmedResources,
4339
- addProtocol,
4340
- removeProtocol,
4341
- Hash,
4342
- Point,
4343
- config,
4344
- EdgeInsets,
4345
- DragRotateHandler,
4346
- DragPanHandler,
4347
- TwoFingersTouchZoomRotateHandler,
4348
- DoubleClickZoomHandler,
4349
- TwoFingersTouchZoomHandler,
4350
- TwoFingersTouchRotateHandler,
4351
- getWorkerCount,
4352
- setWorkerCount,
4353
- getMaxParallelImageRequests,
4354
- setMaxParallelImageRequests,
4355
- getWorkerUrl,
4356
- setWorkerUrl,
4357
- addSourceType,
4358
- importScriptInWorkers
4359
- } = maplibregl;
4242
+ enableRTL();
4360
4243
  function getVersion() {
4361
4244
  return packagejson.version;
4362
4245
  }
4363
- function getMapLibreVersion() {
4364
- return maplibregl.getVersion();
4365
- }
4366
- const MapMLGL = maplibregl.Map;
4367
- const MarkerMLGL = maplibregl.Marker;
4368
- const PopupMLGL = maplibregl.Popup;
4369
- const StyleMLGL = maplibregl.Style;
4370
- maplibregl.CanvasSource;
4371
- maplibregl.GeoJSONSource;
4372
- const ImageSourceMLGL = maplibregl.ImageSource;
4373
- const RasterTileSourceMLGL = maplibregl.RasterTileSource;
4374
- maplibregl.RasterDEMTileSource;
4375
- maplibregl.VectorTileSource;
4376
- const VideoSourceMLGL = maplibregl.VideoSource;
4377
- maplibregl.NavigationControl;
4378
- maplibregl.GeolocateControl;
4379
- maplibregl.AttributionControl;
4380
- maplibregl.LogoControl;
4381
- maplibregl.ScaleControl;
4382
- maplibregl.FullscreenControl;
4383
- maplibregl.TerrainControl;
4384
- const BoxZoomHandlerMLGL = maplibregl.BoxZoomHandler;
4385
- const ScrollZoomHandlerMLGL = maplibregl.ScrollZoomHandler;
4386
- const CooperativeGesturesHandlerMLGL = maplibregl.CooperativeGesturesHandler;
4387
- const KeyboardHandlerMLGL = maplibregl.KeyboardHandler;
4388
- const TwoFingersTouchPitchHandlerMLGL = maplibregl.TwoFingersTouchPitchHandler;
4389
- maplibregl.MapWheelEvent;
4390
- maplibregl.MapTouchEvent;
4391
- maplibregl.MapMouseEvent;
4392
4246
 
4393
- export { AttributionControl, BoxZoomHandler, BoxZoomHandlerMLGL, CanvasSource, ColorRamp, ColorRampCollection, CooperativeGesturesHandler, CooperativeGesturesHandlerMLGL, DoubleClickZoomHandler, DragPanHandler, DragRotateHandler, EdgeInsets, Evented, FullscreenControl, GeoJSONSource, GeolocateControl, GeolocationType, Hash, ImageSource, ImageSourceMLGL, KeyboardHandler, KeyboardHandlerMLGL, Language, LngLat, LngLatBounds, LogoControl, Map, MapMLGL, MapMouseEvent, MapTouchEvent, MapWheelEvent, MaptilerGeolocateControl, MaptilerLogoControl, MaptilerNavigationControl, MaptilerTerrainControl, Marker, MarkerMLGL, MercatorCoordinate, NavigationControl, Point, Popup, PopupMLGL, RasterDEMTileSource, RasterTileSource, RasterTileSourceMLGL, ScaleControl, ScrollZoomHandler, ScrollZoomHandlerMLGL, SdkConfig, Style, StyleMLGL, TerrainControl, TwoFingersTouchPitchHandler, TwoFingersTouchPitchHandlerMLGL, TwoFingersTouchRotateHandler, TwoFingersTouchZoomHandler, TwoFingersTouchZoomRotateHandler, VectorTileSource, 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 };
4247
+ export { AttributionControl, BoxZoomHandler, CanvasSource, ColorRamp, ColorRampCollection, CooperativeGesturesHandler, FullscreenControl, GeoJSONSource, GeolocateControl, GeolocationType, ImageSource, KeyboardHandler, Language, LogoControl, Map, MapMouseEvent, MapTouchEvent, MapWheelEvent, MaptilerGeolocateControl, MaptilerLogoControl, MaptilerNavigationControl, MaptilerTerrainControl, Marker$1 as Marker, NavigationControl, Popup, RasterDEMTileSource, RasterTileSource, ScaleControl, ScrollZoomHandler, SdkConfig, Style, TerrainControl, TwoFingersTouchPitchHandler, VectorTileSource, VideoSource, config, getBrowserLanguage, getVersion, gpx, gpxOrKml, hasChildNodeWithName, helpers, isLanguageSupported, kml, str2xml, xml2str };
4394
4248
  //# sourceMappingURL=maptiler-sdk.mjs.map