@maptiler/sdk 1.0.7 → 1.0.9
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 +55 -0
- package/demos/maptiler-sdk.umd.js +240 -79
- package/demos/simple.html +3 -2
- package/dist/maptiler-sdk.d.ts +200 -30
- package/dist/maptiler-sdk.min.mjs +1 -1
- package/dist/maptiler-sdk.mjs +144 -45
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/maptiler-sdk.umd.js +240 -79
- package/dist/maptiler-sdk.umd.js.map +1 -1
- package/dist/maptiler-sdk.umd.min.js +30 -30
- package/package.json +2 -2
- package/readme.md +9 -5
- package/src/AttributionControl.ts +13 -0
- package/src/CanvasSource.ts +13 -0
- package/src/FullscreenControl.ts +13 -0
- package/src/GeoJSONSource.ts +13 -0
- package/src/GeolocateControl.ts +13 -0
- package/src/ImageSource.ts +13 -0
- package/src/LogoControl.ts +13 -0
- package/src/Map.ts +36 -43
- package/src/MaptilerGeolocateControl.ts +1 -1
- package/src/MaptilerLogoControl.ts +2 -1
- package/src/MaptilerNavigationControl.ts +2 -2
- package/src/Marker.ts +13 -0
- package/src/NavigationControl.ts +13 -0
- package/src/Popup.ts +13 -0
- package/src/RasterDEMTileSource.ts +13 -0
- package/src/RasterTileSource.ts +13 -0
- package/src/ScaleControl.ts +13 -0
- package/src/Style.ts +13 -0
- package/src/TerrainControl.ts +13 -0
- package/src/VectorTileSource.ts +13 -0
- package/src/VideoSource.ts +13 -0
- package/src/index.ts +111 -35
package/dist/maptiler-sdk.mjs
CHANGED
|
@@ -142,7 +142,13 @@ const defaults = {
|
|
|
142
142
|
};
|
|
143
143
|
Object.freeze(defaults);
|
|
144
144
|
|
|
145
|
-
class
|
|
145
|
+
class LogoControl extends maplibregl__default.LogoControl {
|
|
146
|
+
onAdd(map) {
|
|
147
|
+
return super.onAdd(map);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
class MaptilerLogoControl extends LogoControl {
|
|
146
152
|
constructor(options = {}) {
|
|
147
153
|
var _a, _b;
|
|
148
154
|
super(options);
|
|
@@ -287,7 +293,13 @@ class MaptilerTerrainControl {
|
|
|
287
293
|
}
|
|
288
294
|
}
|
|
289
295
|
|
|
290
|
-
class
|
|
296
|
+
class NavigationControl extends maplibregl__default.NavigationControl {
|
|
297
|
+
onAdd(map) {
|
|
298
|
+
return super.onAdd(map);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
class MaptilerNavigationControl extends NavigationControl {
|
|
291
303
|
constructor() {
|
|
292
304
|
super({
|
|
293
305
|
showCompass: true,
|
|
@@ -327,6 +339,12 @@ class MaptilerNavigationControl extends maplibregl__default.NavigationControl {
|
|
|
327
339
|
}
|
|
328
340
|
}
|
|
329
341
|
|
|
342
|
+
class GeolocateControl extends maplibregl__default.GeolocateControl {
|
|
343
|
+
onAdd(map) {
|
|
344
|
+
return super.onAdd(map);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
330
348
|
var __defProp$1 = Object.defineProperty;
|
|
331
349
|
var __defProps$1 = Object.defineProperties;
|
|
332
350
|
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
@@ -346,10 +364,9 @@ var __spreadValues$1 = (a, b) => {
|
|
|
346
364
|
return a;
|
|
347
365
|
};
|
|
348
366
|
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
349
|
-
const GeolocateControl$1 = maplibregl__default.GeolocateControl;
|
|
350
367
|
const Marker$1 = maplibregl__default.Marker;
|
|
351
368
|
const LngLat$1 = maplibregl__default.LngLat;
|
|
352
|
-
class MaptilerGeolocateControl extends GeolocateControl
|
|
369
|
+
class MaptilerGeolocateControl extends GeolocateControl {
|
|
353
370
|
constructor() {
|
|
354
371
|
super(...arguments);
|
|
355
372
|
this.lastUpdatedCenter = new LngLat$1(0, 0);
|
|
@@ -491,6 +508,24 @@ class MaptilerGeolocateControl extends GeolocateControl$1 {
|
|
|
491
508
|
}
|
|
492
509
|
}
|
|
493
510
|
|
|
511
|
+
class AttributionControl extends maplibregl__default.AttributionControl {
|
|
512
|
+
onAdd(map) {
|
|
513
|
+
return super.onAdd(map);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
class ScaleControl extends maplibregl__default.ScaleControl {
|
|
518
|
+
onAdd(map) {
|
|
519
|
+
return super.onAdd(map);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
class FullscreenControl extends maplibregl__default.FullscreenControl {
|
|
524
|
+
onAdd(map) {
|
|
525
|
+
return super.onAdd(map);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
494
529
|
var __defProp = Object.defineProperty;
|
|
495
530
|
var __defProps = Object.defineProperties;
|
|
496
531
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -537,7 +572,7 @@ const GeolocationType = {
|
|
|
537
572
|
};
|
|
538
573
|
class Map extends maplibregl__default.Map {
|
|
539
574
|
constructor(options) {
|
|
540
|
-
var _a;
|
|
575
|
+
var _a, _b;
|
|
541
576
|
if (options.apiKey) {
|
|
542
577
|
config.apiKey = options.apiKey;
|
|
543
578
|
}
|
|
@@ -575,12 +610,14 @@ class Map extends maplibregl__default.Map {
|
|
|
575
610
|
};
|
|
576
611
|
}
|
|
577
612
|
}));
|
|
578
|
-
this.languageShouldUpdate = false;
|
|
579
|
-
this.isStyleInitialized = false;
|
|
580
613
|
this.isTerrainEnabled = false;
|
|
581
614
|
this.terrainExaggeration = 1;
|
|
615
|
+
this.primaryLanguage = null;
|
|
616
|
+
this.secondaryLanguage = null;
|
|
617
|
+
this.primaryLanguage = (_a = options.language) != null ? _a : config.primaryLanguage;
|
|
618
|
+
this.secondaryLanguage = config.secondaryLanguage;
|
|
582
619
|
this.once("styledata", () => __async(this, null, function* () {
|
|
583
|
-
if (options.geolocate
|
|
620
|
+
if (!options.geolocate) {
|
|
584
621
|
return;
|
|
585
622
|
}
|
|
586
623
|
if (options.center) {
|
|
@@ -628,22 +665,9 @@ class Map extends maplibregl__default.Map {
|
|
|
628
665
|
);
|
|
629
666
|
}
|
|
630
667
|
}));
|
|
631
|
-
this.on("styledataloading", () => {
|
|
632
|
-
this.languageShouldUpdate = !!config.primaryLanguage || !!config.secondaryLanguage;
|
|
633
|
-
});
|
|
634
|
-
let initLanguageFromConstructor = true;
|
|
635
668
|
this.on("styledata", () => {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
} else if (config.primaryLanguage && (this.languageShouldUpdate || !this.isStyleInitialized)) {
|
|
639
|
-
this.setPrimaryLanguage(config.primaryLanguage);
|
|
640
|
-
}
|
|
641
|
-
if (config.secondaryLanguage && (this.languageShouldUpdate || !this.isStyleInitialized)) {
|
|
642
|
-
this.setSecondaryLanguage(config.secondaryLanguage);
|
|
643
|
-
}
|
|
644
|
-
this.languageShouldUpdate = false;
|
|
645
|
-
this.isStyleInitialized = true;
|
|
646
|
-
initLanguageFromConstructor = false;
|
|
669
|
+
this.setPrimaryLanguage(this.primaryLanguage);
|
|
670
|
+
this.setSecondaryLanguage(this.secondaryLanguage);
|
|
647
671
|
});
|
|
648
672
|
this.on("styledata", () => {
|
|
649
673
|
if (this.getTerrain() === null && this.isTerrainEnabled) {
|
|
@@ -676,14 +700,14 @@ class Map extends maplibregl__default.Map {
|
|
|
676
700
|
options.logoPosition
|
|
677
701
|
);
|
|
678
702
|
if (options.attributionControl === false) {
|
|
679
|
-
this.addControl(new
|
|
703
|
+
this.addControl(new AttributionControl(options));
|
|
680
704
|
}
|
|
681
705
|
} else if (options.maptilerLogo) {
|
|
682
706
|
this.addControl(new MaptilerLogoControl(), options.logoPosition);
|
|
683
707
|
}
|
|
684
708
|
if (options.scaleControl) {
|
|
685
709
|
const position = options.scaleControl === true || options.scaleControl === void 0 ? "bottom-right" : options.scaleControl;
|
|
686
|
-
const scaleControl = new
|
|
710
|
+
const scaleControl = new ScaleControl({ unit: config.unit });
|
|
687
711
|
this.addControl(scaleControl, position);
|
|
688
712
|
config.on("unit", (unit) => {
|
|
689
713
|
scaleControl.setUnit(unit);
|
|
@@ -718,12 +742,12 @@ class Map extends maplibregl__default.Map {
|
|
|
718
742
|
}
|
|
719
743
|
if (options.fullscreenControl) {
|
|
720
744
|
const position = options.fullscreenControl === true || options.fullscreenControl === void 0 ? "top-right" : options.fullscreenControl;
|
|
721
|
-
this.addControl(new
|
|
745
|
+
this.addControl(new FullscreenControl({}), position);
|
|
722
746
|
}
|
|
723
747
|
}));
|
|
724
748
|
if (options.terrain) {
|
|
725
749
|
this.enableTerrain(
|
|
726
|
-
(
|
|
750
|
+
(_b = options.terrainExaggeration) != null ? _b : this.terrainExaggeration
|
|
727
751
|
);
|
|
728
752
|
}
|
|
729
753
|
}
|
|
@@ -740,6 +764,7 @@ class Map extends maplibregl__default.Map {
|
|
|
740
764
|
if (!isLanguageSupported(language)) {
|
|
741
765
|
return;
|
|
742
766
|
}
|
|
767
|
+
this.primaryLanguage = language;
|
|
743
768
|
this.onStyleReady(() => {
|
|
744
769
|
if (language === Language.AUTO) {
|
|
745
770
|
return this.setPrimaryLanguage(getBrowserLanguage());
|
|
@@ -813,6 +838,7 @@ class Map extends maplibregl__default.Map {
|
|
|
813
838
|
if (!isLanguageSupported(language)) {
|
|
814
839
|
return;
|
|
815
840
|
}
|
|
841
|
+
this.secondaryLanguage = language;
|
|
816
842
|
this.onStyleReady(() => {
|
|
817
843
|
if (language === Language.AUTO) {
|
|
818
844
|
return this.setSecondaryLanguage(getBrowserLanguage());
|
|
@@ -872,6 +898,12 @@ class Map extends maplibregl__default.Map {
|
|
|
872
898
|
}
|
|
873
899
|
});
|
|
874
900
|
}
|
|
901
|
+
getPrimaryLanguage() {
|
|
902
|
+
return this.primaryLanguage;
|
|
903
|
+
}
|
|
904
|
+
getSecondaryLanguage() {
|
|
905
|
+
return this.secondaryLanguage;
|
|
906
|
+
}
|
|
875
907
|
getTerrainExaggeration() {
|
|
876
908
|
return this.terrainExaggeration;
|
|
877
909
|
}
|
|
@@ -969,6 +1001,72 @@ class Map extends maplibregl__default.Map {
|
|
|
969
1001
|
}
|
|
970
1002
|
}
|
|
971
1003
|
|
|
1004
|
+
class Marker extends maplibregl__default.Marker {
|
|
1005
|
+
addTo(map) {
|
|
1006
|
+
return super.addTo(map);
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
class Popup extends maplibregl__default.Popup {
|
|
1011
|
+
addTo(map) {
|
|
1012
|
+
return super.addTo(map);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
class Style extends maplibregl__default.Style {
|
|
1017
|
+
constructor(map, options = {}) {
|
|
1018
|
+
super(map, options);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
class CanvasSource extends maplibregl__default.CanvasSource {
|
|
1023
|
+
onAdd(map) {
|
|
1024
|
+
super.onAdd(map);
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
class GeoJSONSource extends maplibregl__default.GeoJSONSource {
|
|
1029
|
+
onAdd(map) {
|
|
1030
|
+
super.onAdd(map);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
class ImageSource extends maplibregl__default.ImageSource {
|
|
1035
|
+
onAdd(map) {
|
|
1036
|
+
super.onAdd(map);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
class RasterTileSource extends maplibregl__default.RasterTileSource {
|
|
1041
|
+
onAdd(map) {
|
|
1042
|
+
super.onAdd(map);
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
class RasterDEMTileSource extends maplibregl__default.RasterDEMTileSource {
|
|
1047
|
+
onAdd(map) {
|
|
1048
|
+
super.onAdd(map);
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
class VectorTileSource extends maplibregl__default.VectorTileSource {
|
|
1053
|
+
onAdd(map) {
|
|
1054
|
+
super.onAdd(map);
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
class VideoSource extends maplibregl__default.VideoSource {
|
|
1059
|
+
onAdd(map) {
|
|
1060
|
+
super.onAdd(map);
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
class TerrainControl extends maplibregl__default.TerrainControl {
|
|
1065
|
+
onAdd(map) {
|
|
1066
|
+
return super.onAdd(map);
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
|
|
972
1070
|
class Point {
|
|
973
1071
|
constructor(x, y) {
|
|
974
1072
|
this.x = x;
|
|
@@ -1124,28 +1222,11 @@ const {
|
|
|
1124
1222
|
supported,
|
|
1125
1223
|
setRTLTextPlugin,
|
|
1126
1224
|
getRTLTextPluginStatus,
|
|
1127
|
-
NavigationControl,
|
|
1128
|
-
GeolocateControl,
|
|
1129
|
-
AttributionControl,
|
|
1130
|
-
LogoControl,
|
|
1131
|
-
ScaleControl,
|
|
1132
|
-
FullscreenControl,
|
|
1133
|
-
TerrainControl,
|
|
1134
|
-
Popup,
|
|
1135
|
-
Marker,
|
|
1136
|
-
Style,
|
|
1137
1225
|
LngLat,
|
|
1138
1226
|
LngLatBounds,
|
|
1139
1227
|
MercatorCoordinate,
|
|
1140
1228
|
Evented,
|
|
1141
1229
|
AJAXError,
|
|
1142
|
-
CanvasSource,
|
|
1143
|
-
GeoJSONSource,
|
|
1144
|
-
ImageSource,
|
|
1145
|
-
RasterDEMTileSource,
|
|
1146
|
-
RasterTileSource,
|
|
1147
|
-
VectorTileSource,
|
|
1148
|
-
VideoSource,
|
|
1149
1230
|
prewarm,
|
|
1150
1231
|
clearPrewarmedResources,
|
|
1151
1232
|
version,
|
|
@@ -1156,6 +1237,24 @@ const {
|
|
|
1156
1237
|
addProtocol,
|
|
1157
1238
|
removeProtocol
|
|
1158
1239
|
} = maplibregl__default;
|
|
1240
|
+
const MapMLGL = maplibregl__default.Map;
|
|
1241
|
+
const MarkerMLGL = maplibregl__default.Marker;
|
|
1242
|
+
const PopupMLGL = maplibregl__default.Popup;
|
|
1243
|
+
const StyleMLGL = maplibregl__default.Style;
|
|
1244
|
+
const CanvasSourceMLGL = maplibregl__default.CanvasSource;
|
|
1245
|
+
const GeoJSONSourceMLGL = maplibregl__default.GeoJSONSource;
|
|
1246
|
+
const ImageSourceMLGL = maplibregl__default.ImageSource;
|
|
1247
|
+
const RasterTileSourceMLGL = maplibregl__default.RasterTileSource;
|
|
1248
|
+
const RasterDEMTileSourceMLGL = maplibregl__default.RasterDEMTileSource;
|
|
1249
|
+
const VectorTileSourceMLGL = maplibregl__default.VectorTileSource;
|
|
1250
|
+
const VideoSourceMLGL = maplibregl__default.VideoSource;
|
|
1251
|
+
maplibregl__default.NavigationControl;
|
|
1252
|
+
maplibregl__default.GeolocateControl;
|
|
1253
|
+
maplibregl__default.AttributionControl;
|
|
1254
|
+
maplibregl__default.LogoControl;
|
|
1255
|
+
maplibregl__default.ScaleControl;
|
|
1256
|
+
maplibregl__default.FullscreenControl;
|
|
1257
|
+
maplibregl__default.TerrainControl;
|
|
1159
1258
|
|
|
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 };
|
|
1259
|
+
export { AJAXError, AttributionControl, CanvasSource, CanvasSourceMLGL, Evented, FullscreenControl, GeoJSONSource, GeoJSONSourceMLGL, GeolocateControl, GeolocationType, ImageSource, ImageSourceMLGL, Language, LngLat, LngLatBounds, LogoControl, Map, MapMLGL, MaptilerGeolocateControl, MaptilerLogoControl, MaptilerTerrainControl, Marker, MarkerMLGL, MercatorCoordinate, NavigationControl, Point, Popup, PopupMLGL, RasterDEMTileSource, RasterDEMTileSourceMLGL, RasterTileSource, RasterTileSourceMLGL, ScaleControl, SdkConfig, Style, StyleMLGL, TerrainControl, VectorTileSource, VectorTileSourceMLGL, VideoSource, VideoSourceMLGL, addProtocol, clearPrewarmedResources, clearStorage, config, getRTLTextPluginStatus, maxParallelImageRequests, prewarm, removeProtocol, setRTLTextPlugin, supported, version, workerCount, workerUrl };
|
|
1161
1260
|
//# sourceMappingURL=maptiler-sdk.mjs.map
|