@maptiler/sdk 1.0.0

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.
Files changed (203) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.cjs +10 -0
  3. package/.github/workflows/npm-publish.yml +23 -0
  4. package/LICENSE +29 -0
  5. package/demos/maptiler-sdk.css +147 -0
  6. package/demos/maptiler-sdk.umd.js +3287 -0
  7. package/demos/simple.html +63 -0
  8. package/dist/maptiler-sdk.css +147 -0
  9. package/dist/maptiler-sdk.d.ts +531 -0
  10. package/dist/maptiler-sdk.min.mjs +1 -0
  11. package/dist/maptiler-sdk.mjs +1128 -0
  12. package/dist/maptiler-sdk.mjs.map +1 -0
  13. package/dist/maptiler-sdk.umd.js +3287 -0
  14. package/dist/maptiler-sdk.umd.js.map +1 -0
  15. package/dist/maptiler-sdk.umd.min.js +579 -0
  16. package/docs/.nojekyll +1 -0
  17. package/docs/assets/custom.css +118 -0
  18. package/docs/assets/highlight.css +134 -0
  19. package/docs/assets/main.js +54 -0
  20. package/docs/assets/search.js +1 -0
  21. package/docs/assets/style.css +1257 -0
  22. package/docs/classes/Map.html +273 -0
  23. package/docs/classes/Point.html +549 -0
  24. package/docs/classes/SdkConfig.html +188 -0
  25. package/docs/demos/maptiler-sdk.css +147 -0
  26. package/docs/demos/maptiler-sdk.umd.js +3287 -0
  27. package/docs/demos/simple.html +63 -0
  28. package/docs/functions/addProtocol.html +146 -0
  29. package/docs/functions/clearPrewarmedResources.html +92 -0
  30. package/docs/functions/clearStorage.html +124 -0
  31. package/docs/functions/getRTLTextPluginStatus.html +92 -0
  32. package/docs/functions/prewarm.html +92 -0
  33. package/docs/functions/removeProtocol.html +106 -0
  34. package/docs/functions/setRTLTextPlugin.html +112 -0
  35. package/docs/functions/supported.html +97 -0
  36. package/docs/images/JS-logo.svg +4 -0
  37. package/docs/images/TS-logo.svg +6 -0
  38. package/docs/images/maptiler-logo.svg +19 -0
  39. package/docs/images/maptiler-sdk-logo.afdesign +0 -0
  40. package/docs/images/maptiler-sdk-logo.svg +66 -0
  41. package/docs/images/screenshots/alps.gif +0 -0
  42. package/docs/images/screenshots/grandcanyon.gif +0 -0
  43. package/docs/images/screenshots/lang-arabic.png +0 -0
  44. package/docs/images/screenshots/lang-hebrew.png +0 -0
  45. package/docs/images/screenshots/multilang.gif +0 -0
  46. package/docs/images/screenshots/static-bounded-europe-1024.png +0 -0
  47. package/docs/images/screenshots/static-bounded-europe-2048.png +0 -0
  48. package/docs/images/screenshots/static-bounded-portugal-1024x2048.png +0 -0
  49. package/docs/images/screenshots/static-bounded-portugal-2048x2048.png +0 -0
  50. package/docs/images/screenshots/static-with-path.png +0 -0
  51. package/docs/images/screenshots/style-basic-v2.png +0 -0
  52. package/docs/images/screenshots/style-bright.png +0 -0
  53. package/docs/images/screenshots/style-dataviz-dark.png +0 -0
  54. package/docs/images/screenshots/style-hybrid.png +0 -0
  55. package/docs/images/screenshots/style-osm.png +0 -0
  56. package/docs/images/screenshots/style-outdoor.png +0 -0
  57. package/docs/images/screenshots/style-pastel.png +0 -0
  58. package/docs/images/screenshots/style-satellite.png +0 -0
  59. package/docs/images/screenshots/style-streets-v2-dark.png +0 -0
  60. package/docs/images/screenshots/style-streets-v2-light.png +0 -0
  61. package/docs/images/screenshots/style-streets-v2.png +0 -0
  62. package/docs/images/screenshots/style-toner.png +0 -0
  63. package/docs/images/screenshots/style-topo.png +0 -0
  64. package/docs/images/screenshots/style-topographique.png +0 -0
  65. package/docs/images/screenshots/style-voyager.png +0 -0
  66. package/docs/images/screenshots/style-winter.png +0 -0
  67. package/docs/index.html +601 -0
  68. package/docs/modules.html +142 -0
  69. package/docs/types/LanguageKey.html +90 -0
  70. package/docs/types/LanguageString.html +90 -0
  71. package/docs/types/MapOptions.html +90 -0
  72. package/docs/types/Matrix2.html +90 -0
  73. package/docs/types/Unit.html +88 -0
  74. package/docs/variables/AJAXError.html +88 -0
  75. package/docs/variables/AttributionControl.html +88 -0
  76. package/docs/variables/CanvasSource.html +88 -0
  77. package/docs/variables/Evented.html +88 -0
  78. package/docs/variables/FullscreenControl.html +88 -0
  79. package/docs/variables/GeoJSONSource.html +88 -0
  80. package/docs/variables/GeolocateControl.html +88 -0
  81. package/docs/variables/GeolocationType.html +95 -0
  82. package/docs/variables/ImageSource.html +88 -0
  83. package/docs/variables/Language.html +249 -0
  84. package/docs/variables/LngLat.html +88 -0
  85. package/docs/variables/LngLatBounds.html +88 -0
  86. package/docs/variables/LogoControl.html +88 -0
  87. package/docs/variables/Marker.html +88 -0
  88. package/docs/variables/MercatorCoordinate.html +88 -0
  89. package/docs/variables/NavigationControl.html +88 -0
  90. package/docs/variables/Popup.html +88 -0
  91. package/docs/variables/RasterDEMTileSource.html +88 -0
  92. package/docs/variables/RasterTileSource.html +88 -0
  93. package/docs/variables/ScaleControl.html +88 -0
  94. package/docs/variables/Style.html +88 -0
  95. package/docs/variables/TerrainControl.html +88 -0
  96. package/docs/variables/VectorTileSource.html +88 -0
  97. package/docs/variables/VideoSource.html +88 -0
  98. package/docs/variables/config.html +88 -0
  99. package/docs/variables/maxParallelImageRequests.html +88 -0
  100. package/docs/variables/version.html +88 -0
  101. package/docs/variables/workerCount.html +88 -0
  102. package/docs/variables/workerUrl.html +88 -0
  103. package/docsmd/.nojekyll +1 -0
  104. package/docsmd/README.md +710 -0
  105. package/docsmd/assets/custom.css +118 -0
  106. package/docsmd/classes/Map.md +292 -0
  107. package/docsmd/classes/Point.md +603 -0
  108. package/docsmd/classes/SdkConfig.md +186 -0
  109. package/docsmd/images/JS-logo.svg +4 -0
  110. package/docsmd/images/TS-logo.svg +6 -0
  111. package/docsmd/images/maptiler-logo.svg +19 -0
  112. package/docsmd/images/maptiler-sdk-logo.afdesign +0 -0
  113. package/docsmd/images/maptiler-sdk-logo.svg +66 -0
  114. package/docsmd/images/screenshots/alps.gif +0 -0
  115. package/docsmd/images/screenshots/grandcanyon.gif +0 -0
  116. package/docsmd/images/screenshots/lang-arabic.png +0 -0
  117. package/docsmd/images/screenshots/lang-hebrew.png +0 -0
  118. package/docsmd/images/screenshots/multilang.gif +0 -0
  119. package/docsmd/images/screenshots/static-bounded-europe-1024.png +0 -0
  120. package/docsmd/images/screenshots/static-bounded-europe-2048.png +0 -0
  121. package/docsmd/images/screenshots/static-bounded-portugal-1024x2048.png +0 -0
  122. package/docsmd/images/screenshots/static-bounded-portugal-2048x2048.png +0 -0
  123. package/docsmd/images/screenshots/static-with-path.png +0 -0
  124. package/docsmd/images/screenshots/style-basic-v2.png +0 -0
  125. package/docsmd/images/screenshots/style-bright.png +0 -0
  126. package/docsmd/images/screenshots/style-dataviz-dark.png +0 -0
  127. package/docsmd/images/screenshots/style-hybrid.png +0 -0
  128. package/docsmd/images/screenshots/style-osm.png +0 -0
  129. package/docsmd/images/screenshots/style-outdoor.png +0 -0
  130. package/docsmd/images/screenshots/style-pastel.png +0 -0
  131. package/docsmd/images/screenshots/style-satellite.png +0 -0
  132. package/docsmd/images/screenshots/style-streets-v2-dark.png +0 -0
  133. package/docsmd/images/screenshots/style-streets-v2-light.png +0 -0
  134. package/docsmd/images/screenshots/style-streets-v2.png +0 -0
  135. package/docsmd/images/screenshots/style-toner.png +0 -0
  136. package/docsmd/images/screenshots/style-topo.png +0 -0
  137. package/docsmd/images/screenshots/style-topographique.png +0 -0
  138. package/docsmd/images/screenshots/style-voyager.png +0 -0
  139. package/docsmd/images/screenshots/style-winter.png +0 -0
  140. package/images/JS-logo.svg +4 -0
  141. package/images/TS-logo.svg +6 -0
  142. package/images/maptiler-logo.svg +19 -0
  143. package/images/maptiler-sdk-logo.afdesign +0 -0
  144. package/images/maptiler-sdk-logo.svg +66 -0
  145. package/images/screenshots/alps.gif +0 -0
  146. package/images/screenshots/grandcanyon.gif +0 -0
  147. package/images/screenshots/lang-arabic.png +0 -0
  148. package/images/screenshots/lang-hebrew.png +0 -0
  149. package/images/screenshots/multilang.gif +0 -0
  150. package/images/screenshots/static-bounded-europe-1024.png +0 -0
  151. package/images/screenshots/static-bounded-europe-2048.png +0 -0
  152. package/images/screenshots/static-bounded-portugal-1024x2048.png +0 -0
  153. package/images/screenshots/static-bounded-portugal-2048x2048.png +0 -0
  154. package/images/screenshots/static-with-path.png +0 -0
  155. package/images/screenshots/style-basic-v2.png +0 -0
  156. package/images/screenshots/style-bright.png +0 -0
  157. package/images/screenshots/style-dataviz-dark.png +0 -0
  158. package/images/screenshots/style-hybrid.png +0 -0
  159. package/images/screenshots/style-osm.png +0 -0
  160. package/images/screenshots/style-outdoor.png +0 -0
  161. package/images/screenshots/style-pastel.png +0 -0
  162. package/images/screenshots/style-satellite.png +0 -0
  163. package/images/screenshots/style-streets-v2-dark.png +0 -0
  164. package/images/screenshots/style-streets-v2-light.png +0 -0
  165. package/images/screenshots/style-streets-v2.png +0 -0
  166. package/images/screenshots/style-toner.png +0 -0
  167. package/images/screenshots/style-topo.png +0 -0
  168. package/images/screenshots/style-topographique.png +0 -0
  169. package/images/screenshots/style-voyager.png +0 -0
  170. package/images/screenshots/style-winter.png +0 -0
  171. package/package.json +71 -0
  172. package/readme.md +609 -0
  173. package/rollup.config.js +161 -0
  174. package/scripts/replace-path-with-content.js +51 -0
  175. package/src/CustomGeolocateControl.ts +193 -0
  176. package/src/CustomLogoControl.ts +59 -0
  177. package/src/Map.ts +897 -0
  178. package/src/MaptilerNavigationControl.ts +66 -0
  179. package/src/Point.ts +336 -0
  180. package/src/TerrainControl.ts +87 -0
  181. package/src/config.ts +92 -0
  182. package/src/defaults.ts +20 -0
  183. package/src/index.ts +171 -0
  184. package/src/language.ts +139 -0
  185. package/src/mapstyle.ts +38 -0
  186. package/src/style/style_template.css +146 -0
  187. package/src/style/svg/v6-compass.svg +12 -0
  188. package/src/style/svg/v6-fullscreen-off.svg +7 -0
  189. package/src/style/svg/v6-fullscreen.svg +7 -0
  190. package/src/style/svg/v6-geolocate-active-error.svg +10 -0
  191. package/src/style/svg/v6-geolocate-active.svg +7 -0
  192. package/src/style/svg/v6-geolocate-background.svg +8 -0
  193. package/src/style/svg/v6-geolocate-disabled.svg +10 -0
  194. package/src/style/svg/v6-geolocate.svg +7 -0
  195. package/src/style/svg/v6-terrain-on.svg +7 -0
  196. package/src/style/svg/v6-terrain.svg +7 -0
  197. package/src/style/svg/v6-zoom-minus.svg +7 -0
  198. package/src/style/svg/v6-zoom-plus.svg +7 -0
  199. package/src/tools.ts +45 -0
  200. package/src/unit.ts +1 -0
  201. package/tsconfig.json +11 -0
  202. package/typedoc.css +118 -0
  203. package/typedoc.json +13 -0
