@maptiler/sdk 1.0.6 → 1.0.8

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.
@@ -2643,7 +2643,10 @@
2643
2643
  };
2644
2644
  class Map$1 extends maplibregl.Map {
2645
2645
  constructor(options) {
2646
- var _a;
2646
+ var _a, _b;
2647
+ if (options.apiKey) {
2648
+ config.apiKey = options.apiKey;
2649
+ }
2647
2650
  const style = styleToStyle(options.style);
2648
2651
  const hashPreConstructor = location.hash;
2649
2652
  if (!config.apiKey) {
@@ -2682,6 +2685,10 @@
2682
2685
  this.isStyleInitialized = false;
2683
2686
  this.isTerrainEnabled = false;
2684
2687
  this.terrainExaggeration = 1;
2688
+ this.primaryLanguage = null;
2689
+ this.secondaryLanguage = null;
2690
+ this.primaryLanguage = (_a = options.language) != null ? _a : config.primaryLanguage;
2691
+ this.secondaryLanguage = config.secondaryLanguage;
2685
2692
  this.once("styledata", () => __async(this, null, function* () {
2686
2693
  if (options.geolocate === false) {
2687
2694
  return;
@@ -2731,18 +2738,9 @@
2731
2738
  );
2732
2739
  }
2733
2740
  }));
2734
- this.on("styledataloading", () => {
2735
- this.languageShouldUpdate = !!config.primaryLanguage || !!config.secondaryLanguage;
2736
- });
2737
2741
  this.on("styledata", () => {
2738
- if (config.primaryLanguage && (this.languageShouldUpdate || !this.isStyleInitialized)) {
2739
- this.setPrimaryLanguage(config.primaryLanguage);
2740
- }
2741
- if (config.secondaryLanguage && (this.languageShouldUpdate || !this.isStyleInitialized)) {
2742
- this.setSecondaryLanguage(config.secondaryLanguage);
2743
- }
2744
- this.languageShouldUpdate = false;
2745
- this.isStyleInitialized = true;
2742
+ this.setPrimaryLanguage(this.primaryLanguage);
2743
+ this.setSecondaryLanguage(this.secondaryLanguage);
2746
2744
  });
2747
2745
  this.on("styledata", () => {
2748
2746
  if (this.getTerrain() === null && this.isTerrainEnabled) {
@@ -2822,7 +2820,7 @@
2822
2820
  }));
2823
2821
  if (options.terrain) {
2824
2822
  this.enableTerrain(
2825
- (_a = options.terrainExaggeration) != null ? _a : this.terrainExaggeration
2823
+ (_b = options.terrainExaggeration) != null ? _b : this.terrainExaggeration
2826
2824
  );
2827
2825
  }
2828
2826
  }
@@ -2839,11 +2837,11 @@
2839
2837
  if (!isLanguageSupported(language)) {
2840
2838
  return;
2841
2839
  }
2840
+ this.primaryLanguage = language;
2842
2841
  this.onStyleReady(() => {
2843
2842
  if (language === Language.AUTO) {
2844
2843
  return this.setPrimaryLanguage(getBrowserLanguage());
2845
2844
  }
2846
- config.primaryLanguage = language;
2847
2845
  const layers = this.getStyle().layers;
2848
2846
  const strLanguageRegex = /^\s*{\s*name\s*(:\s*(\S*))?\s*}$/;
2849
2847
  const strLanguageInArrayRegex = /^\s*name\s*(:\s*(\S*))?\s*$/;
@@ -2913,11 +2911,11 @@
2913
2911
  if (!isLanguageSupported(language)) {
2914
2912
  return;
2915
2913
  }
2914
+ this.secondaryLanguage = language;
2916
2915
  this.onStyleReady(() => {
2917
2916
  if (language === Language.AUTO) {
2918
2917
  return this.setSecondaryLanguage(getBrowserLanguage());
2919
2918
  }
2920
- config.secondaryLanguage = language;
2921
2919
  const layers = this.getStyle().layers;
2922
2920
  const strLanguageRegex = /^\s*{\s*name\s*(:\s*(\S*))?\s*}$/;
2923
2921
  const strLanguageInArrayRegex = /^\s*name\s*(:\s*(\S*))?\s*$/;
@@ -2973,6 +2971,12 @@
2973
2971
  }
2974
2972
  });
2975
2973
  }
2974
+ getPrimaryLanguage() {
2975
+ return this.primaryLanguage;
2976
+ }
2977
+ getSecondaryLanguage() {
2978
+ return this.secondaryLanguage;
2979
+ }
2976
2980
  getTerrainExaggeration() {
2977
2981
  return this.terrainExaggeration;
2978
2982
  }
@@ -3062,6 +3066,12 @@
3062
3066
  hashBin[4] = this.getBearing();
3063
3067
  return gBase64.fromUint8Array(new Uint8Array(hashBin.buffer));
3064
3068
  }
3069
+ getSdkConfig() {
3070
+ return config;
3071
+ }
3072
+ getMaptilerSessionId() {
3073
+ return MAPTILER_SESSION_ID;
3074
+ }
3065
3075
  }
3066
3076
 
3067
3077
  class Point {