@maptiler/sdk 1.0.6 → 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 +7 -0
- package/demos/embedded-config.html +66 -0
- package/demos/maptiler-sdk.umd.js +14 -3
- package/demos/simple.html +3 -1
- package/demos/two-maps.html +71 -0
- package/dist/maptiler-sdk.d.ts +84 -60
- package/dist/maptiler-sdk.min.mjs +1 -1
- package/dist/maptiler-sdk.mjs +14 -3
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/maptiler-sdk.umd.js +14 -3
- 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 +52 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
## [v1.0.7](https://github.com/maptiler/maptiler-sdk-js/releases/tag/v1.0.7)
|
|
3
|
+
- The `apiKey` can now be specified in the `Map` constructor (will propagate to `config`)
|
|
4
|
+
- The `language` can now be speficifed in the `Map` constructo (will **not** propagete to `config` and will apply only to this specific instance)
|
|
5
|
+
- `Map` now has the method `.getSdkConfig()` to retrieve the config object.
|
|
6
|
+
- `Map` now has the method `.getMaptilerSessionId()` to retrieve the MapTiler session ID
|
|
7
|
+
|
|
8
|
+
Both `.getSdkConfig()` and `.getMaptilerSessionId()` are handy for layers or control built outside of the SDK that still need some of the configuration to interact with the server. Those components do not always have access to the internal of the SDK (especially that the config is scoped) but can access to the `Map` instance to which they are added with the implementation of the `.onAdd()` method.
|
|
2
9
|
|
|
3
10
|
## [v1.0.6](https://github.com/maptiler/maptiler-sdk-js/releases/tag/v1.0.6)
|
|
4
11
|
- Now exposing `MaptilerGeolocateControl` for external initialization if needed
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<title>MapTiler JS SDK example</title>
|
|
4
|
+
<style>
|
|
5
|
+
html, body {
|
|
6
|
+
margin: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
#map-container {
|
|
10
|
+
position: absolute;
|
|
11
|
+
width: 100vw;
|
|
12
|
+
height: 100vh;
|
|
13
|
+
background: radial-gradient(circle, rgb(186 226 255) 5%, rgb(0 100 159) 98%);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
#style-picker-container {
|
|
17
|
+
position: absolute;
|
|
18
|
+
z-index: 2;
|
|
19
|
+
margin: 10px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
</style>
|
|
23
|
+
|
|
24
|
+
<link rel="stylesheet" href="maptiler-sdk.css">
|
|
25
|
+
</head>
|
|
26
|
+
|
|
27
|
+
<body>
|
|
28
|
+
<div id="map-container"></div>
|
|
29
|
+
<div id="style-picker-container">
|
|
30
|
+
<select name="mapstyles" id="mapstyles-picker">
|
|
31
|
+
|
|
32
|
+
</select>
|
|
33
|
+
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<script src ="maptiler-sdk.umd.js"></script>
|
|
37
|
+
|
|
38
|
+
<script>
|
|
39
|
+
const map = new maptilersdk.Map({
|
|
40
|
+
container: document.getElementById("map-container"),
|
|
41
|
+
apiKey: "ZFEK2gQSwT4Jcimbtcy7",
|
|
42
|
+
language: maptilersdk.Language.GERMAN,
|
|
43
|
+
hash: true,
|
|
44
|
+
maxPitch: 85,
|
|
45
|
+
scaleControl: true,
|
|
46
|
+
fullscreenControl: true,
|
|
47
|
+
terrainControl: true,
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
const styleDropDown = document.getElementById("mapstyles-picker")
|
|
51
|
+
|
|
52
|
+
styleDropDown.onchange = (evt) => {
|
|
53
|
+
map.setStyle(styleDropDown.value)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
Object.keys(maptilersdk.MapStyle).forEach(s => {
|
|
57
|
+
const styleOption = document.createElement('option');
|
|
58
|
+
styleOption.value = maptilersdk.MapStyle[s].DEFAULT.id;
|
|
59
|
+
styleOption.innerHTML = s.replace("_", " ").toLowerCase();
|
|
60
|
+
styleDropDown.appendChild(styleOption);
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
</script>
|
|
65
|
+
</body>
|
|
66
|
+
</html>
|
|
@@ -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) {
|
|
@@ -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 {
|
package/demos/simple.html
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
<script src ="maptiler-sdk.umd.js"></script>
|
|
37
37
|
|
|
38
38
|
<script>
|
|
39
|
-
maptilersdk.config.apiKey = "ZFEK2gQSwT4Jcimbtcy7";
|
|
39
|
+
// maptilersdk.config.apiKey = "ZFEK2gQSwT4Jcimbtcy7";
|
|
40
40
|
|
|
41
41
|
const map = new maptilersdk.Map({
|
|
42
42
|
container: document.getElementById("map-container"),
|
|
@@ -59,6 +59,8 @@
|
|
|
59
59
|
styleOption.innerHTML = s.replace("_", " ").toLowerCase();
|
|
60
60
|
styleDropDown.appendChild(styleOption);
|
|
61
61
|
})
|
|
62
|
+
|
|
63
|
+
|
|
62
64
|
</script>
|
|
63
65
|
</body>
|
|
64
66
|
</html>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<title>MapTiler JS SDK example</title>
|
|
4
|
+
<style>
|
|
5
|
+
html, body {
|
|
6
|
+
margin: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
#two-map-container {
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
#map-container1 {
|
|
14
|
+
/* position: absolute; */
|
|
15
|
+
width: 50vw;
|
|
16
|
+
height: 100vh;
|
|
17
|
+
background: radial-gradient(circle, rgb(186 226 255) 5%, rgb(0 100 159) 98%);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#map-container2 {
|
|
21
|
+
/* position: absolute; */
|
|
22
|
+
width: 50vw;
|
|
23
|
+
height: 100vh;
|
|
24
|
+
background: radial-gradient(circle, rgb(186 226 255) 5%, rgb(0 100 159) 98%);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
</style>
|
|
28
|
+
|
|
29
|
+
<link rel="stylesheet" href="maptiler-sdk.css">
|
|
30
|
+
</head>
|
|
31
|
+
|
|
32
|
+
<body>
|
|
33
|
+
<div id="two-map-container">
|
|
34
|
+
<div id="map-container1"></div>
|
|
35
|
+
<div id="map-container2"></div>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
<script src ="maptiler-sdk.umd.js"></script>
|
|
40
|
+
|
|
41
|
+
<script>
|
|
42
|
+
// maptilersdk.config.primaryLanguage = maptilersdk.Language.GERMAN;
|
|
43
|
+
|
|
44
|
+
const map1 = new maptilersdk.Map({
|
|
45
|
+
container: document.getElementById("map-container1"),
|
|
46
|
+
apiKey: "ZFEK2gQSwT4Jcimbtcy7",
|
|
47
|
+
language: maptilersdk.Language.SPANISH,
|
|
48
|
+
hash: true,
|
|
49
|
+
maxPitch: 85,
|
|
50
|
+
scaleControl: true,
|
|
51
|
+
fullscreenControl: true,
|
|
52
|
+
terrainControl: true,
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const map2 = new maptilersdk.Map({
|
|
56
|
+
container: document.getElementById("map-container2"),
|
|
57
|
+
apiKey: "ZFEK2gQSwT4Jcimbtcy7",
|
|
58
|
+
hash: true,
|
|
59
|
+
maxPitch: 85,
|
|
60
|
+
scaleControl: true,
|
|
61
|
+
fullscreenControl: true,
|
|
62
|
+
terrainControl: true,
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
console.log('map1', map1);
|
|
66
|
+
console.log('map2', map2);
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
</script>
|
|
70
|
+
</body>
|
|
71
|
+
</html>
|
package/dist/maptiler-sdk.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as maplibre_gl from 'maplibre-gl';
|
|
|
2
2
|
import maplibre_gl__default, { MapOptions as MapOptions$1, StyleSpecification, ControlPosition, StyleOptions, LogoOptions as LogoOptions$1 } from 'maplibre-gl';
|
|
3
3
|
export * from 'maplibre-gl';
|
|
4
4
|
import * as _mapbox_mapbox_gl_supported from '@mapbox/mapbox-gl-supported';
|
|
5
|
-
import { ReferenceMapStyle, MapStyleVariant
|
|
5
|
+
import { FetchFunction, ReferenceMapStyle, MapStyleVariant } from '@maptiler/client';
|
|
6
6
|
export { AutomaticStaticMapOptions, BBox, BoundedStaticMapOptions, CenteredStaticMapOptions, CoordinatesSearchOptions, GeocodingOptions, LanguageGeocoding, LanguageGeocodingString, MapStyle, MapStyleType, MapStyleVariant, Position, ReferenceMapStyle, ServiceError, coordinates, data, geocoding, geolocation, staticMaps } from '@maptiler/client';
|
|
7
7
|
import EventEmitter from 'events';
|
|
8
8
|
|
|
@@ -107,6 +107,65 @@ declare type Values<T> = T[keyof T];
|
|
|
107
107
|
*/
|
|
108
108
|
declare type LanguageString = Values<typeof Language>;
|
|
109
109
|
|
|
110
|
+
declare type Unit = "imperial" | "metric" | "nautical";
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Configuration class for the SDK
|
|
114
|
+
*/
|
|
115
|
+
declare class SdkConfig extends EventEmitter {
|
|
116
|
+
/**
|
|
117
|
+
* The primary language. By default, the language of the web browser is used.
|
|
118
|
+
*/
|
|
119
|
+
primaryLanguage: LanguageString | null;
|
|
120
|
+
/**
|
|
121
|
+
* The secondary language, to overwrite the default language defined in the map style.
|
|
122
|
+
* This settings is highly dependant on the style compatibility and may not work in most cases.
|
|
123
|
+
*/
|
|
124
|
+
secondaryLanguage: LanguageString | null;
|
|
125
|
+
/**
|
|
126
|
+
* Setting on whether of not the SDK runs with a session logic.
|
|
127
|
+
* A "session" is started at the initialization of the SDK and finished when the browser
|
|
128
|
+
* page is being refreshed.
|
|
129
|
+
* When `session` is enabled (default: true), the extra URL param `mtsid` is added to queries
|
|
130
|
+
* on the MapTiler Cloud API. This allows MapTiler to enable "session based billing".
|
|
131
|
+
*/
|
|
132
|
+
session: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Unit to be used
|
|
135
|
+
*/
|
|
136
|
+
private _unit;
|
|
137
|
+
/**
|
|
138
|
+
* MapTiler Cloud API key
|
|
139
|
+
*/
|
|
140
|
+
private _apiKey;
|
|
141
|
+
constructor();
|
|
142
|
+
/**
|
|
143
|
+
* Set the unit system
|
|
144
|
+
*/
|
|
145
|
+
set unit(u: Unit);
|
|
146
|
+
/**
|
|
147
|
+
* Get the unit system
|
|
148
|
+
*/
|
|
149
|
+
get unit(): Unit;
|
|
150
|
+
/**
|
|
151
|
+
* Set the MapTiler Cloud API key
|
|
152
|
+
*/
|
|
153
|
+
set apiKey(k: string);
|
|
154
|
+
/**
|
|
155
|
+
* Get the MapTiler Cloud API key
|
|
156
|
+
*/
|
|
157
|
+
get apiKey(): string;
|
|
158
|
+
/**
|
|
159
|
+
* Set a the custom fetch function to replace the default one
|
|
160
|
+
*/
|
|
161
|
+
set fetch(f: FetchFunction);
|
|
162
|
+
/**
|
|
163
|
+
* Get the fetch fucntion
|
|
164
|
+
*/
|
|
165
|
+
get fetch(): FetchFunction | null;
|
|
166
|
+
}
|
|
167
|
+
declare const config: SdkConfig;
|
|
168
|
+
|
|
110
169
|
declare type TransformStyleFunction = (previous: StyleSpecification, next: StyleSpecification) => StyleSpecification;
|
|
111
170
|
declare type StyleSwapOptions = {
|
|
112
171
|
diff?: boolean;
|
|
@@ -127,6 +186,17 @@ declare type MapOptions = Omit<MapOptions$1, "style" | "maplibreLogo"> & {
|
|
|
127
186
|
* - a longer form with the prefix `"maptiler://"` (eg. `"maptiler://streets-v2"`)
|
|
128
187
|
*/
|
|
129
188
|
style?: ReferenceMapStyle | MapStyleVariant | StyleSpecification | string;
|
|
189
|
+
/**
|
|
190
|
+
* Define the language of the map. This can be done directly with a language ISO code (eg. "en")
|
|
191
|
+
* or with a built-in shorthand (eg. Language.ENGLISH).
|
|
192
|
+
* Note that this is equivalent to setting the `config.primaryLanguage` and will overwrite it.
|
|
193
|
+
*/
|
|
194
|
+
language?: LanguageString;
|
|
195
|
+
/**
|
|
196
|
+
* Define the MapTiler Cloud API key to be used. This is strictly equivalent to setting
|
|
197
|
+
* `config.apiKey` and will overwrite it.
|
|
198
|
+
*/
|
|
199
|
+
apiKey?: string;
|
|
130
200
|
/**
|
|
131
201
|
* Shows the MapTiler logo if `true`. Note that the logo is always displayed on free plan.
|
|
132
202
|
*/
|
|
@@ -252,6 +322,19 @@ declare class Map extends maplibre_gl__default.Map {
|
|
|
252
322
|
fitToIpBounds(): Promise<void>;
|
|
253
323
|
centerOnIpPoint(zoom: number | undefined): Promise<void>;
|
|
254
324
|
getCameraHash(): string;
|
|
325
|
+
/**
|
|
326
|
+
* Get the SDK config object.
|
|
327
|
+
* This is convenient to dispatch the SDK configuration to externally built layers
|
|
328
|
+
* that do not directly have access to the SDK configuration but do have access to a Map instance.
|
|
329
|
+
* @returns
|
|
330
|
+
*/
|
|
331
|
+
getSdkConfig(): SdkConfig;
|
|
332
|
+
/**
|
|
333
|
+
* Get the MapTiler session ID. Convenient to dispatch to externaly built component
|
|
334
|
+
* that do not directly have access to the SDK configuration but do have access to a Map instance.
|
|
335
|
+
* @returns
|
|
336
|
+
*/
|
|
337
|
+
getMaptilerSessionId(): string;
|
|
255
338
|
}
|
|
256
339
|
|
|
257
340
|
declare const GeolocateControl$1: typeof maplibre_gl.GeolocateControl;
|
|
@@ -485,65 +568,6 @@ declare class Point {
|
|
|
485
568
|
static convert(a: Point | Array<number>): Point;
|
|
486
569
|
}
|
|
487
570
|
|
|
488
|
-
declare type Unit = "imperial" | "metric" | "nautical";
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* Configuration class for the SDK
|
|
492
|
-
*/
|
|
493
|
-
declare class SdkConfig extends EventEmitter {
|
|
494
|
-
/**
|
|
495
|
-
* The primary language. By default, the language of the web browser is used.
|
|
496
|
-
*/
|
|
497
|
-
primaryLanguage: LanguageString | null;
|
|
498
|
-
/**
|
|
499
|
-
* The secondary language, to overwrite the default language defined in the map style.
|
|
500
|
-
* This settings is highly dependant on the style compatibility and may not work in most cases.
|
|
501
|
-
*/
|
|
502
|
-
secondaryLanguage: LanguageString | null;
|
|
503
|
-
/**
|
|
504
|
-
* Setting on whether of not the SDK runs with a session logic.
|
|
505
|
-
* A "session" is started at the initialization of the SDK and finished when the browser
|
|
506
|
-
* page is being refreshed.
|
|
507
|
-
* When `session` is enabled (default: true), the extra URL param `mtsid` is added to queries
|
|
508
|
-
* on the MapTiler Cloud API. This allows MapTiler to enable "session based billing".
|
|
509
|
-
*/
|
|
510
|
-
session: boolean;
|
|
511
|
-
/**
|
|
512
|
-
* Unit to be used
|
|
513
|
-
*/
|
|
514
|
-
private _unit;
|
|
515
|
-
/**
|
|
516
|
-
* MapTiler Cloud API key
|
|
517
|
-
*/
|
|
518
|
-
private _apiKey;
|
|
519
|
-
constructor();
|
|
520
|
-
/**
|
|
521
|
-
* Set the unit system
|
|
522
|
-
*/
|
|
523
|
-
set unit(u: Unit);
|
|
524
|
-
/**
|
|
525
|
-
* Get the unit system
|
|
526
|
-
*/
|
|
527
|
-
get unit(): Unit;
|
|
528
|
-
/**
|
|
529
|
-
* Set the MapTiler Cloud API key
|
|
530
|
-
*/
|
|
531
|
-
set apiKey(k: string);
|
|
532
|
-
/**
|
|
533
|
-
* Get the MapTiler Cloud API key
|
|
534
|
-
*/
|
|
535
|
-
get apiKey(): string;
|
|
536
|
-
/**
|
|
537
|
-
* Set a the custom fetch function to replace the default one
|
|
538
|
-
*/
|
|
539
|
-
set fetch(f: FetchFunction);
|
|
540
|
-
/**
|
|
541
|
-
* Get the fetch fucntion
|
|
542
|
-
*/
|
|
543
|
-
get fetch(): FetchFunction | null;
|
|
544
|
-
}
|
|
545
|
-
declare const config: SdkConfig;
|
|
546
|
-
|
|
547
571
|
declare const supported: _mapbox_mapbox_gl_supported.IsSupported;
|
|
548
572
|
declare const setRTLTextPlugin: (url: string, callback: (error?: Error) => void, deferred?: boolean) => void;
|
|
549
573
|
declare const getRTLTextPluginStatus: () => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import m from"maplibre-gl";export*from"maplibre-gl";import{Base64 as G}from"js-base64";import{v4 as D}from"uuid";import z from"events";import{config as x,expandMapStyle as V,MapStyleVariant as F,ReferenceMapStyle as Z,MapStyle as q,mapStylePresetList as J,geolocation as v}from"@maptiler/client";import{LanguageGeocoding as oe,MapStyle as ne,MapStyleVariant as se,ReferenceMapStyle as le,ServiceError as ce,coordinates as he,data as ue,geocoding as ge,geolocation as pe,staticMaps as de}from"@maptiler/client";const S={AUTO:"auto",LATIN:"latin",NON_LATIN:"nonlatin",LOCAL:"",ALBANIAN:"sq",AMHARIC:"am",ARABIC:"ar",ARMENIAN:"hy",AZERBAIJANI:"az",BASQUE:"eu",BELORUSSIAN:"be",BOSNIAN:"bs",BRETON:"br",BULGARIAN:"bg",CATALAN:"ca",CHINESE:"zh",CORSICAN:"co",CROATIAN:"hr",CZECH:"cs",DANISH:"da",DUTCH:"nl",ENGLISH:"en",ESPERANTO:"eo",ESTONIAN:"et",FINNISH:"fi",FRENCH:"fr",FRISIAN:"fy",GEORGIAN:"ka",GERMAN:"de",GREEK:"el",HEBREW:"he",HINDI:"hi",HUNGARIAN:"hu",ICELANDIC:"is",INDONESIAN:"id",IRISH:"ga",ITALIAN:"it",JAPANESE:"ja",JAPANESE_HIRAGANA:"ja-Hira",JAPANESE_KANA:"ja_kana",JAPANESE_LATIN:"ja_rm",JAPANESE_2018:"ja-Latn",KANNADA:"kn",KAZAKH:"kk",KOREAN:"ko",KOREAN_LATIN:"ko-Latn",KURDISH:"ku",ROMAN_LATIN:"la",LATVIAN:"lv",LITHUANIAN:"lt",LUXEMBOURGISH:"lb",MACEDONIAN:"mk",MALAYALAM:"ml",MALTESE:"mt",NORWEGIAN:"no",OCCITAN:"oc",POLISH:"pl",PORTUGUESE:"pt",ROMANIAN:"ro",ROMANSH:"rm",RUSSIAN:"ru",SCOTTISH_GAELIC:"gd",SERBIAN_CYRILLIC:"sr",SERBIAN_LATIN:"sr-Latn",SLOVAK:"sk",SLOVENE:"sl",SPANISH:"es",SWEDISH:"sv",TAMIL:"ta",TELUGU:"te",THAI:"th",TURKISH:"tr",UKRAINIAN:"uk",WELSH:"cy"},W=new Set(Object.values(S));function E(r){return W.has(r)}const Y=new Set(Object.values(S));function T(){if(typeof navigator>"u")return Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];const r=Array.from(new Set(navigator.languages.map(t=>t.split("-")[0]))).filter(t=>Y.has(t));return r.length?r[0]:S.LATIN}class N extends z{constructor(){super(),this.primaryLanguage=S.AUTO,this.secondaryLanguage=null,this.session=!0,this._unit="metric",this._apiKey=""}set unit(t){this._unit=t,this.emit("unit",t)}get unit(){return this._unit}set apiKey(t){this._apiKey=t,x.apiKey=t,this.emit("apiKey",t)}get apiKey(){return this._apiKey}set fetch(t){x.fetch=t}get fetch(){return x.fetch}}const g=new N,p={maptilerLogoURL:"https://api.maptiler.com/resources/logo.svg",maptilerURL:"https://www.maptiler.com/",maptilerApiHost:"api.maptiler.com",rtlPluginURL:"https://cdn.maptiler.com/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.min.js",primaryLanguage:S.AUTO,secondaryLanguage:S.LOCAL,terrainSourceURL:"https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json",terrainSourceId:"maptiler-terrain"};Object.freeze(p);class I extends m.LogoControl{constructor(t={}){var e,o;super(t),this.logoURL="",this.linkURL="",this.logoURL=(e=t.logoURL)!=null?e:p.maptilerLogoURL,this.linkURL=(o=t.linkURL)!=null?o:p.maptilerURL}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=window.document.createElement("div"),this._container.className="maplibregl-ctrl";const e=window.document.createElement("a");return e.style.backgroundRepeat="no-repeat",e.style.cursor="pointer",e.style.display="block",e.style.height="23px",e.style.margin="0 0 -4px -4px",e.style.overflow="hidden",e.style.width="88px",e.style.backgroundImage=`url(${this.logoURL})`,e.style.backgroundSize="100px 30px",e.style.width="100px",e.style.height="30px",e.target="_blank",e.rel="noopener nofollow",e.href=this.linkURL,e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}}function X(){m.getRTLTextPluginStatus()==="unavailable"&&m.setRTLTextPlugin(p.rtlPluginURL,null,!0)}function Q(r,t){r.forEach(e=>{!t[e]||(t[e]=t[e].bind(t))})}function A(r,t,e){const o=window.document.createElement(r);return t!==void 0&&(o.className=t),e&&e.appendChild(o),o}function tt(r){r.parentNode&&r.parentNode.removeChild(r)}function w(r){return r?typeof r=="string"||r instanceof String?!r.startsWith("http")&&r.toLowerCase().includes(".json")?r:V(r):r instanceof F?r.getExpandedStyleURL():r instanceof Z?r.getDefaultVariant().getExpandedStyleURL():r:q[J[0].referenceStyleID].getDefaultVariant().getExpandedStyleURL()}class R{constructor(){Q(["_toggleTerrain","_updateTerrainIcon"],this)}onAdd(t){return this._map=t,this._container=A("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=A("button","maplibregl-ctrl-terrain",this._container),A("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){tt(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}_toggleTerrain(){this._map.hasTerrain()?this._map.disableTerrain():this._map.enableTerrain(),this._updateTerrainIcon()}_updateTerrainIcon(){this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.hasTerrain()?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"))}}class et extends m.NavigationControl{constructor(){super({showCompass:!0,showZoom:!0,visualizePitch:!0}),this._compass.removeEventListener("click",this._compass.clickFunction),this._compass.addEventListener("click",t=>{this._map.getPitch()===0?this._map.easeTo({pitch:Math.min(this._map.getMaxPitch(),80)}):this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})}_createButton(t,e){const o=super._createButton(t,e);return o.clickFunction=e,o}_rotateCompassArrow(){const t=this.options.visualizePitch?`scale(${Math.min(1.5,1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5))}) rotateX(${Math.min(70,this._map.transform.pitch)}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=t}}var rt=Object.defineProperty,it=Object.defineProperties,at=Object.getOwnPropertyDescriptors,P=Object.getOwnPropertySymbols,ot=Object.prototype.hasOwnProperty,nt=Object.prototype.propertyIsEnumerable,O=(r,t,e)=>t in r?rt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,st=(r,t)=>{for(var e in t||(t={}))ot.call(t,e)&&O(r,e,t[e]);if(P)for(var e of P(t))nt.call(t,e)&&O(r,e,t[e]);return r},lt=(r,t)=>it(r,at(t));const ct=m.GeolocateControl,U=m.Marker,M=m.LngLat;class k extends ct{constructor(){super(...arguments),this.lastUpdatedCenter=new M(0,0)}_updateCamera(t){const e=new M(t.coords.longitude,t.coords.latitude),o=t.coords.accuracy,h=this._map.getBearing(),s=lt(st({bearing:h},this.options.fitBoundsOptions),{linear:!0}),i=this._map.getZoom();i>this.options.fitBoundsOptions.maxZoom&&(s.zoom=i),this._map.fitBounds(e.toBounds(o),s,{geolocateSource:!0});let c=!1;const a=()=>{c=!0};this._map.once("click",a),this._map.once("dblclick",a),this._map.once("dragstart",a),this._map.once("mousedown",a),this._map.once("touchstart",a),this._map.once("wheel",a),this._map.once("moveend",()=>{this._map.off("click",a),this._map.off("dblclick",a),this._map.off("dragstart",a),this._map.off("mousedown",a),this._map.off("touchstart",a),this._map.off("wheel",a),!c&&(this.lastUpdatedCenter=this._map.getCenter())})}_setupUI(t){if(this.lastUpdatedCenter=this._map.getCenter(),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=A("button","maplibregl-ctrl-geolocate",this._container),A("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",t===!1){const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=A("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new U(this._dotElement),this._circleElement=A("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new U({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("move",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("moveend",e=>{const o=e.originalEvent&&e.originalEvent.type==="resize",h=this.lastUpdatedCenter.distanceTo(this._map.getCenter());!e.geolocateSource&&this._watchState==="ACTIVE_LOCK"&&!o&&h>1&&(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new Event("trackuserlocationend")))})}_updateCircleRadius(){if(this._watchState!=="BACKGROUND"&&this._watchState!=="ACTIVE_LOCK")return;const t=[this._lastKnownPosition.coords.longitude,this._lastKnownPosition.coords.latitude],e=this._map.project(t),o=this._map.unproject([e.x,e.y]),h=this._map.unproject([e.x+20,e.y]),s=o.distanceTo(h)/20,i=Math.ceil(2*this._accuracy/s);this._circleElement.style.width=`${i}px`,this._circleElement.style.height=`${i}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}}var ht=Object.defineProperty,ut=Object.defineProperties,gt=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,pt=Object.prototype.hasOwnProperty,dt=Object.prototype.propertyIsEnumerable,$=(r,t,e)=>t in r?ht(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,H=(r,t)=>{for(var e in t||(t={}))pt.call(t,e)&&$(r,e,t[e]);if(B)for(var e of B(t))dt.call(t,e)&&$(r,e,t[e]);return r},j=(r,t)=>ut(r,gt(t)),C=(r,t,e)=>new Promise((o,h)=>{var s=a=>{try{c(e.next(a))}catch(y){h(y)}},i=a=>{try{c(e.throw(a))}catch(y){h(y)}},c=a=>a.done?o(a.value):Promise.resolve(a.value).then(s,i);c((e=e.apply(r,t)).next())});const mt=D(),K={POINT:"POINT",COUNTRY:"COUNTRY"};class yt extends m.Map{constructor(t){var e;const o=w(t.style),h=location.hash;g.apiKey||console.warn("MapTiler Cloud API key is not set. Visit https://maptiler.com and try Cloud for free!"),super(j(H({},t),{style:o,maplibreLogo:!1,transformRequest:s=>{let i=null;try{i=new URL(s)}catch{return{url:s,headers:{}}}return i.host===p.maptilerApiHost&&(i.searchParams.has("key")||i.searchParams.append("key",g.apiKey),g.session&&i.searchParams.append("mtsid",mt)),{url:i.href,headers:{}}}})),this.languageShouldUpdate=!1,this.isStyleInitialized=!1,this.isTerrainEnabled=!1,this.terrainExaggeration=1,this.once("styledata",()=>C(this,null,function*(){if(t.geolocate===!1||t.center||t.hash&&!!h)return;try{if(t.geolocate===K.COUNTRY){yield this.fitToIpBounds();return}}catch(i){console.warn(i.message)}let s=null;try{yield this.centerOnIpPoint(t.zoom),s=this.getCameraHash()}catch(i){console.warn(i.message)}(yield navigator.permissions.query({name:"geolocation"})).state==="granted"&&navigator.geolocation.getCurrentPosition(i=>{s===this.getCameraHash()&&this.easeTo({center:[i.coords.longitude,i.coords.latitude],zoom:t.zoom||12,duration:2e3})},null,{maximumAge:24*3600*1e3,timeout:5e3,enableHighAccuracy:!1})})),this.on("styledataloading",()=>{this.languageShouldUpdate=!!g.primaryLanguage||!!g.secondaryLanguage}),this.on("styledata",()=>{g.primaryLanguage&&(this.languageShouldUpdate||!this.isStyleInitialized)&&this.setPrimaryLanguage(g.primaryLanguage),g.secondaryLanguage&&(this.languageShouldUpdate||!this.isStyleInitialized)&&this.setSecondaryLanguage(g.secondaryLanguage),this.languageShouldUpdate=!1,this.isStyleInitialized=!0}),this.on("styledata",()=>{this.getTerrain()===null&&this.isTerrainEnabled&&this.enableTerrain(this.terrainExaggeration)}),this.once("load",()=>C(this,null,function*(){X()})),this.once("load",()=>C(this,null,function*(){let s={logo:null};try{const i=Object.keys(this.style.sourceCaches).map(a=>this.getSource(a)).filter(a=>typeof a.url=="string"&&a.url.includes("tiles.json")),c=new URL(i[0].url);c.searchParams.has("key")||c.searchParams.append("key",g.apiKey),s=yield(yield fetch(c.href)).json()}catch{}if("logo"in s&&s.logo){const i=s.logo;this.addControl(new I({logoURL:i}),t.logoPosition),t.attributionControl===!1&&this.addControl(new m.AttributionControl(t))}else t.maptilerLogo&&this.addControl(new I,t.logoPosition);if(t.scaleControl){const i=t.scaleControl===!0||t.scaleControl===void 0?"bottom-right":t.scaleControl,c=new m.ScaleControl({unit:g.unit});this.addControl(c,i),g.on("unit",a=>{c.setUnit(a)})}if(t.navigationControl!==!1){const i=t.navigationControl===!0||t.navigationControl===void 0?"top-right":t.navigationControl;this.addControl(new et,i)}if(t.geolocateControl!==!1){const i=t.geolocateControl===!0||t.geolocateControl===void 0?"top-right":t.geolocateControl;this.addControl(new k({positionOptions:{enableHighAccuracy:!0,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!0,showAccuracyCircle:!0,showUserLocation:!0}),i)}if(t.terrainControl){const i=t.terrainControl===!0||t.terrainControl===void 0?"top-right":t.terrainControl;this.addControl(new R,i)}if(t.fullscreenControl){const i=t.fullscreenControl===!0||t.fullscreenControl===void 0?"top-right":t.fullscreenControl;this.addControl(new m.FullscreenControl({}),i)}})),t.terrain&&this.enableTerrain((e=t.terrainExaggeration)!=null?e:this.terrainExaggeration)}setStyle(t,e){return super.setStyle(w(t),e)}setLanguage(t=p.primaryLanguage){if(t===S.AUTO)return this.setLanguage(T());this.setPrimaryLanguage(t)}setPrimaryLanguage(t=p.primaryLanguage){!E(t)||this.onStyleReady(()=>{if(t===S.AUTO)return this.setPrimaryLanguage(T());g.primaryLanguage=t;const e=this.getStyle().layers,o=/^\s*{\s*name\s*(:\s*(\S*))?\s*}$/,h=/^\s*name\s*(:\s*(\S*))?\s*$/,s=/^\s*{\s*name\s*(:\s*(\S*))?\s*}(\s*){\s*name\s*(:\s*(\S*))?\s*}$/,i=/^(.*)({\s*name\s*(:\s*(\S*))?\s*})(.*)$/,c=t?`name:${t}`:"name",a=["case",["has",c],["get",c],["get","name:latin"]];for(let y=0;y<e.length;y+=1){const u=e[y],f=u.layout;if(!f||!f["text-field"])continue;const n=this.getLayoutProperty(u.id,"text-field");let d;if(Array.isArray(n)&&n.length>=2&&n[0].trim().toLowerCase()==="concat"){const l=n.slice();for(let L=0;L<n.length;L+=1){const _=n[L];if((typeof _=="string"||_ instanceof String)&&o.exec(_.toString())){l[L]=a;break}else if(Array.isArray(_)&&_.length>=2&&_[0].trim().toLowerCase()==="get"&&h.exec(_[1].toString())){l[L]=a;break}else if(Array.isArray(_)&&_.length===4&&_[0].trim().toLowerCase()==="case"){l[L]=a;break}}this.setLayoutProperty(u.id,"text-field",l)}else if(Array.isArray(n)&&n.length>=2&&n[0].trim().toLowerCase()==="get"&&h.exec(n[1].toString())){const l=a;this.setLayoutProperty(u.id,"text-field",l)}else if((typeof n=="string"||n instanceof String)&&o.exec(n.toString())){const l=a;this.setLayoutProperty(u.id,"text-field",l)}else if(Array.isArray(n)&&n.length===4&&n[0].trim().toLowerCase()==="case"){const l=a;this.setLayoutProperty(u.id,"text-field",l)}else if((typeof n=="string"||n instanceof String)&&(d=s.exec(n.toString()))!==null){const l=`{${c}}${d[3]}{name${d[4]||""}}`;this.setLayoutProperty(u.id,"text-field",l)}else if((typeof n=="string"||n instanceof String)&&(d=i.exec(n.toString()))!==null){const l=`${d[1]}{${c}}${d[5]}`;this.setLayoutProperty(u.id,"text-field",l)}}})}setSecondaryLanguage(t=p.secondaryLanguage){!E(t)||this.onStyleReady(()=>{if(t===S.AUTO)return this.setSecondaryLanguage(T());g.secondaryLanguage=t;const e=this.getStyle().layers,o=/^\s*{\s*name\s*(:\s*(\S*))?\s*}$/,h=/^\s*name\s*(:\s*(\S*))?\s*$/,s=/^\s*{\s*name\s*(:\s*(\S*))?\s*}(\s*){\s*name\s*(:\s*(\S*))?\s*}$/;let i;for(let c=0;c<e.length;c+=1){const a=e[c],y=a.layout;if(!y||!y["text-field"])continue;const u=this.getLayoutProperty(a.id,"text-field");let f;if(Array.isArray(u)&&u.length>=2&&u[0].trim().toLowerCase()==="concat"){f=u.slice();let n=0;for(let d=0;d<u.length;d+=1){const l=u[d];if((typeof l=="string"||l instanceof String)&&o.exec(l.toString())){if(n===1){f[d]=`{name:${t}}`;break}n+=1}else if(Array.isArray(l)&&l.length>=2&&l[0].trim().toLowerCase()==="get"&&h.exec(l[1].toString())){if(n===1){f[d][1]=`name:${t}`;break}n+=1}else if(Array.isArray(l)&&l.length===4&&l[0].trim().toLowerCase()==="case"){if(n===1){f[d]=["get",`name:${t}`];break}n+=1}}this.setLayoutProperty(a.id,"text-field",f)}else if((typeof u=="string"||u instanceof String)&&(i=s.exec(u.toString()))!==null){const n=t?`name:${t}`:"name";f=`{name${i[1]||""}}${i[3]}{${n}}`,this.setLayoutProperty(a.id,"text-field",f)}}})}getTerrainExaggeration(){return this.terrainExaggeration}hasTerrain(){return this.isTerrainEnabled}enableTerrain(t=this.terrainExaggeration){if(t<0){console.warn("Terrain exaggeration cannot be negative.");return}const e=this.getTerrain(),o=()=>{this.isTerrainEnabled=!0,this.terrainExaggeration=t,this.addSource(p.terrainSourceId,{type:"raster-dem",url:p.terrainSourceURL}),this.setTerrain({source:p.terrainSourceId,exaggeration:t})};if(e){this.setTerrain(j(H({},e),{exaggeration:t}));return}this.loaded()||this.isTerrainEnabled?o():this.once("load",()=>{this.getTerrain()&&this.getSource(p.terrainSourceId)||o()})}disableTerrain(){this.isTerrainEnabled=!1,this.setTerrain(null),this.getSource(p.terrainSourceId)&&this.removeSource(p.terrainSourceId)}setTerrainExaggeration(t){this.enableTerrain(t)}onStyleReady(t){this.isStyleLoaded()?t():this.once("styledata",()=>{t()})}fitToIpBounds(){return C(this,null,function*(){const t=yield v.info();this.fitBounds(t.country_bounds,{duration:0,padding:100})})}centerOnIpPoint(t){return C(this,null,function*(){const e=yield v.info();this.jumpTo({center:[e.longitude,e.latitude],zoom:t||11})})}getCameraHash(){const t=new Float32Array(5),e=this.getCenter();return t[0]=e.lng,t[1]=e.lat,t[2]=this.getZoom(),t[3]=this.getPitch(),t[4]=this.getBearing(),G.fromUint8Array(new Uint8Array(t.buffer))}}class b{constructor(t,e){this.x=t,this.y=e}_matMult(t){const e=t[0]*this.x+t[1]*this.y,o=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=o,this}_add(t){return this.x+=t.x,this.y+=t.y,this}_sub(t){return this.x-=t.x,this.y-=t.y,this}_mult(t){return this.x*=t,this.y*=t,this}_div(t){return this.x/=t,this.y/=t,this}_multByPoint(t){return this.x*=t.x,this.y*=t.y,this}_divByPoint(t){return this.x/=t.x,this.y/=t.y,this}_unit(){return this._div(this.mag()),this}_perp(){const t=this.y;return this.y=this.x,this.x=-t,this}_rotate(t){const e=Math.cos(t),o=Math.sin(t),h=e*this.x-o*this.y,s=o*this.x+e*this.y;return this.x=h,this.y=s,this}_rotateAround(t,e){const o=Math.cos(t),h=Math.sin(t),s=e.x+o*(this.x-e.x)-h*(this.y-e.y),i=e.y+h*(this.x-e.x)+o*(this.y-e.y);return this.x=s,this.y=i,this}_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}clone(){return new b(this.x,this.y)}add(t){return this.clone()._add(t)}sub(t){return this.clone()._sub(t)}multByPoint(t){return this.clone()._multByPoint(t)}divByPoint(t){return this.clone()._divByPoint(t)}mult(t){return this.clone()._mult(t)}div(t){return this.clone()._div(t)}rotate(t){return this.clone()._rotate(t)}rotateAround(t,e){return this.clone()._rotateAround(t,e)}matMult(t){return this.clone()._matMult(t)}unit(){return this.clone()._unit()}perp(){return this.clone()._perp()}round(){return this.clone()._round()}mag(){return Math.sqrt(this.x*this.x+this.y*this.y)}equals(t){return this.x===t.x&&this.y===t.y}dist(t){return Math.sqrt(this.distSqr(t))}distSqr(t){const e=t.x-this.x,o=t.y-this.y;return e*e+o*o}angle(){return Math.atan2(this.y,this.x)}angleTo(t){return Math.atan2(this.y-t.y,this.x-t.x)}angleWith(t){return this.angleWithSep(t.x,t.y)}angleWithSep(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)}static convert(t){return t instanceof b?t:Array.isArray(t)?new b(t[0],t[1]):t}}const{supported:ft,setRTLTextPlugin:_t,getRTLTextPluginStatus:St,NavigationControl:At,GeolocateControl:Lt,AttributionControl:Ct,LogoControl:bt,ScaleControl:xt,FullscreenControl:Tt,TerrainControl:It,Popup:vt,Marker:Et,Style:Nt,LngLat:wt,LngLatBounds:Rt,MercatorCoordinate:Pt,Evented:Ot,AJAXError:Ut,CanvasSource:Mt,GeoJSONSource:kt,ImageSource:Bt,RasterDEMTileSource:$t,RasterTileSource:Ht,VectorTileSource:jt,VideoSource:Kt,prewarm:Gt,clearPrewarmedResources:Dt,version:zt,workerCount:Vt,maxParallelImageRequests:Ft,clearStorage:Zt,workerUrl:qt,addProtocol:Jt,removeProtocol:Wt}=m;export{Ut as AJAXError,Ct as AttributionControl,Mt as CanvasSource,Ot as Evented,Tt as FullscreenControl,kt as GeoJSONSource,Lt as GeolocateControl,K as GeolocationType,Bt as ImageSource,S as Language,oe as LanguageGeocoding,wt as LngLat,Rt as LngLatBounds,bt as LogoControl,yt as Map,ne as MapStyle,se as MapStyleVariant,k as MaptilerGeolocateControl,I as MaptilerLogoControl,R as MaptilerTerrainControl,Et as Marker,Pt as MercatorCoordinate,At as NavigationControl,b as Point,vt as Popup,$t as RasterDEMTileSource,Ht as RasterTileSource,le as ReferenceMapStyle,xt as ScaleControl,N as SdkConfig,ce as ServiceError,Nt as Style,It as TerrainControl,jt as VectorTileSource,Kt as VideoSource,Jt as addProtocol,Dt as clearPrewarmedResources,Zt as clearStorage,g as config,he as coordinates,ue as data,ge as geocoding,pe as geolocation,St as getRTLTextPluginStatus,Ft as maxParallelImageRequests,Gt as prewarm,Wt as removeProtocol,_t as setRTLTextPlugin,de as staticMaps,ft as supported,zt as version,Vt as workerCount,qt as workerUrl};
|
|
1
|
+
import y from"maplibre-gl";export*from"maplibre-gl";import{Base64 as D}from"js-base64";import{v4 as z}from"uuid";import F from"events";import{config as x,expandMapStyle as V,MapStyleVariant as Z,ReferenceMapStyle as q,MapStyle as J,mapStylePresetList as W,geolocation as v}from"@maptiler/client";import{LanguageGeocoding as oe,MapStyle as ne,MapStyleVariant as se,ReferenceMapStyle as le,ServiceError as ce,coordinates as he,data as ue,geocoding as ge,geolocation as pe,staticMaps as de}from"@maptiler/client";const S={AUTO:"auto",LATIN:"latin",NON_LATIN:"nonlatin",LOCAL:"",ALBANIAN:"sq",AMHARIC:"am",ARABIC:"ar",ARMENIAN:"hy",AZERBAIJANI:"az",BASQUE:"eu",BELORUSSIAN:"be",BOSNIAN:"bs",BRETON:"br",BULGARIAN:"bg",CATALAN:"ca",CHINESE:"zh",CORSICAN:"co",CROATIAN:"hr",CZECH:"cs",DANISH:"da",DUTCH:"nl",ENGLISH:"en",ESPERANTO:"eo",ESTONIAN:"et",FINNISH:"fi",FRENCH:"fr",FRISIAN:"fy",GEORGIAN:"ka",GERMAN:"de",GREEK:"el",HEBREW:"he",HINDI:"hi",HUNGARIAN:"hu",ICELANDIC:"is",INDONESIAN:"id",IRISH:"ga",ITALIAN:"it",JAPANESE:"ja",JAPANESE_HIRAGANA:"ja-Hira",JAPANESE_KANA:"ja_kana",JAPANESE_LATIN:"ja_rm",JAPANESE_2018:"ja-Latn",KANNADA:"kn",KAZAKH:"kk",KOREAN:"ko",KOREAN_LATIN:"ko-Latn",KURDISH:"ku",ROMAN_LATIN:"la",LATVIAN:"lv",LITHUANIAN:"lt",LUXEMBOURGISH:"lb",MACEDONIAN:"mk",MALAYALAM:"ml",MALTESE:"mt",NORWEGIAN:"no",OCCITAN:"oc",POLISH:"pl",PORTUGUESE:"pt",ROMANIAN:"ro",ROMANSH:"rm",RUSSIAN:"ru",SCOTTISH_GAELIC:"gd",SERBIAN_CYRILLIC:"sr",SERBIAN_LATIN:"sr-Latn",SLOVAK:"sk",SLOVENE:"sl",SPANISH:"es",SWEDISH:"sv",TAMIL:"ta",TELUGU:"te",THAI:"th",TURKISH:"tr",UKRAINIAN:"uk",WELSH:"cy"},Y=new Set(Object.values(S));function E(r){return Y.has(r)}const X=new Set(Object.values(S));function T(){if(typeof navigator>"u")return Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];const r=Array.from(new Set(navigator.languages.map(t=>t.split("-")[0]))).filter(t=>X.has(t));return r.length?r[0]:S.LATIN}class N extends F{constructor(){super(),this.primaryLanguage=S.AUTO,this.secondaryLanguage=null,this.session=!0,this._unit="metric",this._apiKey=""}set unit(t){this._unit=t,this.emit("unit",t)}get unit(){return this._unit}set apiKey(t){this._apiKey=t,x.apiKey=t,this.emit("apiKey",t)}get apiKey(){return this._apiKey}set fetch(t){x.fetch=t}get fetch(){return x.fetch}}const p=new N,d={maptilerLogoURL:"https://api.maptiler.com/resources/logo.svg",maptilerURL:"https://www.maptiler.com/",maptilerApiHost:"api.maptiler.com",rtlPluginURL:"https://cdn.maptiler.com/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.min.js",primaryLanguage:S.AUTO,secondaryLanguage:S.LOCAL,terrainSourceURL:"https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json",terrainSourceId:"maptiler-terrain"};Object.freeze(d);class I extends y.LogoControl{constructor(t={}){var e,o;super(t),this.logoURL="",this.linkURL="",this.logoURL=(e=t.logoURL)!=null?e:d.maptilerLogoURL,this.linkURL=(o=t.linkURL)!=null?o:d.maptilerURL}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=window.document.createElement("div"),this._container.className="maplibregl-ctrl";const e=window.document.createElement("a");return e.style.backgroundRepeat="no-repeat",e.style.cursor="pointer",e.style.display="block",e.style.height="23px",e.style.margin="0 0 -4px -4px",e.style.overflow="hidden",e.style.width="88px",e.style.backgroundImage=`url(${this.logoURL})`,e.style.backgroundSize="100px 30px",e.style.width="100px",e.style.height="30px",e.target="_blank",e.rel="noopener nofollow",e.href=this.linkURL,e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}}function Q(){y.getRTLTextPluginStatus()==="unavailable"&&y.setRTLTextPlugin(d.rtlPluginURL,null,!0)}function tt(r,t){r.forEach(e=>{!t[e]||(t[e]=t[e].bind(t))})}function A(r,t,e){const o=window.document.createElement(r);return t!==void 0&&(o.className=t),e&&e.appendChild(o),o}function et(r){r.parentNode&&r.parentNode.removeChild(r)}function w(r){return r?typeof r=="string"||r instanceof String?!r.startsWith("http")&&r.toLowerCase().includes(".json")?r:V(r):r instanceof Z?r.getExpandedStyleURL():r instanceof q?r.getDefaultVariant().getExpandedStyleURL():r:J[W[0].referenceStyleID].getDefaultVariant().getExpandedStyleURL()}class R{constructor(){tt(["_toggleTerrain","_updateTerrainIcon"],this)}onAdd(t){return this._map=t,this._container=A("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=A("button","maplibregl-ctrl-terrain",this._container),A("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){et(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}_toggleTerrain(){this._map.hasTerrain()?this._map.disableTerrain():this._map.enableTerrain(),this._updateTerrainIcon()}_updateTerrainIcon(){this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.hasTerrain()?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"))}}class rt extends y.NavigationControl{constructor(){super({showCompass:!0,showZoom:!0,visualizePitch:!0}),this._compass.removeEventListener("click",this._compass.clickFunction),this._compass.addEventListener("click",t=>{this._map.getPitch()===0?this._map.easeTo({pitch:Math.min(this._map.getMaxPitch(),80)}):this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})}_createButton(t,e){const o=super._createButton(t,e);return o.clickFunction=e,o}_rotateCompassArrow(){const t=this.options.visualizePitch?`scale(${Math.min(1.5,1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5))}) rotateX(${Math.min(70,this._map.transform.pitch)}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=t}}var it=Object.defineProperty,at=Object.defineProperties,ot=Object.getOwnPropertyDescriptors,P=Object.getOwnPropertySymbols,nt=Object.prototype.hasOwnProperty,st=Object.prototype.propertyIsEnumerable,O=(r,t,e)=>t in r?it(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,lt=(r,t)=>{for(var e in t||(t={}))nt.call(t,e)&&O(r,e,t[e]);if(P)for(var e of P(t))st.call(t,e)&&O(r,e,t[e]);return r},ct=(r,t)=>at(r,ot(t));const ht=y.GeolocateControl,U=y.Marker,M=y.LngLat;class k extends ht{constructor(){super(...arguments),this.lastUpdatedCenter=new M(0,0)}_updateCamera(t){const e=new M(t.coords.longitude,t.coords.latitude),o=t.coords.accuracy,c=this._map.getBearing(),u=ct(lt({bearing:c},this.options.fitBoundsOptions),{linear:!0}),s=this._map.getZoom();s>this.options.fitBoundsOptions.maxZoom&&(u.zoom=s),this._map.fitBounds(e.toBounds(o),u,{geolocateSource:!0});let i=!1;const a=()=>{i=!0};this._map.once("click",a),this._map.once("dblclick",a),this._map.once("dragstart",a),this._map.once("mousedown",a),this._map.once("touchstart",a),this._map.once("wheel",a),this._map.once("moveend",()=>{this._map.off("click",a),this._map.off("dblclick",a),this._map.off("dragstart",a),this._map.off("mousedown",a),this._map.off("touchstart",a),this._map.off("wheel",a),!i&&(this.lastUpdatedCenter=this._map.getCenter())})}_setupUI(t){if(this.lastUpdatedCenter=this._map.getCenter(),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=A("button","maplibregl-ctrl-geolocate",this._container),A("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",t===!1){const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=A("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new U(this._dotElement),this._circleElement=A("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new U({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("move",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("moveend",e=>{const o=e.originalEvent&&e.originalEvent.type==="resize",c=this.lastUpdatedCenter.distanceTo(this._map.getCenter());!e.geolocateSource&&this._watchState==="ACTIVE_LOCK"&&!o&&c>1&&(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new Event("trackuserlocationend")))})}_updateCircleRadius(){if(this._watchState!=="BACKGROUND"&&this._watchState!=="ACTIVE_LOCK")return;const t=[this._lastKnownPosition.coords.longitude,this._lastKnownPosition.coords.latitude],e=this._map.project(t),o=this._map.unproject([e.x,e.y]),c=this._map.unproject([e.x+20,e.y]),u=o.distanceTo(c)/20,s=Math.ceil(2*this._accuracy/u);this._circleElement.style.width=`${s}px`,this._circleElement.style.height=`${s}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}}var ut=Object.defineProperty,gt=Object.defineProperties,pt=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,dt=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable,$=(r,t,e)=>t in r?ut(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,H=(r,t)=>{for(var e in t||(t={}))dt.call(t,e)&&$(r,e,t[e]);if(B)for(var e of B(t))mt.call(t,e)&&$(r,e,t[e]);return r},j=(r,t)=>gt(r,pt(t)),C=(r,t,e)=>new Promise((o,c)=>{var u=a=>{try{i(e.next(a))}catch(g){c(g)}},s=a=>{try{i(e.throw(a))}catch(g){c(g)}},i=a=>a.done?o(a.value):Promise.resolve(a.value).then(u,s);i((e=e.apply(r,t)).next())});const K=z(),G={POINT:"POINT",COUNTRY:"COUNTRY"};class yt extends y.Map{constructor(t){var e;t.apiKey&&(p.apiKey=t.apiKey);const o=w(t.style),c=location.hash;p.apiKey||console.warn("MapTiler Cloud API key is not set. Visit https://maptiler.com and try Cloud for free!"),super(j(H({},t),{style:o,maplibreLogo:!1,transformRequest:s=>{let i=null;try{i=new URL(s)}catch{return{url:s,headers:{}}}return i.host===d.maptilerApiHost&&(i.searchParams.has("key")||i.searchParams.append("key",p.apiKey),p.session&&i.searchParams.append("mtsid",K)),{url:i.href,headers:{}}}})),this.languageShouldUpdate=!1,this.isStyleInitialized=!1,this.isTerrainEnabled=!1,this.terrainExaggeration=1,this.once("styledata",()=>C(this,null,function*(){if(t.geolocate===!1||t.center||t.hash&&!!c)return;try{if(t.geolocate===G.COUNTRY){yield this.fitToIpBounds();return}}catch(i){console.warn(i.message)}let s=null;try{yield this.centerOnIpPoint(t.zoom),s=this.getCameraHash()}catch(i){console.warn(i.message)}(yield navigator.permissions.query({name:"geolocation"})).state==="granted"&&navigator.geolocation.getCurrentPosition(i=>{s===this.getCameraHash()&&this.easeTo({center:[i.coords.longitude,i.coords.latitude],zoom:t.zoom||12,duration:2e3})},null,{maximumAge:24*3600*1e3,timeout:5e3,enableHighAccuracy:!1})})),this.on("styledataloading",()=>{this.languageShouldUpdate=!!p.primaryLanguage||!!p.secondaryLanguage});let u=!0;this.on("styledata",()=>{t.language&&u?this.setPrimaryLanguage(t.language):p.primaryLanguage&&(this.languageShouldUpdate||!this.isStyleInitialized)&&this.setPrimaryLanguage(p.primaryLanguage),p.secondaryLanguage&&(this.languageShouldUpdate||!this.isStyleInitialized)&&this.setSecondaryLanguage(p.secondaryLanguage),this.languageShouldUpdate=!1,this.isStyleInitialized=!0,u=!1}),this.on("styledata",()=>{this.getTerrain()===null&&this.isTerrainEnabled&&this.enableTerrain(this.terrainExaggeration)}),this.once("load",()=>C(this,null,function*(){Q()})),this.once("load",()=>C(this,null,function*(){let s={logo:null};try{const i=Object.keys(this.style.sourceCaches).map(g=>this.getSource(g)).filter(g=>typeof g.url=="string"&&g.url.includes("tiles.json")),a=new URL(i[0].url);a.searchParams.has("key")||a.searchParams.append("key",p.apiKey),s=yield(yield fetch(a.href)).json()}catch{}if("logo"in s&&s.logo){const i=s.logo;this.addControl(new I({logoURL:i}),t.logoPosition),t.attributionControl===!1&&this.addControl(new y.AttributionControl(t))}else t.maptilerLogo&&this.addControl(new I,t.logoPosition);if(t.scaleControl){const i=t.scaleControl===!0||t.scaleControl===void 0?"bottom-right":t.scaleControl,a=new y.ScaleControl({unit:p.unit});this.addControl(a,i),p.on("unit",g=>{a.setUnit(g)})}if(t.navigationControl!==!1){const i=t.navigationControl===!0||t.navigationControl===void 0?"top-right":t.navigationControl;this.addControl(new rt,i)}if(t.geolocateControl!==!1){const i=t.geolocateControl===!0||t.geolocateControl===void 0?"top-right":t.geolocateControl;this.addControl(new k({positionOptions:{enableHighAccuracy:!0,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!0,showAccuracyCircle:!0,showUserLocation:!0}),i)}if(t.terrainControl){const i=t.terrainControl===!0||t.terrainControl===void 0?"top-right":t.terrainControl;this.addControl(new R,i)}if(t.fullscreenControl){const i=t.fullscreenControl===!0||t.fullscreenControl===void 0?"top-right":t.fullscreenControl;this.addControl(new y.FullscreenControl({}),i)}})),t.terrain&&this.enableTerrain((e=t.terrainExaggeration)!=null?e:this.terrainExaggeration)}setStyle(t,e){return super.setStyle(w(t),e)}setLanguage(t=d.primaryLanguage){if(t===S.AUTO)return this.setLanguage(T());this.setPrimaryLanguage(t)}setPrimaryLanguage(t=d.primaryLanguage){!E(t)||this.onStyleReady(()=>{if(t===S.AUTO)return this.setPrimaryLanguage(T());const e=this.getStyle().layers,o=/^\s*{\s*name\s*(:\s*(\S*))?\s*}$/,c=/^\s*name\s*(:\s*(\S*))?\s*$/,u=/^\s*{\s*name\s*(:\s*(\S*))?\s*}(\s*){\s*name\s*(:\s*(\S*))?\s*}$/,s=/^(.*)({\s*name\s*(:\s*(\S*))?\s*})(.*)$/,i=t?`name:${t}`:"name",a=["case",["has",i],["get",i],["get","name:latin"]];for(let g=0;g<e.length;g+=1){const h=e[g],f=h.layout;if(!f||!f["text-field"])continue;const n=this.getLayoutProperty(h.id,"text-field");let m;if(Array.isArray(n)&&n.length>=2&&n[0].trim().toLowerCase()==="concat"){const l=n.slice();for(let L=0;L<n.length;L+=1){const _=n[L];if((typeof _=="string"||_ instanceof String)&&o.exec(_.toString())){l[L]=a;break}else if(Array.isArray(_)&&_.length>=2&&_[0].trim().toLowerCase()==="get"&&c.exec(_[1].toString())){l[L]=a;break}else if(Array.isArray(_)&&_.length===4&&_[0].trim().toLowerCase()==="case"){l[L]=a;break}}this.setLayoutProperty(h.id,"text-field",l)}else if(Array.isArray(n)&&n.length>=2&&n[0].trim().toLowerCase()==="get"&&c.exec(n[1].toString())){const l=a;this.setLayoutProperty(h.id,"text-field",l)}else if((typeof n=="string"||n instanceof String)&&o.exec(n.toString())){const l=a;this.setLayoutProperty(h.id,"text-field",l)}else if(Array.isArray(n)&&n.length===4&&n[0].trim().toLowerCase()==="case"){const l=a;this.setLayoutProperty(h.id,"text-field",l)}else if((typeof n=="string"||n instanceof String)&&(m=u.exec(n.toString()))!==null){const l=`{${i}}${m[3]}{name${m[4]||""}}`;this.setLayoutProperty(h.id,"text-field",l)}else if((typeof n=="string"||n instanceof String)&&(m=s.exec(n.toString()))!==null){const l=`${m[1]}{${i}}${m[5]}`;this.setLayoutProperty(h.id,"text-field",l)}}})}setSecondaryLanguage(t=d.secondaryLanguage){!E(t)||this.onStyleReady(()=>{if(t===S.AUTO)return this.setSecondaryLanguage(T());const e=this.getStyle().layers,o=/^\s*{\s*name\s*(:\s*(\S*))?\s*}$/,c=/^\s*name\s*(:\s*(\S*))?\s*$/,u=/^\s*{\s*name\s*(:\s*(\S*))?\s*}(\s*){\s*name\s*(:\s*(\S*))?\s*}$/;let s;for(let i=0;i<e.length;i+=1){const a=e[i],g=a.layout;if(!g||!g["text-field"])continue;const h=this.getLayoutProperty(a.id,"text-field");let f;if(Array.isArray(h)&&h.length>=2&&h[0].trim().toLowerCase()==="concat"){f=h.slice();let n=0;for(let m=0;m<h.length;m+=1){const l=h[m];if((typeof l=="string"||l instanceof String)&&o.exec(l.toString())){if(n===1){f[m]=`{name:${t}}`;break}n+=1}else if(Array.isArray(l)&&l.length>=2&&l[0].trim().toLowerCase()==="get"&&c.exec(l[1].toString())){if(n===1){f[m][1]=`name:${t}`;break}n+=1}else if(Array.isArray(l)&&l.length===4&&l[0].trim().toLowerCase()==="case"){if(n===1){f[m]=["get",`name:${t}`];break}n+=1}}this.setLayoutProperty(a.id,"text-field",f)}else if((typeof h=="string"||h instanceof String)&&(s=u.exec(h.toString()))!==null){const n=t?`name:${t}`:"name";f=`{name${s[1]||""}}${s[3]}{${n}}`,this.setLayoutProperty(a.id,"text-field",f)}}})}getTerrainExaggeration(){return this.terrainExaggeration}hasTerrain(){return this.isTerrainEnabled}enableTerrain(t=this.terrainExaggeration){if(t<0){console.warn("Terrain exaggeration cannot be negative.");return}const e=this.getTerrain(),o=()=>{this.isTerrainEnabled=!0,this.terrainExaggeration=t,this.addSource(d.terrainSourceId,{type:"raster-dem",url:d.terrainSourceURL}),this.setTerrain({source:d.terrainSourceId,exaggeration:t})};if(e){this.setTerrain(j(H({},e),{exaggeration:t}));return}this.loaded()||this.isTerrainEnabled?o():this.once("load",()=>{this.getTerrain()&&this.getSource(d.terrainSourceId)||o()})}disableTerrain(){this.isTerrainEnabled=!1,this.setTerrain(null),this.getSource(d.terrainSourceId)&&this.removeSource(d.terrainSourceId)}setTerrainExaggeration(t){this.enableTerrain(t)}onStyleReady(t){this.isStyleLoaded()?t():this.once("styledata",()=>{t()})}fitToIpBounds(){return C(this,null,function*(){const t=yield v.info();this.fitBounds(t.country_bounds,{duration:0,padding:100})})}centerOnIpPoint(t){return C(this,null,function*(){const e=yield v.info();this.jumpTo({center:[e.longitude,e.latitude],zoom:t||11})})}getCameraHash(){const t=new Float32Array(5),e=this.getCenter();return t[0]=e.lng,t[1]=e.lat,t[2]=this.getZoom(),t[3]=this.getPitch(),t[4]=this.getBearing(),D.fromUint8Array(new Uint8Array(t.buffer))}getSdkConfig(){return p}getMaptilerSessionId(){return K}}class b{constructor(t,e){this.x=t,this.y=e}_matMult(t){const e=t[0]*this.x+t[1]*this.y,o=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=o,this}_add(t){return this.x+=t.x,this.y+=t.y,this}_sub(t){return this.x-=t.x,this.y-=t.y,this}_mult(t){return this.x*=t,this.y*=t,this}_div(t){return this.x/=t,this.y/=t,this}_multByPoint(t){return this.x*=t.x,this.y*=t.y,this}_divByPoint(t){return this.x/=t.x,this.y/=t.y,this}_unit(){return this._div(this.mag()),this}_perp(){const t=this.y;return this.y=this.x,this.x=-t,this}_rotate(t){const e=Math.cos(t),o=Math.sin(t),c=e*this.x-o*this.y,u=o*this.x+e*this.y;return this.x=c,this.y=u,this}_rotateAround(t,e){const o=Math.cos(t),c=Math.sin(t),u=e.x+o*(this.x-e.x)-c*(this.y-e.y),s=e.y+c*(this.x-e.x)+o*(this.y-e.y);return this.x=u,this.y=s,this}_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}clone(){return new b(this.x,this.y)}add(t){return this.clone()._add(t)}sub(t){return this.clone()._sub(t)}multByPoint(t){return this.clone()._multByPoint(t)}divByPoint(t){return this.clone()._divByPoint(t)}mult(t){return this.clone()._mult(t)}div(t){return this.clone()._div(t)}rotate(t){return this.clone()._rotate(t)}rotateAround(t,e){return this.clone()._rotateAround(t,e)}matMult(t){return this.clone()._matMult(t)}unit(){return this.clone()._unit()}perp(){return this.clone()._perp()}round(){return this.clone()._round()}mag(){return Math.sqrt(this.x*this.x+this.y*this.y)}equals(t){return this.x===t.x&&this.y===t.y}dist(t){return Math.sqrt(this.distSqr(t))}distSqr(t){const e=t.x-this.x,o=t.y-this.y;return e*e+o*o}angle(){return Math.atan2(this.y,this.x)}angleTo(t){return Math.atan2(this.y-t.y,this.x-t.x)}angleWith(t){return this.angleWithSep(t.x,t.y)}angleWithSep(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)}static convert(t){return t instanceof b?t:Array.isArray(t)?new b(t[0],t[1]):t}}const{supported:ft,setRTLTextPlugin:_t,getRTLTextPluginStatus:St,NavigationControl:At,GeolocateControl:Lt,AttributionControl:Ct,LogoControl:bt,ScaleControl:xt,FullscreenControl:Tt,TerrainControl:It,Popup:vt,Marker:Et,Style:Nt,LngLat:wt,LngLatBounds:Rt,MercatorCoordinate:Pt,Evented:Ot,AJAXError:Ut,CanvasSource:Mt,GeoJSONSource:kt,ImageSource:Bt,RasterDEMTileSource:$t,RasterTileSource:Ht,VectorTileSource:jt,VideoSource:Kt,prewarm:Gt,clearPrewarmedResources:Dt,version:zt,workerCount:Ft,maxParallelImageRequests:Vt,clearStorage:Zt,workerUrl:qt,addProtocol:Jt,removeProtocol:Wt}=y;export{Ut as AJAXError,Ct as AttributionControl,Mt as CanvasSource,Ot as Evented,Tt as FullscreenControl,kt as GeoJSONSource,Lt as GeolocateControl,G as GeolocationType,Bt as ImageSource,S as Language,oe as LanguageGeocoding,wt as LngLat,Rt as LngLatBounds,bt as LogoControl,yt as Map,ne as MapStyle,se as MapStyleVariant,k as MaptilerGeolocateControl,I as MaptilerLogoControl,R as MaptilerTerrainControl,Et as Marker,Pt as MercatorCoordinate,At as NavigationControl,b as Point,vt as Popup,$t as RasterDEMTileSource,Ht as RasterTileSource,le as ReferenceMapStyle,xt as ScaleControl,N as SdkConfig,ce as ServiceError,Nt as Style,It as TerrainControl,jt as VectorTileSource,Kt as VideoSource,Jt as addProtocol,Dt as clearPrewarmedResources,Zt as clearStorage,p as config,he as coordinates,ue as data,ge as geocoding,pe as geolocation,St as getRTLTextPluginStatus,Vt as maxParallelImageRequests,Gt as prewarm,Wt as removeProtocol,_t as setRTLTextPlugin,de as staticMaps,ft as supported,zt as version,Ft as workerCount,qt as workerUrl};
|
package/dist/maptiler-sdk.mjs
CHANGED
|
@@ -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) {
|
|
@@ -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 {
|