@@ -0,0 +1,1128 @@
1
+ import maplibregl__default, { GeolocateControl as GeolocateControl$1, LngLat as LngLat$1, Marker as Marker$1 } from 'maplibre-gl';
2
+ export * from 'maplibre-gl';
3
+ import { Base64 } from 'js-base64';
4
+ import { v4 } from 'uuid';
5
+ import EventEmitter from 'events';
6
+ import { config as config$1, MapStyle, mapStylePresetList, expandMapStyle, MapStyleVariant, ReferenceMapStyle, geolocation } from '@maptiler/client';
7
+ export { LanguageGeocoding, MapStyle, MapStyleVariant, ReferenceMapStyle, ServiceError, coordinates, data, geocoding, geolocation, staticMaps } from '@maptiler/client';
8
+
9
+ const Language = {
10
+ AUTO: "auto",
11
+ LATIN: "latin",
12
+ NON_LATIN: "nonlatin",
13
+ LOCAL: "",
14
+ ALBANIAN: "sq",
15
+ AMHARIC: "am",
16
+ ARABIC: "ar",
17
+ ARMENIAN: "hy",
18
+ AZERBAIJANI: "az",
19
+ BASQUE: "eu",
20
+ BELORUSSIAN: "be",
21
+ BOSNIAN: "bs",
22
+ BRETON: "br",
23
+ BULGARIAN: "bg",
24
+ CATALAN: "ca",
25
+ CHINESE: "zh",
26
+ CORSICAN: "co",
27
+ CROATIAN: "hr",
28
+ CZECH: "cs",
29
+ DANISH: "da",
30
+ DUTCH: "nl",
31
+ ENGLISH: "en",
32
+ ESPERANTO: "eo",
33
+ ESTONIAN: "et",
34
+ FINNISH: "fi",
35
+ FRENCH: "fr",
36
+ FRISIAN: "fy",
37
+ GEORGIAN: "ka",
38
+ GERMAN: "de",
39
+ GREEK: "el",
40
+ HEBREW: "he",
41
+ HINDI: "hi",
42
+ HUNGARIAN: "hu",
43
+ ICELANDIC: "is",
44
+ INDONESIAN: "id",
45
+ IRISH: "ga",
46
+ ITALIAN: "it",
47
+ JAPANESE: "ja",
48
+ JAPANESE_HIRAGANA: "ja-Hira",
49
+ JAPANESE_KANA: "ja_kana",
50
+ JAPANESE_LATIN: "ja_rm",
51
+ JAPANESE_2018: "ja-Latn",
52
+ KANNADA: "kn",
53
+ KAZAKH: "kk",
54
+ KOREAN: "ko",
55
+ KOREAN_LATIN: "ko-Latn",
56
+ KURDISH: "ku",
57
+ ROMAN_LATIN: "la",
58
+ LATVIAN: "lv",
59
+ LITHUANIAN: "lt",
60
+ LUXEMBOURGISH: "lb",
61
+ MACEDONIAN: "mk",
62
+ MALAYALAM: "ml",
63
+ MALTESE: "mt",
64
+ NORWEGIAN: "no",
65
+ OCCITAN: "oc",
66
+ POLISH: "pl",
67
+ PORTUGUESE: "pt",
68
+ ROMANIAN: "ro",
69
+ ROMANSH: "rm",
70
+ RUSSIAN: "ru",
71
+ SCOTTISH_GAELIC: "gd",
72
+ SERBIAN_CYRILLIC: "sr",
73
+ SERBIAN_LATIN: "sr-Latn",
74
+ SLOVAK: "sk",
75
+ SLOVENE: "sl",
76
+ SPANISH: "es",
77
+ SWEDISH: "sv",
78
+ TAMIL: "ta",
79
+ TELUGU: "te",
80
+ THAI: "th",
81
+ TURKISH: "tr",
82
+ UKRAINIAN: "uk",
83
+ WELSH: "cy"
84
+ };
85
+ const languagesIsoSet = new Set(Object.values(Language));
86
+ function isLanguageSupported(lang) {
87
+ return languagesIsoSet.has(lang);
88
+ }
89
+ const languageCodeSet = new Set(Object.values(Language));
90
+ function getBrowserLanguage() {
91
+ if (typeof navigator === "undefined") {
92
+ return Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];
93
+ }
94
+ const canditatelangs = Array.from(
95
+ new Set(navigator.languages.map((l) => l.split("-")[0]))
96
+ ).filter((l) => languageCodeSet.has(l));
97
+ return canditatelangs.length ? canditatelangs[0] : Language.LATIN;
98
+ }
99
+
100
+ class SdkConfig extends EventEmitter {
101
+ constructor() {
102
+ super();
103
+ this.primaryLanguage = Language.AUTO;
104
+ this.secondaryLanguage = null;
105
+ this.session = true;
106
+ this._unit = "metric";
107
+ this._apiKey = "";
108
+ }
109
+ set unit(u) {
110
+ this._unit = u;
111
+ this.emit("unit", u);
112
+ }
113
+ get unit() {
114
+ return this._unit;
115
+ }
116
+ set apiKey(k) {
117
+ this._apiKey = k;
118
+ config$1.apiKey = k;
119
+ this.emit("apiKey", k);
120
+ }
121
+ get apiKey() {
122
+ return this._apiKey;
123
+ }
124
+ set fetch(f) {
125
+ config$1.fetch = f;
126
+ }
127
+ get fetch() {
128
+ return config$1.fetch;
129
+ }
130
+ }
131
+ const config = new SdkConfig();
132
+
133
+ const defaults = {
134
+ maptilerLogoURL: "https://api.maptiler.com/resources/logo.svg",
135
+ maptilerURL: "https://www.maptiler.com/",
136
+ maptilerApiHost: "api.maptiler.com",
137
+ rtlPluginURL: "https://cdn.maptiler.com/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.min.js",
138
+ primaryLanguage: Language.AUTO,
139
+ secondaryLanguage: Language.LOCAL,
140
+ terrainSourceURL: "https://api.maptiler.com/tiles/terrain-rgb/tiles.json",
141
+ terrainSourceId: "maptiler-terrain"
142
+ };
143
+ Object.freeze(defaults);
144
+
145
+ class CustomLogoControl extends maplibregl__default.LogoControl {
146
+ constructor(options = {}) {
147
+ var _a, _b;
148
+ super(options);
149
+ this.logoURL = "";
150
+ this.linkURL = "";
151
+ this.logoURL = (_a = options.logoURL) != null ? _a : defaults.maptilerLogoURL;
152
+ this.linkURL = (_b = options.linkURL) != null ? _b : defaults.maptilerURL;
153
+ }
154
+ onAdd(map) {
155
+ this._map = map;
156
+ this._compact = this.options && this.options.compact;
157
+ this._container = window.document.createElement("div");
158
+ this._container.className = "maplibregl-ctrl";
159
+ const anchor = window.document.createElement("a");
160
+ anchor.style.backgroundRepeat = "no-repeat";
161
+ anchor.style.cursor = "pointer";
162
+ anchor.style.display = "block";
163
+ anchor.style.height = "23px";
164
+ anchor.style.margin = "0 0 -4px -4px";
165
+ anchor.style.overflow = "hidden";
166
+ anchor.style.width = "88px";
167
+ anchor.style.backgroundImage = `url(${this.logoURL})`;
168
+ anchor.style.backgroundSize = "100px 30px";
169
+ anchor.style.width = "100px";
170
+ anchor.style.height = "30px";
171
+ anchor.target = "_blank";
172
+ anchor.rel = "noopener nofollow";
173
+ anchor.href = this.linkURL;
174
+ anchor.setAttribute(
175
+ "aria-label",
176
+ this._map._getUIString("LogoControl.Title")
177
+ );
178
+ anchor.setAttribute("rel", "noopener nofollow");
179
+ this._container.appendChild(anchor);
180
+ this._container.style.display = "block";
181
+ this._map.on("resize", this._updateCompact);
182
+ this._updateCompact();
183
+ return this._container;
184
+ }
185
+ }
186
+
187
+ function enableRTL() {
188
+ if (maplibregl__default.getRTLTextPluginStatus() === "unavailable") {
189
+ maplibregl__default.setRTLTextPlugin(
190
+ defaults.rtlPluginURL,
191
+ null,
192
+ true
193
+ );
194
+ }
195
+ }
196
+ function bindAll(fns, context) {
197
+ fns.forEach((fn) => {
198
+ if (!context[fn]) {
199
+ return;
200
+ }
201
+ context[fn] = context[fn].bind(context);
202
+ });
203
+ }
204
+ function DOMcreate(tagName, className, container) {
205
+ const el = window.document.createElement(tagName);
206
+ if (className !== void 0)
207
+ el.className = className;
208
+ if (container)
209
+ container.appendChild(el);
210
+ return el;
211
+ }
212
+ function DOMremove(node) {
213
+ if (node.parentNode) {
214
+ node.parentNode.removeChild(node);
215
+ }
216
+ }
217
+
218
+ function styleToStyle(style) {
219
+ if (!style) {
220
+ return MapStyle[mapStylePresetList[0].referenceStyleID].getDefaultVariant().getExpandedStyleURL();
221
+ }
222
+ if (typeof style === "string" || style instanceof String) {
223
+ return expandMapStyle(style);
224
+ }
225
+ if (style instanceof MapStyleVariant) {
226
+ return style.getExpandedStyleURL();
227
+ }
228
+ if (style instanceof ReferenceMapStyle) {
229
+ return style.getDefaultVariant().getExpandedStyleURL();
230
+ }
231
+ return style;
232
+ }
233
+
234
+ class TerrainControl$1 {
235
+ constructor() {
236
+ bindAll(["_toggleTerrain", "_updateTerrainIcon"], this);
237
+ }
238
+ onAdd(map) {
239
+ this._map = map;
240
+ this._container = DOMcreate("div", "maplibregl-ctrl maplibregl-ctrl-group");
241
+ this._terrainButton = DOMcreate(
242
+ "button",
243
+ "maplibregl-ctrl-terrain",
244
+ this._container
245
+ );
246
+ DOMcreate("span", "maplibregl-ctrl-icon", this._terrainButton).setAttribute(
247
+ "aria-hidden",
248
+ "true"
249
+ );
250
+ this._terrainButton.type = "button";
251
+ this._terrainButton.addEventListener("click", this._toggleTerrain);
252
+ this._updateTerrainIcon();
253
+ this._map.on("terrain", this._updateTerrainIcon);
254
+ return this._container;
255
+ }
256
+ onRemove() {
257
+ DOMremove(this._container);
258
+ this._map.off("terrain", this._updateTerrainIcon);
259
+ this._map = void 0;
260
+ }
261
+ _toggleTerrain() {
262
+ if (this._map.hasTerrain()) {
263
+ this._map.disableTerrain();
264
+ } else {
265
+ this._map.enableTerrain();
266
+ }
267
+ this._updateTerrainIcon();
268
+ }
269
+ _updateTerrainIcon() {
270
+ this._terrainButton.classList.remove("maplibregl-ctrl-terrain");
271
+ this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled");
272
+ if (this._map.hasTerrain()) {
273
+ this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled");
274
+ this._terrainButton.title = this._map._getUIString(
275
+ "TerrainControl.disableTerrain"
276
+ );
277
+ } else {
278
+ this._terrainButton.classList.add("maplibregl-ctrl-terrain");
279
+ this._terrainButton.title = this._map._getUIString(
280
+ "TerrainControl.enableTerrain"
281
+ );
282
+ }
283
+ }
284
+ }
285
+
286
+ class MaptilerNavigationControl extends maplibregl__default.NavigationControl {
287
+ constructor() {
288
+ super({
289
+ showCompass: true,
290
+ showZoom: true,
291
+ visualizePitch: true
292
+ });
293
+ this._compass.removeEventListener(
294
+ "click",
295
+ this._compass.clickFunction
296
+ );
297
+ this._compass.addEventListener("click", (e) => {
298
+ {
299
+ const currentPitch = this._map.getPitch();
300
+ if (currentPitch === 0) {
301
+ this._map.easeTo({ pitch: Math.min(this._map.getMaxPitch(), 80) });
302
+ } else {
303
+ if (this.options.visualizePitch) {
304
+ this._map.resetNorthPitch({}, { originalEvent: e });
305
+ } else {
306
+ this._map.resetNorth({}, { originalEvent: e });
307
+ }
308
+ }
309
+ }
310
+ });
311
+ }
312
+ _createButton(className, fn) {
313
+ const button = super._createButton(className, fn);
314
+ button.clickFunction = fn;
315
+ return button;
316
+ }
317
+ _rotateCompassArrow() {
318
+ const rotate = this.options.visualizePitch ? `scale(${Math.min(
319
+ 1.5,
320
+ 1 / Math.pow(Math.cos(this._map.transform.pitch * (Math.PI / 180)), 0.5)
321
+ )}) 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)`;
322
+ this._compassIcon.style.transform = rotate;
323
+ }
324
+ }
325
+
326
+ var __defProp$1 = Object.defineProperty;
327
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
328
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
329
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
330
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
331
+ var __spreadValues$1 = (a, b) => {
332
+ for (var prop in b || (b = {}))
333
+ if (__hasOwnProp$1.call(b, prop))
334
+ __defNormalProp$1(a, prop, b[prop]);
335
+ if (__getOwnPropSymbols$1)
336
+ for (var prop of __getOwnPropSymbols$1(b)) {
337
+ if (__propIsEnum$1.call(b, prop))
338
+ __defNormalProp$1(a, prop, b[prop]);
339
+ }
340
+ return a;
341
+ };
342
+ class CustomGeolocateControl extends GeolocateControl$1 {
343
+ _updateCamera(position) {
344
+ const center = new LngLat$1(
345
+ position.coords.longitude,
346
+ position.coords.latitude
347
+ );
348
+ const radius = position.coords.accuracy;
349
+ const bearing = this._map.getBearing();
350
+ const options = __spreadValues$1({
351
+ bearing
352
+ }, this.options.fitBoundsOptions);
353
+ console.log("moving camera");
354
+ this._map.fitBounds(center.toBounds(radius), options, {
355
+ geolocateSource: true
356
+ });
357
+ let hasFittingBeenDisrupted = false;
358
+ const flagFittingDisruption = () => {
359
+ console.log("DISRUPTED FITTING!");
360
+ hasFittingBeenDisrupted = true;
361
+ };
362
+ this._map.once("click", flagFittingDisruption);
363
+ this._map.once("dblclick", flagFittingDisruption);
364
+ this._map.once("dragstart", flagFittingDisruption);
365
+ this._map.once("mousedown", flagFittingDisruption);
366
+ this._map.once("touchstart", flagFittingDisruption);
367
+ this._map.once("wheel", flagFittingDisruption);
368
+ this._map.once("moveend", () => {
369
+ console.log("done moving, with disruption:", hasFittingBeenDisrupted);
370
+ this._map.off("click", flagFittingDisruption);
371
+ this._map.off("dblclick", flagFittingDisruption);
372
+ this._map.off("dragstart", flagFittingDisruption);
373
+ this._map.off("mousedown", flagFittingDisruption);
374
+ this._map.off("touchstart", flagFittingDisruption);
375
+ this._map.off("wheel", flagFittingDisruption);
376
+ if (hasFittingBeenDisrupted) {
377
+ return;
378
+ }
379
+ this.lastUpdatedCenter = this._map.getCenter();
380
+ this.lastUpdatedZoom = this._map.getZoom();
381
+ });
382
+ }
383
+ _setupUI(supported) {
384
+ this.lastUpdatedCenter = this._map.getCenter();
385
+ this.lastUpdatedZoom = this._map.getZoom();
386
+ this._container.addEventListener(
387
+ "contextmenu",
388
+ (e) => e.preventDefault()
389
+ );
390
+ this._geolocateButton = DOMcreate(
391
+ "button",
392
+ "maplibregl-ctrl-geolocate",
393
+ this._container
394
+ );
395
+ DOMcreate(
396
+ "span",
397
+ "maplibregl-ctrl-icon",
398
+ this._geolocateButton
399
+ ).setAttribute("aria-hidden", "true");
400
+ this._geolocateButton.type = "button";
401
+ if (supported === false) {
402
+ const title = this._map._getUIString(
403
+ "GeolocateControl.LocationNotAvailable"
404
+ );
405
+ this._geolocateButton.disabled = true;
406
+ this._geolocateButton.title = title;
407
+ this._geolocateButton.setAttribute("aria-label", title);
408
+ } else {
409
+ const title = this._map._getUIString("GeolocateControl.FindMyLocation");
410
+ this._geolocateButton.title = title;
411
+ this._geolocateButton.setAttribute("aria-label", title);
412
+ }
413
+ if (this.options.trackUserLocation) {
414
+ this._geolocateButton.setAttribute("aria-pressed", "false");
415
+ this._watchState = "OFF";
416
+ }
417
+ if (this.options.showUserLocation) {
418
+ this._dotElement = DOMcreate("div", "maplibregl-user-location-dot");
419
+ this._userLocationDotMarker = new Marker$1(this._dotElement);
420
+ this._circleElement = DOMcreate(
421
+ "div",
422
+ "maplibregl-user-location-accuracy-circle"
423
+ );
424
+ this._accuracyCircleMarker = new Marker$1({
425
+ element: this._circleElement,
426
+ pitchAlignment: "map"
427
+ });
428
+ if (this.options.trackUserLocation)
429
+ this._watchState = "OFF";
430
+ this._map.on("move", this._onZoom);
431
+ }
432
+ this._geolocateButton.addEventListener("click", this.trigger.bind(this));
433
+ this._setup = true;
434
+ if (this.options.trackUserLocation) {
435
+ this._map.on("moveend", (event) => {
436
+ const fromResize = event.originalEvent && event.originalEvent.type === "resize";
437
+ const movingDistance = this.lastUpdatedCenter.distanceTo(
438
+ this._map.getCenter()
439
+ );
440
+ if (!event.geolocateSource && this._watchState === "ACTIVE_LOCK" && !fromResize && movingDistance > 1) {
441
+ this._watchState = "BACKGROUND";
442
+ this._geolocateButton.classList.add(
443
+ "maplibregl-ctrl-geolocate-background"
444
+ );
445
+ this._geolocateButton.classList.remove(
446
+ "maplibregl-ctrl-geolocate-active"
447
+ );
448
+ this.fire(new Event("trackuserlocationend"));
449
+ }
450
+ });
451
+ }
452
+ }
453
+ _updateCircleRadius() {
454
+ if (this._watchState !== "BACKGROUND" && this._watchState !== "ACTIVE_LOCK") {
455
+ return;
456
+ }
457
+ const lastKnownLocation = [
458
+ this._lastKnownPosition.coords.longitude,
459
+ this._lastKnownPosition.coords.latitude
460
+ ];
461
+ const projectedLocation = this._map.project(lastKnownLocation);
462
+ const a = this._map.unproject([projectedLocation.x, projectedLocation.y]);
463
+ const b = this._map.unproject([
464
+ projectedLocation.x + 20,
465
+ projectedLocation.y
466
+ ]);
467
+ const metersPerPixel = a.distanceTo(b) / 20;
468
+ const circleDiameter = Math.ceil(2 * this._accuracy / metersPerPixel);
469
+ this._circleElement.style.width = `${circleDiameter}px`;
470
+ this._circleElement.style.height = `${circleDiameter}px`;
471
+ }
472
+ _onZoom() {
473
+ if (this.options.showUserLocation && this.options.showAccuracyCircle) {
474
+ this._updateCircleRadius();
475
+ }
476
+ }
477
+ }
478
+
479
+ var __defProp = Object.defineProperty;
480
+ var __defProps = Object.defineProperties;
481
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
482
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
483
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
484
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
485
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
486
+ var __spreadValues = (a, b) => {
487
+ for (var prop in b || (b = {}))
488
+ if (__hasOwnProp.call(b, prop))
489
+ __defNormalProp(a, prop, b[prop]);
490
+ if (__getOwnPropSymbols)
491
+ for (var prop of __getOwnPropSymbols(b)) {
492
+ if (__propIsEnum.call(b, prop))
493
+ __defNormalProp(a, prop, b[prop]);
494
+ }
495
+ return a;
496
+ };
497
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
498
+ var __async = (__this, __arguments, generator) => {
499
+ return new Promise((resolve, reject) => {
500
+ var fulfilled = (value) => {
501
+ try {
502
+ step(generator.next(value));
503
+ } catch (e) {
504
+ reject(e);
505
+ }
506
+ };
507
+ var rejected = (value) => {
508
+ try {
509
+ step(generator.throw(value));
510
+ } catch (e) {
511
+ reject(e);
512
+ }
513
+ };
514
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
515
+ step((generator = generator.apply(__this, __arguments)).next());
516
+ });
517
+ };
518
+ const MAPTILER_SESSION_ID = v4();
519
+ const GeolocationType = {
520
+ POINT: "POINT",
521
+ COUNTRY: "COUNTRY"
522
+ };
523
+ class Map extends maplibregl__default.Map {
524
+ constructor(options) {
525
+ var _a;
526
+ const style = styleToStyle(options.style);
527
+ console.log(style);
528
+ const hashPreConstructor = location.hash;
529
+ if (!config.apiKey) {
530
+ console.warn(
531
+ "MapTiler Cloud API key is not set. Visit https://maptiler.com and try Cloud for free!"
532
+ );
533
+ }
534
+ super(__spreadProps(__spreadValues({}, options), {
535
+ style,
536
+ maplibreLogo: false,
537
+ transformRequest: (url) => {
538
+ const reqUrl = new URL(url);
539
+ if (reqUrl.host === defaults.maptilerApiHost) {
540
+ if (!reqUrl.searchParams.has("key")) {
541
+ reqUrl.searchParams.append("key", config.apiKey);
542
+ }
543
+ if (config.session) {
544
+ reqUrl.searchParams.append("mtsid", MAPTILER_SESSION_ID);
545
+ }
546
+ }
547
+ return {
548
+ url: reqUrl.href,
549
+ headers: {}
550
+ };
551
+ }
552
+ }));
553
+ this.languageShouldUpdate = false;
554
+ this.isStyleInitialized = false;
555
+ this.isTerrainEnabled = false;
556
+ this.terrainExaggeration = 1;
557
+ this.once("styledata", () => __async(this, null, function* () {
558
+ if (options.geolocate === false) {
559
+ return;
560
+ }
561
+ if (options.center) {
562
+ return;
563
+ }
564
+ if (options.hash && !!hashPreConstructor) {
565
+ return;
566
+ }
567
+ try {
568
+ if (options.geolocate === GeolocationType.COUNTRY) {
569
+ yield this.fitToIpBounds();
570
+ return;
571
+ }
572
+ } catch (e) {
573
+ console.warn(e.message);
574
+ }
575
+ let ipLocatedCameraHash = null;
576
+ try {
577
+ yield this.centerOnIpPoint(options.zoom);
578
+ ipLocatedCameraHash = this.getCameraHash();
579
+ } catch (e) {
580
+ console.warn(e.message);
581
+ }
582
+ const locationResult = yield navigator.permissions.query({
583
+ name: "geolocation"
584
+ });
585
+ if (locationResult.state === "granted") {
586
+ navigator.geolocation.getCurrentPosition(
587
+ (data) => {
588
+ if (ipLocatedCameraHash !== this.getCameraHash()) {
589
+ return;
590
+ }
591
+ this.easeTo({
592
+ center: [data.coords.longitude, data.coords.latitude],
593
+ zoom: options.zoom || 12,
594
+ duration: 2e3
595
+ });
596
+ },
597
+ null,
598
+ {
599
+ maximumAge: 24 * 3600 * 1e3,
600
+ timeout: 5e3,
601
+ enableHighAccuracy: false
602
+ }
603
+ );
604
+ }
605
+ }));
606
+ this.on("styledataloading", () => {
607
+ this.languageShouldUpdate = !!config.primaryLanguage || !!config.secondaryLanguage;
608
+ });
609
+ this.on("styledata", () => {
610
+ if (config.primaryLanguage && (this.languageShouldUpdate || !this.isStyleInitialized)) {
611
+ this.setPrimaryLanguage(config.primaryLanguage);
612
+ }
613
+ if (config.secondaryLanguage && (this.languageShouldUpdate || !this.isStyleInitialized)) {
614
+ this.setSecondaryLanguage(config.secondaryLanguage);
615
+ }
616
+ this.languageShouldUpdate = false;
617
+ this.isStyleInitialized = true;
618
+ });
619
+ this.on("styledata", () => {
620
+ if (this.getTerrain() === null && this.isTerrainEnabled) {
621
+ this.enableTerrain(this.terrainExaggeration);
622
+ }
623
+ });
624
+ this.once("load", () => __async(this, null, function* () {
625
+ enableRTL();
626
+ }));
627
+ this.once("load", () => __async(this, null, function* () {
628
+ let tileJsonContent = { logo: null };
629
+ try {
630
+ const possibleSources = Object.keys(this.style.sourceCaches).map((sourceName) => this.getSource(sourceName)).filter(
631
+ (s) => typeof s.url === "string" && s.url.includes("tiles.json")
632
+ );
633
+ const styleUrl = new URL(
634
+ possibleSources[0].url
635
+ );
636
+ if (!styleUrl.searchParams.has("key")) {
637
+ styleUrl.searchParams.append("key", config.apiKey);
638
+ }
639
+ const tileJsonRes = yield fetch(styleUrl.href);
640
+ tileJsonContent = yield tileJsonRes.json();
641
+ } catch (e) {
642
+ }
643
+ if ("logo" in tileJsonContent && tileJsonContent.logo) {
644
+ const logoURL = tileJsonContent.logo;
645
+ this.addControl(
646
+ new CustomLogoControl({ logoURL }),
647
+ options.logoPosition
648
+ );
649
+ if (options.attributionControl === false) {
650
+ this.addControl(new maplibregl__default.AttributionControl(options));
651
+ }
652
+ } else if (options.maptilerLogo) {
653
+ this.addControl(new CustomLogoControl(), options.logoPosition);
654
+ }
655
+ if (options.scaleControl) {
656
+ const position = options.scaleControl === true || options.scaleControl === void 0 ? "bottom-right" : options.scaleControl;
657
+ const scaleControl = new maplibregl__default.ScaleControl({ unit: config.unit });
658
+ this.addControl(scaleControl, position);
659
+ config.on("unit", (unit) => {
660
+ scaleControl.setUnit(unit);
661
+ });
662
+ }
663
+ if (options.navigationControl !== false) {
664
+ const position = options.navigationControl === true || options.navigationControl === void 0 ? "top-right" : options.navigationControl;
665
+ this.addControl(new MaptilerNavigationControl(), position);
666
+ }
667
+ if (options.geolocateControl !== false) {
668
+ const position = options.geolocateControl === true || options.geolocateControl === void 0 ? "top-right" : options.geolocateControl;
669
+ this.addControl(
670
+ new CustomGeolocateControl({
671
+ positionOptions: {
672
+ enableHighAccuracy: true,
673
+ maximumAge: 0,
674
+ timeout: 6e3
675
+ },
676
+ fitBoundsOptions: {
677
+ maxZoom: 15
678
+ },
679
+ trackUserLocation: true,
680
+ showAccuracyCircle: true,
681
+ showUserLocation: true
682
+ }),
683
+ position
684
+ );
685
+ }
686
+ if (options.terrainControl) {
687
+ const position = options.terrainControl === true || options.terrainControl === void 0 ? "top-right" : options.terrainControl;
688
+ this.addControl(new TerrainControl$1(), position);
689
+ }
690
+ if (options.fullscreenControl) {
691
+ const position = options.fullscreenControl === true || options.fullscreenControl === void 0 ? "top-right" : options.fullscreenControl;
692
+ this.addControl(new maplibregl__default.FullscreenControl({}), position);
693
+ }
694
+ }));
695
+ if (options.terrain) {
696
+ this.enableTerrain(
697
+ (_a = options.terrainExaggeration) != null ? _a : this.terrainExaggeration
698
+ );
699
+ }
700
+ }
701
+ setStyle(style, options) {
702
+ return super.setStyle(styleToStyle(style), options);
703
+ }
704
+ setLanguage(language = defaults.primaryLanguage) {
705
+ if (language === Language.AUTO) {
706
+ return this.setLanguage(getBrowserLanguage());
707
+ }
708
+ this.setPrimaryLanguage(language);
709
+ }
710
+ setPrimaryLanguage(language = defaults.primaryLanguage) {
711
+ if (!isLanguageSupported(language)) {
712
+ return;
713
+ }
714
+ this.onStyleReady(() => {
715
+ if (language === Language.AUTO) {
716
+ return this.setPrimaryLanguage(getBrowserLanguage());
717
+ }
718
+ config.primaryLanguage = language;
719
+ const layers = this.getStyle().layers;
720
+ const strLanguageRegex = /^\s*{\s*name\s*(:\s*(\S*))?\s*}$/;
721
+ const strLanguageInArrayRegex = /^\s*name\s*(:\s*(\S*))?\s*$/;
722
+ const strBilingualRegex = /^\s*{\s*name\s*(:\s*(\S*))?\s*}(\s*){\s*name\s*(:\s*(\S*))?\s*}$/;
723
+ const strMoreInfoRegex = /^(.*)({\s*name\s*(:\s*(\S*))?\s*})(.*)$/;
724
+ const langStr = language ? `name:${language}` : "name";
725
+ const replacer = [
726
+ "case",
727
+ ["has", langStr],
728
+ ["get", langStr],
729
+ ["get", "name:latin"]
730
+ ];
731
+ for (let i = 0; i < layers.length; i += 1) {
732
+ const layer = layers[i];
733
+ const layout = layer.layout;
734
+ if (!layout) {
735
+ continue;
736
+ }
737
+ if (!layout["text-field"]) {
738
+ continue;
739
+ }
740
+ const textFieldLayoutProp = this.getLayoutProperty(
741
+ layer.id,
742
+ "text-field"
743
+ );
744
+ let regexMatch;
745
+ if (Array.isArray(textFieldLayoutProp) && textFieldLayoutProp.length >= 2 && textFieldLayoutProp[0].trim().toLowerCase() === "concat") {
746
+ const newProp = textFieldLayoutProp.slice();
747
+ for (let j = 0; j < textFieldLayoutProp.length; j += 1) {
748
+ const elem = textFieldLayoutProp[j];
749
+ if ((typeof elem === "string" || elem instanceof String) && strLanguageRegex.exec(elem.toString())) {
750
+ newProp[j] = replacer;
751
+ break;
752
+ } else if (Array.isArray(elem) && elem.length >= 2 && elem[0].trim().toLowerCase() === "get" && strLanguageInArrayRegex.exec(elem[1].toString())) {
753
+ newProp[j] = replacer;
754
+ break;
755
+ } else if (Array.isArray(elem) && elem.length === 4 && elem[0].trim().toLowerCase() === "case") {
756
+ newProp[j] = replacer;
757
+ break;
758
+ }
759
+ }
760
+ this.setLayoutProperty(layer.id, "text-field", newProp);
761
+ } else if (Array.isArray(textFieldLayoutProp) && textFieldLayoutProp.length >= 2 && textFieldLayoutProp[0].trim().toLowerCase() === "get" && strLanguageInArrayRegex.exec(textFieldLayoutProp[1].toString())) {
762
+ const newProp = replacer;
763
+ this.setLayoutProperty(layer.id, "text-field", newProp);
764
+ } else if ((typeof textFieldLayoutProp === "string" || textFieldLayoutProp instanceof String) && strLanguageRegex.exec(textFieldLayoutProp.toString())) {
765
+ const newProp = replacer;
766
+ this.setLayoutProperty(layer.id, "text-field", newProp);
767
+ } else if (Array.isArray(textFieldLayoutProp) && textFieldLayoutProp.length === 4 && textFieldLayoutProp[0].trim().toLowerCase() === "case") {
768
+ const newProp = replacer;
769
+ this.setLayoutProperty(layer.id, "text-field", newProp);
770
+ } else if ((typeof textFieldLayoutProp === "string" || textFieldLayoutProp instanceof String) && (regexMatch = strBilingualRegex.exec(
771
+ textFieldLayoutProp.toString()
772
+ )) !== null) {
773
+ const newProp = `{${langStr}}${regexMatch[3]}{name${regexMatch[4] || ""}}`;
774
+ this.setLayoutProperty(layer.id, "text-field", newProp);
775
+ } else if ((typeof textFieldLayoutProp === "string" || textFieldLayoutProp instanceof String) && (regexMatch = strMoreInfoRegex.exec(
776
+ textFieldLayoutProp.toString()
777
+ )) !== null) {
778
+ const newProp = `${regexMatch[1]}{${langStr}}${regexMatch[5]}`;
779
+ this.setLayoutProperty(layer.id, "text-field", newProp);
780
+ }
781
+ }
782
+ });
783
+ }
784
+ setSecondaryLanguage(language = defaults.secondaryLanguage) {
785
+ if (!isLanguageSupported(language)) {
786
+ return;
787
+ }
788
+ this.onStyleReady(() => {
789
+ if (language === Language.AUTO) {
790
+ return this.setSecondaryLanguage(getBrowserLanguage());
791
+ }
792
+ config.secondaryLanguage = language;
793
+ const layers = this.getStyle().layers;
794
+ const strLanguageRegex = /^\s*{\s*name\s*(:\s*(\S*))?\s*}$/;
795
+ const strLanguageInArrayRegex = /^\s*name\s*(:\s*(\S*))?\s*$/;
796
+ const strBilingualRegex = /^\s*{\s*name\s*(:\s*(\S*))?\s*}(\s*){\s*name\s*(:\s*(\S*))?\s*}$/;
797
+ let regexMatch;
798
+ for (let i = 0; i < layers.length; i += 1) {
799
+ const layer = layers[i];
800
+ const layout = layer.layout;
801
+ if (!layout) {
802
+ continue;
803
+ }
804
+ if (!layout["text-field"]) {
805
+ continue;
806
+ }
807
+ const textFieldLayoutProp = this.getLayoutProperty(
808
+ layer.id,
809
+ "text-field"
810
+ );
811
+ let newProp;
812
+ if (Array.isArray(textFieldLayoutProp) && textFieldLayoutProp.length >= 2 && textFieldLayoutProp[0].trim().toLowerCase() === "concat") {
813
+ newProp = textFieldLayoutProp.slice();
814
+ let languagesAlreadyFound = 0;
815
+ for (let j = 0; j < textFieldLayoutProp.length; j += 1) {
816
+ const elem = textFieldLayoutProp[j];
817
+ if ((typeof elem === "string" || elem instanceof String) && strLanguageRegex.exec(elem.toString())) {
818
+ if (languagesAlreadyFound === 1) {
819
+ newProp[j] = `{name:${language}}`;
820
+ break;
821
+ }
822
+ languagesAlreadyFound += 1;
823
+ } else if (Array.isArray(elem) && elem.length >= 2 && elem[0].trim().toLowerCase() === "get" && strLanguageInArrayRegex.exec(elem[1].toString())) {
824
+ if (languagesAlreadyFound === 1) {
825
+ newProp[j][1] = `name:${language}`;
826
+ break;
827
+ }
828
+ languagesAlreadyFound += 1;
829
+ } else if (Array.isArray(elem) && elem.length === 4 && elem[0].trim().toLowerCase() === "case") {
830
+ if (languagesAlreadyFound === 1) {
831
+ newProp[j] = ["get", `name:${language}`];
832
+ break;
833
+ }
834
+ languagesAlreadyFound += 1;
835
+ }
836
+ }
837
+ this.setLayoutProperty(layer.id, "text-field", newProp);
838
+ } else if ((typeof textFieldLayoutProp === "string" || textFieldLayoutProp instanceof String) && (regexMatch = strBilingualRegex.exec(
839
+ textFieldLayoutProp.toString()
840
+ )) !== null) {
841
+ const langStr = language ? `name:${language}` : "name";
842
+ newProp = `{name${regexMatch[1] || ""}}${regexMatch[3]}{${langStr}}`;
843
+ this.setLayoutProperty(layer.id, "text-field", newProp);
844
+ }
845
+ }
846
+ });
847
+ }
848
+ getTerrainExaggeration() {
849
+ return this.terrainExaggeration;
850
+ }
851
+ hasTerrain() {
852
+ return this.isTerrainEnabled;
853
+ }
854
+ enableTerrain(exaggeration = this.terrainExaggeration) {
855
+ if (exaggeration < 0) {
856
+ console.warn("Terrain exaggeration cannot be negative.");
857
+ return;
858
+ }
859
+ const terrainInfo = this.getTerrain();
860
+ const addTerrain = () => {
861
+ this.isTerrainEnabled = true;
862
+ this.terrainExaggeration = exaggeration;
863
+ this.addSource(defaults.terrainSourceId, {
864
+ type: "raster-dem",
865
+ url: defaults.terrainSourceURL
866
+ });
867
+ this.setTerrain({
868
+ source: defaults.terrainSourceId,
869
+ exaggeration
870
+ });
871
+ };
872
+ if (terrainInfo) {
873
+ this.setTerrain(__spreadProps(__spreadValues({}, terrainInfo), { exaggeration }));
874
+ return;
875
+ }
876
+ if (this.loaded() || this.isTerrainEnabled) {
877
+ addTerrain();
878
+ } else {
879
+ this.once("load", () => {
880
+ if (this.getTerrain() && this.getSource(defaults.terrainSourceId)) {
881
+ return;
882
+ }
883
+ addTerrain();
884
+ });
885
+ }
886
+ }
887
+ disableTerrain() {
888
+ this.isTerrainEnabled = false;
889
+ this.setTerrain(null);
890
+ if (this.getSource(defaults.terrainSourceId)) {
891
+ this.removeSource(defaults.terrainSourceId);
892
+ }
893
+ }
894
+ setTerrainExaggeration(exaggeration) {
895
+ this.enableTerrain(exaggeration);
896
+ }
897
+ onStyleReady(cb) {
898
+ if (this.isStyleLoaded()) {
899
+ cb();
900
+ } else {
901
+ this.once("styledata", () => {
902
+ cb();
903
+ });
904
+ }
905
+ }
906
+ fitToIpBounds() {
907
+ return __async(this, null, function* () {
908
+ const ipGeolocateResult = yield geolocation.info();
909
+ this.fitBounds(
910
+ ipGeolocateResult.country_bounds,
911
+ {
912
+ duration: 0,
913
+ padding: 100
914
+ }
915
+ );
916
+ });
917
+ }
918
+ centerOnIpPoint(zoom) {
919
+ return __async(this, null, function* () {
920
+ const ipGeolocateResult = yield geolocation.info();
921
+ this.jumpTo({
922
+ center: [ipGeolocateResult.longitude, ipGeolocateResult.latitude],
923
+ zoom: zoom || 11
924
+ });
925
+ });
926
+ }
927
+ getCameraHash() {
928
+ const hashBin = new Float32Array(5);
929
+ const center = this.getCenter();
930
+ hashBin[0] = center.lng;
931
+ hashBin[1] = center.lat;
932
+ hashBin[2] = this.getZoom();
933
+ hashBin[3] = this.getPitch();
934
+ hashBin[4] = this.getBearing();
935
+ return Base64.fromUint8Array(new Uint8Array(hashBin.buffer));
936
+ }
937
+ }
938
+
939
+ class Point {
940
+ constructor(x, y) {
941
+ this.x = x;
942
+ this.y = y;
943
+ }
944
+ _matMult(m) {
945
+ const x = m[0] * this.x + m[1] * this.y;
946
+ const y = m[2] * this.x + m[3] * this.y;
947
+ this.x = x;
948
+ this.y = y;
949
+ return this;
950
+ }
951
+ _add(p) {
952
+ this.x += p.x;
953
+ this.y += p.y;
954
+ return this;
955
+ }
956
+ _sub(p) {
957
+ this.x -= p.x;
958
+ this.y -= p.y;
959
+ return this;
960
+ }
961
+ _mult(k) {
962
+ this.x *= k;
963
+ this.y *= k;
964
+ return this;
965
+ }
966
+ _div(k) {
967
+ this.x /= k;
968
+ this.y /= k;
969
+ return this;
970
+ }
971
+ _multByPoint(p) {
972
+ this.x *= p.x;
973
+ this.y *= p.y;
974
+ return this;
975
+ }
976
+ _divByPoint(p) {
977
+ this.x /= p.x;
978
+ this.y /= p.y;
979
+ return this;
980
+ }
981
+ _unit() {
982
+ this._div(this.mag());
983
+ return this;
984
+ }
985
+ _perp() {
986
+ const y = this.y;
987
+ this.y = this.x;
988
+ this.x = -y;
989
+ return this;
990
+ }
991
+ _rotate(angle) {
992
+ const cos = Math.cos(angle);
993
+ const sin = Math.sin(angle);
994
+ const x = cos * this.x - sin * this.y;
995
+ const y = sin * this.x + cos * this.y;
996
+ this.x = x;
997
+ this.y = y;
998
+ return this;
999
+ }
1000
+ _rotateAround(angle, p) {
1001
+ const cos = Math.cos(angle);
1002
+ const sin = Math.sin(angle);
1003
+ const x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y);
1004
+ const y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);
1005
+ this.x = x;
1006
+ this.y = y;
1007
+ return this;
1008
+ }
1009
+ _round() {
1010
+ this.x = Math.round(this.x);
1011
+ this.y = Math.round(this.y);
1012
+ return this;
1013
+ }
1014
+ clone() {
1015
+ return new Point(this.x, this.y);
1016
+ }
1017
+ add(p) {
1018
+ return this.clone()._add(p);
1019
+ }
1020
+ sub(p) {
1021
+ return this.clone()._sub(p);
1022
+ }
1023
+ multByPoint(p) {
1024
+ return this.clone()._multByPoint(p);
1025
+ }
1026
+ divByPoint(p) {
1027
+ return this.clone()._divByPoint(p);
1028
+ }
1029
+ mult(k) {
1030
+ return this.clone()._mult(k);
1031
+ }
1032
+ div(k) {
1033
+ return this.clone()._div(k);
1034
+ }
1035
+ rotate(a) {
1036
+ return this.clone()._rotate(a);
1037
+ }
1038
+ rotateAround(a, p) {
1039
+ return this.clone()._rotateAround(a, p);
1040
+ }
1041
+ matMult(m) {
1042
+ return this.clone()._matMult(m);
1043
+ }
1044
+ unit() {
1045
+ return this.clone()._unit();
1046
+ }
1047
+ perp() {
1048
+ return this.clone()._perp();
1049
+ }
1050
+ round() {
1051
+ return this.clone()._round();
1052
+ }
1053
+ mag() {
1054
+ return Math.sqrt(this.x * this.x + this.y * this.y);
1055
+ }
1056
+ equals(other) {
1057
+ return this.x === other.x && this.y === other.y;
1058
+ }
1059
+ dist(p) {
1060
+ return Math.sqrt(this.distSqr(p));
1061
+ }
1062
+ distSqr(p) {
1063
+ const dx = p.x - this.x;
1064
+ const dy = p.y - this.y;
1065
+ return dx * dx + dy * dy;
1066
+ }
1067
+ angle() {
1068
+ return Math.atan2(this.y, this.x);
1069
+ }
1070
+ angleTo(b) {
1071
+ return Math.atan2(this.y - b.y, this.x - b.x);
1072
+ }
1073
+ angleWith(b) {
1074
+ return this.angleWithSep(b.x, b.y);
1075
+ }
1076
+ angleWithSep(x, y) {
1077
+ return Math.atan2(this.x * y - this.y * x, this.x * x + this.y * y);
1078
+ }
1079
+ static convert(a) {
1080
+ if (a instanceof Point) {
1081
+ return a;
1082
+ }
1083
+ if (Array.isArray(a)) {
1084
+ return new Point(a[0], a[1]);
1085
+ }
1086
+ return a;
1087
+ }
1088
+ }
1089
+
1090
+ const {
1091
+ supported,
1092
+ setRTLTextPlugin,
1093
+ getRTLTextPluginStatus,
1094
+ NavigationControl,
1095
+ GeolocateControl,
1096
+ AttributionControl,
1097
+ LogoControl,
1098
+ ScaleControl,
1099
+ FullscreenControl,
1100
+ TerrainControl,
1101
+ Popup,
1102
+ Marker,
1103
+ Style,
1104
+ LngLat,
1105
+ LngLatBounds,
1106
+ MercatorCoordinate,
1107
+ Evented,
1108
+ AJAXError,
1109
+ CanvasSource,
1110
+ GeoJSONSource,
1111
+ ImageSource,
1112
+ RasterDEMTileSource,
1113
+ RasterTileSource,
1114
+ VectorTileSource,
1115
+ VideoSource,
1116
+ prewarm,
1117
+ clearPrewarmedResources,
1118
+ version,
1119
+ workerCount,
1120
+ maxParallelImageRequests,
1121
+ clearStorage,
1122
+ workerUrl,
1123
+ addProtocol,
1124
+ removeProtocol
1125
+ } = maplibregl__default;
1126
+
1127
+ 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 };
1128
+ //# sourceMappingURL=maptiler-sdk.mjs.map