@maptiler/sdk 1.0.11 → 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 +4 -0
- package/demos/maptiler-sdk.umd.js +19 -1
- package/demos/mountain.html +67 -0
- package/dist/maptiler-sdk.d.ts +6 -0
- package/dist/maptiler-sdk.min.mjs +1 -1
- package/dist/maptiler-sdk.mjs +19 -1
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/maptiler-sdk.umd.js +19 -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 +16 -1
- 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
|
@@ -586,6 +586,13 @@ export class Map extends maplibregl.Map {
|
|
|
586
586
|
* @param language
|
|
587
587
|
*/
|
|
588
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
|
+
|
|
589
596
|
if (!isLanguageSupported(language as string)) {
|
|
590
597
|
return;
|
|
591
598
|
}
|
|
@@ -617,7 +624,7 @@ export class Map extends maplibregl.Map {
|
|
|
617
624
|
"case",
|
|
618
625
|
["has", langStr],
|
|
619
626
|
["get", langStr],
|
|
620
|
-
["get", "name
|
|
627
|
+
["get", "name"],
|
|
621
628
|
];
|
|
622
629
|
|
|
623
630
|
for (let i = 0; i < layers.length; i += 1) {
|
|
@@ -751,6 +758,14 @@ export class Map extends maplibregl.Map {
|
|
|
751
758
|
* @param language
|
|
752
759
|
*/
|
|
753
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
|
+
|
|
754
769
|
if (!isLanguageSupported(language as string)) {
|
|
755
770
|
return;
|
|
756
771
|
}
|
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
|
*/
|