@maptiler/sdk 1.0.10 → 1.0.12
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 +8 -0
- package/demos/maptiler-sdk.umd.js +20 -1
- package/demos/mountain.html +67 -0
- package/dist/maptiler-sdk.d.ts +30 -2
- package/dist/maptiler-sdk.min.mjs +1 -1
- package/dist/maptiler-sdk.mjs +20 -2
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/maptiler-sdk.umd.js +20 -1
- 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 +3 -2
- package/src/Map.ts +24 -2
- package/src/index.ts +2 -0
- package/src/language.ts +7 -0
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
1
|
<p align="center">
|
|
2
|
+
<a href="https://docs.maptiler.com/sdk-js/">official page →</a><br>
|
|
3
3
|
<img src="images/maptiler-sdk-logo.svg" width="400px">
|
|
4
4
|
</p>
|
|
5
5
|
|
|
@@ -372,11 +372,12 @@ Again, it will only apply `ENGLISH` as the language of this specific map instanc
|
|
|
372
372
|
|
|
373
373
|
The list of supported languages is built-in and can be found [here](src/language.ts). In addition, there are spacial language *flags*:
|
|
374
374
|
- `Language.AUTO` **[DEFAULT]** uses the language defined in the web browser
|
|
375
|
+
- `Language.STYLE_LOCK` to strictly use the language defined in the style. Prevents any further language update
|
|
375
376
|
- `Language.LOCAL` uses the language local to each country
|
|
376
377
|
- `Language.LATIN` uses a default with latin characters
|
|
377
378
|
- `Language.NON_LATIN` uses a default with non-latin characters
|
|
378
379
|
|
|
379
|
-
Whenever a label is not supported in the defined language, it falls back to `Language.
|
|
380
|
+
Whenever a label is not supported in the defined language, it falls back to `Language.LOCAL`.
|
|
380
381
|
|
|
381
382
|
Here is a sample of some compatible languages:
|
|
382
383
|

|
package/src/Map.ts
CHANGED
|
@@ -99,7 +99,14 @@ export type MapOptions = Omit<MapOptionsML, "style" | "maplibreLogo"> & {
|
|
|
99
99
|
apiKey?: string;
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
|
-
* Shows the MapTiler logo
|
|
102
|
+
* Shows or hides the MapTiler logo in the bottom left corner.
|
|
103
|
+
*
|
|
104
|
+
* For paid plans:
|
|
105
|
+
* - `true` shows MapTiler logo
|
|
106
|
+
* - `false` hodes MapTiler logo
|
|
107
|
+
* - default: `false` (hide)
|
|
108
|
+
*
|
|
109
|
+
* For free plans: MapTiler logo always shows, regardless of the value.
|
|
103
110
|
*/
|
|
104
111
|
maptilerLogo?: boolean;
|
|
105
112
|
|
|
@@ -579,6 +586,13 @@ export class Map extends maplibregl.Map {
|
|
|
579
586
|
* @param language
|
|
580
587
|
*/
|
|
581
588
|
setPrimaryLanguage(language: LanguageString = defaults.primaryLanguage) {
|
|
589
|
+
if (this.primaryLanguage === Language.STYLE_LOCK) {
|
|
590
|
+
console.warn(
|
|
591
|
+
"The language cannot be changed because this map has been instantiated with the STYLE_LOCK language flag."
|
|
592
|
+
);
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
|
|
582
596
|
if (!isLanguageSupported(language as string)) {
|
|
583
597
|
return;
|
|
584
598
|
}
|
|
@@ -610,7 +624,7 @@ export class Map extends maplibregl.Map {
|
|
|
610
624
|
"case",
|
|
611
625
|
["has", langStr],
|
|
612
626
|
["get", langStr],
|
|
613
|
-
["get", "name
|
|
627
|
+
["get", "name"],
|
|
614
628
|
];
|
|
615
629
|
|
|
616
630
|
for (let i = 0; i < layers.length; i += 1) {
|
|
@@ -744,6 +758,14 @@ export class Map extends maplibregl.Map {
|
|
|
744
758
|
* @param language
|
|
745
759
|
*/
|
|
746
760
|
setSecondaryLanguage(language: LanguageString = defaults.secondaryLanguage) {
|
|
761
|
+
// Using the lock flag as a primaty language also applies to the secondary
|
|
762
|
+
if (this.primaryLanguage === Language.STYLE_LOCK) {
|
|
763
|
+
console.warn(
|
|
764
|
+
"The language cannot be changed because this map has been instantiated with the STYLE_LOCK language flag."
|
|
765
|
+
);
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
|
|
747
769
|
if (!isLanguageSupported(language as string)) {
|
|
748
770
|
return;
|
|
749
771
|
}
|
package/src/index.ts
CHANGED
|
@@ -134,6 +134,7 @@ import { TerrainControl } from "./TerrainControl";
|
|
|
134
134
|
import { MaptilerGeolocateControl } from "./MaptilerGeolocateControl";
|
|
135
135
|
import { MaptilerLogoControl } from "./MaptilerLogoControl";
|
|
136
136
|
import { MaptilerTerrainControl } from "./MaptilerTerrainControl";
|
|
137
|
+
import { MaptilerNavigationControl } from "./MaptilerNavigationControl";
|
|
137
138
|
|
|
138
139
|
// importing client functions to expose them as part of the SDK
|
|
139
140
|
import type {
|
|
@@ -227,4 +228,5 @@ export {
|
|
|
227
228
|
MaptilerGeolocateControl,
|
|
228
229
|
MaptilerLogoControl,
|
|
229
230
|
MaptilerTerrainControl,
|
|
231
|
+
MaptilerNavigationControl,
|
|
230
232
|
};
|
package/src/language.ts
CHANGED
|
@@ -7,6 +7,13 @@ const Language = {
|
|
|
7
7
|
*/
|
|
8
8
|
AUTO: "auto",
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* STYLE is a custom flag to keep the language of the map as defined into the style.
|
|
12
|
+
* If STYLE is set in the constructor, then further modification of the language
|
|
13
|
+
* with `.setLanguage()` is not possible.
|
|
14
|
+
*/
|
|
15
|
+
STYLE_LOCK: "style_lock",
|
|
16
|
+
|
|
10
17
|
/**
|
|
11
18
|
* Default fallback languages that uses latin charaters
|
|
12
19
|
*/
|