@maptiler/sdk 1.0.5 → 1.0.7
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 +11 -0
- package/demos/embedded-config.html +66 -0
- package/demos/maptiler-sdk.umd.js +24 -10
- package/demos/simple.html +3 -1
- package/demos/two-maps.html +71 -0
- package/dist/maptiler-sdk.d.ts +137 -62
- package/dist/maptiler-sdk.min.mjs +1 -1
- package/dist/maptiler-sdk.mjs +22 -11
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/maptiler-sdk.umd.js +24 -10
- 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 +50 -7
- package/src/Map.ts +59 -15
- package/src/{CustomGeolocateControl.ts → MaptilerGeolocateControl.ts} +7 -1
- package/src/{CustomLogoControl.ts → MaptilerLogoControl.ts} +3 -2
- package/src/{TerrainControl.ts → MaptilerTerrainControl.ts} +3 -13
- package/src/index.ts +7 -0
package/dist/maptiler-sdk.umd.js
CHANGED
|
@@ -2248,7 +2248,7 @@
|
|
|
2248
2248
|
};
|
|
2249
2249
|
Object.freeze(defaults);
|
|
2250
2250
|
|
|
2251
|
-
class
|
|
2251
|
+
class MaptilerLogoControl extends maplibregl.LogoControl {
|
|
2252
2252
|
constructor(options = {}) {
|
|
2253
2253
|
var _a, _b;
|
|
2254
2254
|
super(options);
|
|
@@ -2341,7 +2341,7 @@
|
|
|
2341
2341
|
return style;
|
|
2342
2342
|
}
|
|
2343
2343
|
|
|
2344
|
-
class
|
|
2344
|
+
class MaptilerTerrainControl {
|
|
2345
2345
|
constructor() {
|
|
2346
2346
|
bindAll(["_toggleTerrain", "_updateTerrainIcon"], this);
|
|
2347
2347
|
}
|
|
@@ -2455,7 +2455,7 @@
|
|
|
2455
2455
|
const GeolocateControl$1 = maplibregl.GeolocateControl;
|
|
2456
2456
|
const Marker$1 = maplibregl.Marker;
|
|
2457
2457
|
const LngLat$1 = maplibregl.LngLat;
|
|
2458
|
-
class
|
|
2458
|
+
class MaptilerGeolocateControl extends GeolocateControl$1 {
|
|
2459
2459
|
constructor() {
|
|
2460
2460
|
super(...arguments);
|
|
2461
2461
|
this.lastUpdatedCenter = new LngLat$1(0, 0);
|
|
@@ -2644,6 +2644,9 @@
|
|
|
2644
2644
|
class Map$1 extends maplibregl.Map {
|
|
2645
2645
|
constructor(options) {
|
|
2646
2646
|
var _a;
|
|
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) {
|
|
@@ -2734,8 +2737,11 @@
|
|
|
2734
2737
|
this.on("styledataloading", () => {
|
|
2735
2738
|
this.languageShouldUpdate = !!config.primaryLanguage || !!config.secondaryLanguage;
|
|
2736
2739
|
});
|
|
2740
|
+
let initLanguageFromConstructor = true;
|
|
2737
2741
|
this.on("styledata", () => {
|
|
2738
|
-
if (
|
|
2742
|
+
if (options.language && initLanguageFromConstructor) {
|
|
2743
|
+
this.setPrimaryLanguage(options.language);
|
|
2744
|
+
} else if (config.primaryLanguage && (this.languageShouldUpdate || !this.isStyleInitialized)) {
|
|
2739
2745
|
this.setPrimaryLanguage(config.primaryLanguage);
|
|
2740
2746
|
}
|
|
2741
2747
|
if (config.secondaryLanguage && (this.languageShouldUpdate || !this.isStyleInitialized)) {
|
|
@@ -2743,6 +2749,7 @@
|
|
|
2743
2749
|
}
|
|
2744
2750
|
this.languageShouldUpdate = false;
|
|
2745
2751
|
this.isStyleInitialized = true;
|
|
2752
|
+
initLanguageFromConstructor = false;
|
|
2746
2753
|
});
|
|
2747
2754
|
this.on("styledata", () => {
|
|
2748
2755
|
if (this.getTerrain() === null && this.isTerrainEnabled) {
|
|
@@ -2771,14 +2778,14 @@
|
|
|
2771
2778
|
if ("logo" in tileJsonContent && tileJsonContent.logo) {
|
|
2772
2779
|
const logoURL = tileJsonContent.logo;
|
|
2773
2780
|
this.addControl(
|
|
2774
|
-
new
|
|
2781
|
+
new MaptilerLogoControl({ logoURL }),
|
|
2775
2782
|
options.logoPosition
|
|
2776
2783
|
);
|
|
2777
2784
|
if (options.attributionControl === false) {
|
|
2778
2785
|
this.addControl(new maplibregl.AttributionControl(options));
|
|
2779
2786
|
}
|
|
2780
2787
|
} else if (options.maptilerLogo) {
|
|
2781
|
-
this.addControl(new
|
|
2788
|
+
this.addControl(new MaptilerLogoControl(), options.logoPosition);
|
|
2782
2789
|
}
|
|
2783
2790
|
if (options.scaleControl) {
|
|
2784
2791
|
const position = options.scaleControl === true || options.scaleControl === void 0 ? "bottom-right" : options.scaleControl;
|
|
@@ -2795,7 +2802,7 @@
|
|
|
2795
2802
|
if (options.geolocateControl !== false) {
|
|
2796
2803
|
const position = options.geolocateControl === true || options.geolocateControl === void 0 ? "top-right" : options.geolocateControl;
|
|
2797
2804
|
this.addControl(
|
|
2798
|
-
new
|
|
2805
|
+
new MaptilerGeolocateControl({
|
|
2799
2806
|
positionOptions: {
|
|
2800
2807
|
enableHighAccuracy: true,
|
|
2801
2808
|
maximumAge: 0,
|
|
@@ -2813,7 +2820,7 @@
|
|
|
2813
2820
|
}
|
|
2814
2821
|
if (options.terrainControl) {
|
|
2815
2822
|
const position = options.terrainControl === true || options.terrainControl === void 0 ? "top-right" : options.terrainControl;
|
|
2816
|
-
this.addControl(new
|
|
2823
|
+
this.addControl(new MaptilerTerrainControl(), position);
|
|
2817
2824
|
}
|
|
2818
2825
|
if (options.fullscreenControl) {
|
|
2819
2826
|
const position = options.fullscreenControl === true || options.fullscreenControl === void 0 ? "top-right" : options.fullscreenControl;
|
|
@@ -2843,7 +2850,6 @@
|
|
|
2843
2850
|
if (language === Language.AUTO) {
|
|
2844
2851
|
return this.setPrimaryLanguage(getBrowserLanguage());
|
|
2845
2852
|
}
|
|
2846
|
-
config.primaryLanguage = language;
|
|
2847
2853
|
const layers = this.getStyle().layers;
|
|
2848
2854
|
const strLanguageRegex = /^\s*{\s*name\s*(:\s*(\S*))?\s*}$/;
|
|
2849
2855
|
const strLanguageInArrayRegex = /^\s*name\s*(:\s*(\S*))?\s*$/;
|
|
@@ -2917,7 +2923,6 @@
|
|
|
2917
2923
|
if (language === Language.AUTO) {
|
|
2918
2924
|
return this.setSecondaryLanguage(getBrowserLanguage());
|
|
2919
2925
|
}
|
|
2920
|
-
config.secondaryLanguage = language;
|
|
2921
2926
|
const layers = this.getStyle().layers;
|
|
2922
2927
|
const strLanguageRegex = /^\s*{\s*name\s*(:\s*(\S*))?\s*}$/;
|
|
2923
2928
|
const strLanguageInArrayRegex = /^\s*name\s*(:\s*(\S*))?\s*$/;
|
|
@@ -3062,6 +3067,12 @@
|
|
|
3062
3067
|
hashBin[4] = this.getBearing();
|
|
3063
3068
|
return gBase64.fromUint8Array(new Uint8Array(hashBin.buffer));
|
|
3064
3069
|
}
|
|
3070
|
+
getSdkConfig() {
|
|
3071
|
+
return config;
|
|
3072
|
+
}
|
|
3073
|
+
getMaptilerSessionId() {
|
|
3074
|
+
return MAPTILER_SESSION_ID;
|
|
3075
|
+
}
|
|
3065
3076
|
}
|
|
3066
3077
|
|
|
3067
3078
|
class Point {
|
|
@@ -3269,6 +3280,9 @@
|
|
|
3269
3280
|
exports.Map = Map$1;
|
|
3270
3281
|
exports.MapStyle = MapStyle;
|
|
3271
3282
|
exports.MapStyleVariant = MapStyleVariant;
|
|
3283
|
+
exports.MaptilerGeolocateControl = MaptilerGeolocateControl;
|
|
3284
|
+
exports.MaptilerLogoControl = MaptilerLogoControl;
|
|
3285
|
+
exports.MaptilerTerrainControl = MaptilerTerrainControl;
|
|
3272
3286
|
exports.Marker = Marker;
|
|
3273
3287
|
exports.MercatorCoordinate = MercatorCoordinate;
|
|
3274
3288
|
exports.NavigationControl = NavigationControl;
|