@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.mjs
CHANGED
|
@@ -142,7 +142,7 @@ const defaults = {
|
|
|
142
142
|
};
|
|
143
143
|
Object.freeze(defaults);
|
|
144
144
|
|
|
145
|
-
class
|
|
145
|
+
class MaptilerLogoControl extends maplibregl__default.LogoControl {
|
|
146
146
|
constructor(options = {}) {
|
|
147
147
|
var _a, _b;
|
|
148
148
|
super(options);
|
|
@@ -235,7 +235,7 @@ function styleToStyle(style) {
|
|
|
235
235
|
return style;
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
class
|
|
238
|
+
class MaptilerTerrainControl {
|
|
239
239
|
constructor() {
|
|
240
240
|
bindAll(["_toggleTerrain", "_updateTerrainIcon"], this);
|
|
241
241
|
}
|
|
@@ -349,7 +349,7 @@ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
|
349
349
|
const GeolocateControl$1 = maplibregl__default.GeolocateControl;
|
|
350
350
|
const Marker$1 = maplibregl__default.Marker;
|
|
351
351
|
const LngLat$1 = maplibregl__default.LngLat;
|
|
352
|
-
class
|
|
352
|
+
class MaptilerGeolocateControl extends GeolocateControl$1 {
|
|
353
353
|
constructor() {
|
|
354
354
|
super(...arguments);
|
|
355
355
|
this.lastUpdatedCenter = new LngLat$1(0, 0);
|
|
@@ -538,6 +538,9 @@ const GeolocationType = {
|
|
|
538
538
|
class Map extends maplibregl__default.Map {
|
|
539
539
|
constructor(options) {
|
|
540
540
|
var _a;
|
|
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) {
|
|
@@ -628,8 +631,11 @@ class Map extends maplibregl__default.Map {
|
|
|
628
631
|
this.on("styledataloading", () => {
|
|
629
632
|
this.languageShouldUpdate = !!config.primaryLanguage || !!config.secondaryLanguage;
|
|
630
633
|
});
|
|
634
|
+
let initLanguageFromConstructor = true;
|
|
631
635
|
this.on("styledata", () => {
|
|
632
|
-
if (
|
|
636
|
+
if (options.language && initLanguageFromConstructor) {
|
|
637
|
+
this.setPrimaryLanguage(options.language);
|
|
638
|
+
} else if (config.primaryLanguage && (this.languageShouldUpdate || !this.isStyleInitialized)) {
|
|
633
639
|
this.setPrimaryLanguage(config.primaryLanguage);
|
|
634
640
|
}
|
|
635
641
|
if (config.secondaryLanguage && (this.languageShouldUpdate || !this.isStyleInitialized)) {
|
|
@@ -637,6 +643,7 @@ class Map extends maplibregl__default.Map {
|
|
|
637
643
|
}
|
|
638
644
|
this.languageShouldUpdate = false;
|
|
639
645
|
this.isStyleInitialized = true;
|
|
646
|
+
initLanguageFromConstructor = false;
|
|
640
647
|
});
|
|
641
648
|
this.on("styledata", () => {
|
|
642
649
|
if (this.getTerrain() === null && this.isTerrainEnabled) {
|
|
@@ -665,14 +672,14 @@ class Map extends maplibregl__default.Map {
|
|
|
665
672
|
if ("logo" in tileJsonContent && tileJsonContent.logo) {
|
|
666
673
|
const logoURL = tileJsonContent.logo;
|
|
667
674
|
this.addControl(
|
|
668
|
-
new
|
|
675
|
+
new MaptilerLogoControl({ logoURL }),
|
|
669
676
|
options.logoPosition
|
|
670
677
|
);
|
|
671
678
|
if (options.attributionControl === false) {
|
|
672
679
|
this.addControl(new maplibregl__default.AttributionControl(options));
|
|
673
680
|
}
|
|
674
681
|
} else if (options.maptilerLogo) {
|
|
675
|
-
this.addControl(new
|
|
682
|
+
this.addControl(new MaptilerLogoControl(), options.logoPosition);
|
|
676
683
|
}
|
|
677
684
|
if (options.scaleControl) {
|
|
678
685
|
const position = options.scaleControl === true || options.scaleControl === void 0 ? "bottom-right" : options.scaleControl;
|
|
@@ -689,7 +696,7 @@ class Map extends maplibregl__default.Map {
|
|
|
689
696
|
if (options.geolocateControl !== false) {
|
|
690
697
|
const position = options.geolocateControl === true || options.geolocateControl === void 0 ? "top-right" : options.geolocateControl;
|
|
691
698
|
this.addControl(
|
|
692
|
-
new
|
|
699
|
+
new MaptilerGeolocateControl({
|
|
693
700
|
positionOptions: {
|
|
694
701
|
enableHighAccuracy: true,
|
|
695
702
|
maximumAge: 0,
|
|
@@ -707,7 +714,7 @@ class Map extends maplibregl__default.Map {
|
|
|
707
714
|
}
|
|
708
715
|
if (options.terrainControl) {
|
|
709
716
|
const position = options.terrainControl === true || options.terrainControl === void 0 ? "top-right" : options.terrainControl;
|
|
710
|
-
this.addControl(new
|
|
717
|
+
this.addControl(new MaptilerTerrainControl(), position);
|
|
711
718
|
}
|
|
712
719
|
if (options.fullscreenControl) {
|
|
713
720
|
const position = options.fullscreenControl === true || options.fullscreenControl === void 0 ? "top-right" : options.fullscreenControl;
|
|
@@ -737,7 +744,6 @@ class Map extends maplibregl__default.Map {
|
|
|
737
744
|
if (language === Language.AUTO) {
|
|
738
745
|
return this.setPrimaryLanguage(getBrowserLanguage());
|
|
739
746
|
}
|
|
740
|
-
config.primaryLanguage = language;
|
|
741
747
|
const layers = this.getStyle().layers;
|
|
742
748
|
const strLanguageRegex = /^\s*{\s*name\s*(:\s*(\S*))?\s*}$/;
|
|
743
749
|
const strLanguageInArrayRegex = /^\s*name\s*(:\s*(\S*))?\s*$/;
|
|
@@ -811,7 +817,6 @@ class Map extends maplibregl__default.Map {
|
|
|
811
817
|
if (language === Language.AUTO) {
|
|
812
818
|
return this.setSecondaryLanguage(getBrowserLanguage());
|
|
813
819
|
}
|
|
814
|
-
config.secondaryLanguage = language;
|
|
815
820
|
const layers = this.getStyle().layers;
|
|
816
821
|
const strLanguageRegex = /^\s*{\s*name\s*(:\s*(\S*))?\s*}$/;
|
|
817
822
|
const strLanguageInArrayRegex = /^\s*name\s*(:\s*(\S*))?\s*$/;
|
|
@@ -956,6 +961,12 @@ class Map extends maplibregl__default.Map {
|
|
|
956
961
|
hashBin[4] = this.getBearing();
|
|
957
962
|
return Base64.fromUint8Array(new Uint8Array(hashBin.buffer));
|
|
958
963
|
}
|
|
964
|
+
getSdkConfig() {
|
|
965
|
+
return config;
|
|
966
|
+
}
|
|
967
|
+
getMaptilerSessionId() {
|
|
968
|
+
return MAPTILER_SESSION_ID;
|
|
969
|
+
}
|
|
959
970
|
}
|
|
960
971
|
|
|
961
972
|
class Point {
|
|
@@ -1146,5 +1157,5 @@ const {
|
|
|
1146
1157
|
removeProtocol
|
|
1147
1158
|
} = maplibregl__default;
|
|
1148
1159
|
|
|
1149
|
-
export { AJAXError, AttributionControl, CanvasSource, Evented, FullscreenControl, GeoJSONSource, GeolocateControl, GeolocationType, ImageSource, Language, LngLat, LngLatBounds, LogoControl, Map, Marker, MercatorCoordinate, NavigationControl, Point, Popup, RasterDEMTileSource, RasterTileSource, ScaleControl, SdkConfig, Style, TerrainControl, VectorTileSource, VideoSource, addProtocol, clearPrewarmedResources, clearStorage, config, getRTLTextPluginStatus, maxParallelImageRequests, prewarm, removeProtocol, setRTLTextPlugin, supported, version, workerCount, workerUrl };
|
|
1160
|
+
export { AJAXError, AttributionControl, CanvasSource, Evented, FullscreenControl, GeoJSONSource, GeolocateControl, GeolocationType, ImageSource, Language, LngLat, LngLatBounds, LogoControl, Map, MaptilerGeolocateControl, MaptilerLogoControl, MaptilerTerrainControl, Marker, MercatorCoordinate, NavigationControl, Point, Popup, RasterDEMTileSource, RasterTileSource, ScaleControl, SdkConfig, Style, TerrainControl, VectorTileSource, VideoSource, addProtocol, clearPrewarmedResources, clearStorage, config, getRTLTextPluginStatus, maxParallelImageRequests, prewarm, removeProtocol, setRTLTextPlugin, supported, version, workerCount, workerUrl };
|
|
1150
1161
|
//# sourceMappingURL=maptiler-sdk.mjs.map
|