@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.
- package/CHANGELOG.md +10 -0
- package/demos/embedded-config.html +66 -0
- package/demos/maptiler-sdk.umd.js +25 -15
- package/demos/simple.html +3 -1
- package/demos/two-maps.html +71 -0
- package/dist/maptiler-sdk.d.ts +97 -61
- package/dist/maptiler-sdk.min.mjs +1 -1
- package/dist/maptiler-sdk.mjs +25 -15
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/maptiler-sdk.umd.js +25 -15
- package/dist/maptiler-sdk.umd.js.map +1 -1
- package/dist/maptiler-sdk.umd.min.js +4 -4
- package/package.json +1 -1
- package/readme.md +56 -12
- package/src/Map.ts +69 -30
package/dist/maptiler-sdk.mjs
CHANGED
|
@@ -537,7 +537,10 @@ const GeolocationType = {
|
|
|
537
537
|
};
|
|
538
538
|
class Map extends maplibregl__default.Map {
|
|
539
539
|
constructor(options) {
|
|
540
|
-
var _a;
|
|
540
|
+
var _a, _b;
|
|
541
|
+
if (options.apiKey) {
|
|
542
|
+
config.apiKey = options.apiKey;
|
|
543
|
+
}
|
|
541
544
|
const style = styleToStyle(options.style);
|
|
542
545
|
const hashPreConstructor = location.hash;
|
|
543
546
|
if (!config.apiKey) {
|
|
@@ -576,6 +579,10 @@ class Map extends maplibregl__default.Map {
|
|
|
576
579
|
this.isStyleInitialized = false;
|
|
577
580
|
this.isTerrainEnabled = false;
|
|
578
581
|
this.terrainExaggeration = 1;
|
|
582
|
+
this.primaryLanguage = null;
|
|
583
|
+
this.secondaryLanguage = null;
|
|
584
|
+
this.primaryLanguage = (_a = options.language) != null ? _a : config.primaryLanguage;
|
|
585
|
+
this.secondaryLanguage = config.secondaryLanguage;
|
|
579
586
|
this.once("styledata", () => __async(this, null, function* () {
|
|
580
587
|
if (options.geolocate === false) {
|
|
581
588
|
return;
|
|
@@ -625,18 +632,9 @@ class Map extends maplibregl__default.Map {
|
|
|
625
632
|
);
|
|
626
633
|
}
|
|
627
634
|
}));
|
|
628
|
-
this.on("styledataloading", () => {
|
|
629
|
-
this.languageShouldUpdate = !!config.primaryLanguage || !!config.secondaryLanguage;
|
|
630
|
-
});
|
|
631
635
|
this.on("styledata", () => {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
}
|
|
635
|
-
if (config.secondaryLanguage && (this.languageShouldUpdate || !this.isStyleInitialized)) {
|
|
636
|
-
this.setSecondaryLanguage(config.secondaryLanguage);
|
|
637
|
-
}
|
|
638
|
-
this.languageShouldUpdate = false;
|
|
639
|
-
this.isStyleInitialized = true;
|
|
636
|
+
this.setPrimaryLanguage(this.primaryLanguage);
|
|
637
|
+
this.setSecondaryLanguage(this.secondaryLanguage);
|
|
640
638
|
});
|
|
641
639
|
this.on("styledata", () => {
|
|
642
640
|
if (this.getTerrain() === null && this.isTerrainEnabled) {
|
|
@@ -716,7 +714,7 @@ class Map extends maplibregl__default.Map {
|
|
|
716
714
|
}));
|
|
717
715
|
if (options.terrain) {
|
|
718
716
|
this.enableTerrain(
|
|
719
|
-
(
|
|
717
|
+
(_b = options.terrainExaggeration) != null ? _b : this.terrainExaggeration
|
|
720
718
|
);
|
|
721
719
|
}
|
|
722
720
|
}
|
|
@@ -733,11 +731,11 @@ class Map extends maplibregl__default.Map {
|
|
|
733
731
|
if (!isLanguageSupported(language)) {
|
|
734
732
|
return;
|
|
735
733
|
}
|
|
734
|
+
this.primaryLanguage = language;
|
|
736
735
|
this.onStyleReady(() => {
|
|
737
736
|
if (language === Language.AUTO) {
|
|
738
737
|
return this.setPrimaryLanguage(getBrowserLanguage());
|
|
739
738
|
}
|
|
740
|
-
config.primaryLanguage = language;
|
|
741
739
|
const layers = this.getStyle().layers;
|
|
742
740
|
const strLanguageRegex = /^\s*{\s*name\s*(:\s*(\S*))?\s*}$/;
|
|
743
741
|
const strLanguageInArrayRegex = /^\s*name\s*(:\s*(\S*))?\s*$/;
|
|
@@ -807,11 +805,11 @@ class Map extends maplibregl__default.Map {
|
|
|
807
805
|
if (!isLanguageSupported(language)) {
|
|
808
806
|
return;
|
|
809
807
|
}
|
|
808
|
+
this.secondaryLanguage = language;
|
|
810
809
|
this.onStyleReady(() => {
|
|
811
810
|
if (language === Language.AUTO) {
|
|
812
811
|
return this.setSecondaryLanguage(getBrowserLanguage());
|
|
813
812
|
}
|
|
814
|
-
config.secondaryLanguage = language;
|
|
815
813
|
const layers = this.getStyle().layers;
|
|
816
814
|
const strLanguageRegex = /^\s*{\s*name\s*(:\s*(\S*))?\s*}$/;
|
|
817
815
|
const strLanguageInArrayRegex = /^\s*name\s*(:\s*(\S*))?\s*$/;
|
|
@@ -867,6 +865,12 @@ class Map extends maplibregl__default.Map {
|
|
|
867
865
|
}
|
|
868
866
|
});
|
|
869
867
|
}
|
|
868
|
+
getPrimaryLanguage() {
|
|
869
|
+
return this.primaryLanguage;
|
|
870
|
+
}
|
|
871
|
+
getSecondaryLanguage() {
|
|
872
|
+
return this.secondaryLanguage;
|
|
873
|
+
}
|
|
870
874
|
getTerrainExaggeration() {
|
|
871
875
|
return this.terrainExaggeration;
|
|
872
876
|
}
|
|
@@ -956,6 +960,12 @@ class Map extends maplibregl__default.Map {
|
|
|
956
960
|
hashBin[4] = this.getBearing();
|
|
957
961
|
return Base64.fromUint8Array(new Uint8Array(hashBin.buffer));
|
|
958
962
|
}
|
|
963
|
+
getSdkConfig() {
|
|
964
|
+
return config;
|
|
965
|
+
}
|
|
966
|
+
getMaptilerSessionId() {
|
|
967
|
+
return MAPTILER_SESSION_ID;
|
|
968
|
+
}
|
|
959
969
|
}
|
|
960
970
|
|
|
961
971
|
class Point {
|