@maptiler/client 1.1.3 → 1.4.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 (75) hide show
  1. package/dist/maptiler-client.cjs +113 -36
  2. package/dist/maptiler-client.cjs.map +1 -1
  3. package/dist/maptiler-client.d.ts +79 -28
  4. package/dist/maptiler-client.min.mjs +1 -1
  5. package/dist/maptiler-client.mjs +113 -36
  6. package/dist/maptiler-client.mjs.map +1 -1
  7. package/dist/maptiler-client.umd.js +113 -36
  8. package/dist/maptiler-client.umd.js.map +1 -1
  9. package/dist/maptiler-client.umd.min.js +1 -1
  10. package/docs/assets/search.js +1 -1
  11. package/docs/classes/config.ClientConfig.html +9 -9
  12. package/docs/classes/services_ServiceError.ServiceError.html +7 -7
  13. package/docs/functions/language.getAutoLanguageGeocoding.html +5 -5
  14. package/docs/functions/services_simplify.default.html +5 -5
  15. package/docs/index.html +4 -4
  16. package/docs/modules/config.html +5 -5
  17. package/docs/modules/language.html +5 -5
  18. package/docs/modules/services_ServiceError.html +5 -5
  19. package/docs/modules/services_coordinates.html +5 -5
  20. package/docs/modules/services_data.html +5 -5
  21. package/docs/modules/services_geocoding.html +12 -6
  22. package/docs/modules/services_geolocation.html +5 -5
  23. package/docs/modules/services_simplify.html +5 -5
  24. package/docs/modules/services_staticMaps.html +5 -5
  25. package/docs/modules.html +4 -4
  26. package/docs/types/config.FetchFunction.html +5 -5
  27. package/docs/types/language.LanguageGeocodingString.html +5 -5
  28. package/docs/types/services_coordinates.CoordinateExport.html +5 -5
  29. package/docs/types/services_coordinates.CoordinateGrid.html +5 -5
  30. package/docs/types/services_coordinates.CoordinateId.html +5 -5
  31. package/docs/types/services_coordinates.CoordinateSearch.html +5 -5
  32. package/docs/types/services_coordinates.CoordinateSearchResult.html +5 -5
  33. package/docs/types/services_coordinates.CoordinateTransformResult.html +5 -5
  34. package/docs/types/services_coordinates.CoordinateTransformation.html +5 -5
  35. package/docs/types/services_coordinates.CoordinatesSearchOptions.html +6 -6
  36. package/docs/types/services_coordinates.CoordinatesTransformOptions.html +6 -6
  37. package/docs/types/services_coordinates.XYZ.html +5 -5
  38. package/docs/types/services_data.GetDataOptions.html +6 -6
  39. package/docs/types/services_geocoding.ByIdGeocodingOptions.html +63 -0
  40. package/docs/types/services_geocoding.CommonForwardAndReverseGeocodingOptions.html +63 -0
  41. package/docs/types/services_geocoding.Coordinates.html +9 -6
  42. package/docs/types/services_geocoding.FeatureHierarchy.html +9 -6
  43. package/docs/types/services_geocoding.GeocodingFeature.html +9 -6
  44. package/docs/types/services_geocoding.GeocodingOptions.html +10 -26
  45. package/docs/types/services_geocoding.GeocodingSearchResult.html +9 -6
  46. package/docs/types/services_geocoding.LanguageGeocodingOptions.html +70 -0
  47. package/docs/types/services_geocoding.ReverseGeocodingOptions.html +10 -18
  48. package/docs/types/services_geolocation.GeolocationInfoOptions.html +6 -6
  49. package/docs/types/services_geolocation.GeolocationResult.html +5 -5
  50. package/docs/types/services_staticMaps.AutomaticStaticMapOptions.html +5 -5
  51. package/docs/types/services_staticMaps.BoundedStaticMapOptions.html +5 -5
  52. package/docs/types/services_staticMaps.CenteredStaticMapOptions.html +5 -5
  53. package/docs/types/services_staticMaps.StaticMapBaseOptions.html +6 -6
  54. package/docs/types/services_staticMaps.StaticMapMarker.html +5 -5
  55. package/docs/variables/config.config.html +5 -5
  56. package/docs/variables/language.LanguageGeocoding.html +5 -5
  57. package/docs/variables/services_coordinates.coordinates.html +5 -5
  58. package/docs/variables/services_data.data.html +5 -5
  59. package/docs/variables/services_geocoding.geocoding.html +56 -12
  60. package/docs/variables/services_geolocation.geolocation.html +5 -5
  61. package/docs/variables/services_staticMaps.staticMaps.html +5 -5
  62. package/docsmd/README.md +82 -68
  63. package/docsmd/classes/ClientConfig.md +5 -5
  64. package/docsmd/classes/MapStyleVariant.md +13 -13
  65. package/docsmd/classes/ReferenceMapStyle.md +9 -9
  66. package/docsmd/classes/ServiceError.md +3 -3
  67. package/examples/test-browser-umd.html +6 -6
  68. package/package.json +3 -1
  69. package/src/index.ts +4 -0
  70. package/src/mapstyle.ts +46 -1
  71. package/src/services/coordinates.ts +2 -2
  72. package/src/services/data.ts +1 -1
  73. package/src/services/geocoding.ts +206 -65
  74. package/src/services/geolocation.ts +1 -1
  75. package/src/services/staticMaps.ts +1 -1
@@ -103,11 +103,27 @@ type Values<T> = T[keyof T];
103
103
  */
104
104
  type LanguageGeocodingString = Values<typeof LanguageGeocoding>;
105
105
 
106
- type GeocodingOptions = {
106
+ type LanguageGeocodingOptions = {
107
107
  /**
108
- * Custom mapTiler Cloud API key to use instead of the one in global `config`
108
+ * Prefer results in specific language. It’s possible to specify multiple values.
109
+ */
110
+ language?: LanguageGeocodingString | Array<LanguageGeocodingString>;
111
+ };
112
+ type CommonForwardAndReverseGeocodingOptions = LanguageGeocodingOptions & {
113
+ /**
114
+ * Custom MapTiler Cloud API key to use instead of the one in global `config`
109
115
  */
110
116
  apiKey?: string;
117
+ /**
118
+ * Maximum number of results to show. Must be between 1 and 10. Default is 5 for forward and 1 for reverse geocoding.
119
+ */
120
+ limit?: number;
121
+ /**
122
+ * Filter of feature types to return. If not specified, all available feature types are returned.
123
+ */
124
+ types?: ("country" | "region" | "subregion" | "county" | "joint_municipality" | "joint_submunicipality" | "municipality" | "municipal_district" | "locality" | "neighbourhood" | "place" | "postal_code" | "address")[];
125
+ };
126
+ type GeocodingOptions = CommonForwardAndReverseGeocodingOptions & {
111
127
  /**
112
128
  * Only search for results in the specified area.
113
129
  */
@@ -117,10 +133,21 @@ type GeocodingOptions = {
117
133
  */
118
134
  proximity?: Position;
119
135
  /**
120
- * Prefer results in specific language. It’s possible to specify multiple values.
136
+ * Limit search to specific country/countries specified as list of Alpha-2 ISO 3166-1 codes.
121
137
  */
122
- language?: LanguageGeocodingString | Array<LanguageGeocodingString>;
138
+ country?: string[];
139
+ /**
140
+ * Set to `false` to disable fuzzy (typo-tolerant) search. Default is `true`.
141
+ */
142
+ fuzzyMatch?: boolean;
143
+ /**
144
+ * Set to `true` to use autocomplete, `false` to disable it.
145
+ * Default (`undefined`) is to combine autocomplete with non-autocomplete results.
146
+ */
147
+ autocomplete?: boolean;
123
148
  };
149
+ type ReverseGeocodingOptions = CommonForwardAndReverseGeocodingOptions;
150
+ type ByIdGeocodingOptions = LanguageGeocodingOptions;
124
151
  type Coordinates = Position;
125
152
  type FeatureHierarchy = {
126
153
  /**
@@ -183,25 +210,34 @@ type GeocodingSearchResult = {
183
210
  * @returns
184
211
  */
185
212
  declare function forward(query: string, options?: GeocodingOptions): Promise<GeocodingSearchResult>;
186
- type ReverseGeocodingOptions = {
187
- /**
188
- * Custom mapTiler Cloud API key to use instead of the one in global `config`
189
- */
190
- apiKey?: string;
191
- /**
192
- * Prefer results in specific language. It’s possible to specify multiple values.
193
- */
194
- language?: LanguageGeocodingString | Array<LanguageGeocodingString>;
195
- };
196
213
  /**
197
214
  * Perform a reverse geocoding query to MapTiler API.
198
- * Providing a longitude and latitude, this function returns a set of human readable information abou this place (country, city, street, etc.)
215
+ * Providing a longitude and latitude, this function returns a set of human readable information about this place (country, city, street, etc.)
199
216
  * Learn more on the MapTiler API reference page: https://docs.maptiler.com/cloud/api/geocoding/#search-by-coordinates-reverse
200
217
  * @param position
201
218
  * @param options
202
219
  * @returns
203
220
  */
204
221
  declare function reverse(position: Position, options?: ReverseGeocodingOptions): Promise<GeocodingSearchResult>;
222
+ /**
223
+ * Perform a geocoding query to MapTiler API to obtain fature by its ID.
224
+ * Providing a feature ID, this function returns a feature which includes its full geometry.
225
+ * Note that the feature ID is not stable and it changes when the database is re-indexed.
226
+ * Learn more on the MapTiler API reference page: https://docs.maptiler.com/cloud/api/geocoding/#search-by-feature-id
227
+ * @param id
228
+ * @param options
229
+ * @returns
230
+ */
231
+ declare function byId(id: string, options?: ByIdGeocodingOptions): Promise<GeocodingSearchResult>;
232
+ /**
233
+ * Perform a batch geocoding query to MapTiler API.
234
+ * Provide multiple queries in the array. Each query can be forward, reverse or by feature ID.
235
+ * Learn more on the MapTiler API reference page: https://docs.maptiler.com/cloud/api/geocoding/#batch-geocoding
236
+ * @param queries
237
+ * @param options
238
+ * @returns
239
+ */
240
+ declare function batch(queries: string[], options?: GeocodingOptions): Promise<GeocodingSearchResult[]>;
205
241
  /**
206
242
  * The **geocoding** namespace contains asynchronous functions to call the [MapTiler Geocoding API](https://docs.maptiler.com/cloud/api/geocoding/).
207
243
  * The **Geocoding API** provides ways to get geographic coordinates from a human-readable search query of a place (forward geocoding)
@@ -210,6 +246,8 @@ declare function reverse(position: Position, options?: ReverseGeocodingOptions):
210
246
  declare const geocoding: {
211
247
  forward: typeof forward;
212
248
  reverse: typeof reverse;
249
+ byId: typeof byId;
250
+ batch: typeof batch;
213
251
  language: {
214
252
  AUTO: string;
215
253
  ALBANIAN: string;
@@ -229,18 +267,13 @@ declare const geocoding: {
229
267
  ENGLISH: string;
230
268
  ESPERANTO: string;
231
269
  ESTONIAN: string;
232
- /**
233
- * Custom mapTiler Cloud API key to use instead of the one in global `config`
234
- */
235
270
  FINNISH: string;
236
271
  FRENCH: string;
237
272
  FRISIAN: string;
238
273
  GEORGIAN: string;
239
274
  GERMAN: string;
240
275
  GREEK: string;
241
- HEBREW: string; /**
242
- * Only search for results in the specified area.
243
- */
276
+ HEBREW: string;
244
277
  HUNGARIAN: string;
245
278
  ICELANDIC: string;
246
279
  IRISH: string;
@@ -255,7 +288,9 @@ declare const geocoding: {
255
288
  LUXEMBOURGISH: string;
256
289
  MACEDONIAN: string;
257
290
  MALTESE: string;
258
- NORWEGIAN: string;
291
+ NORWEGIAN: string; /**
292
+ * Maximum number of results to show. Must be between 1 and 10. Default is 5 for forward and 1 for reverse geocoding.
293
+ */
259
294
  POLISH: string;
260
295
  PORTUGUESE: string;
261
296
  ROMANIAN: string;
@@ -279,7 +314,7 @@ declare const geocoding: {
279
314
  */
280
315
  type GeolocationInfoOptions = {
281
316
  /**
282
- * Custom mapTiler Cloud API key to use instead of the one in global `config`
317
+ * Custom MapTiler Cloud API key to use instead of the one in global `config`
283
318
  */
284
319
  apiKey?: string;
285
320
  };
@@ -370,7 +405,7 @@ declare const geolocation: {
370
405
 
371
406
  type CoordinatesSearchOptions = {
372
407
  /**
373
- * Custom mapTiler Cloud API key to use instead of the one in global `config`
408
+ * Custom MapTiler Cloud API key to use instead of the one in global `config`
374
409
  */
375
410
  apiKey?: string;
376
411
  /**
@@ -467,7 +502,7 @@ type CoordinateTransformResult = {
467
502
  */
468
503
  type CoordinatesTransformOptions = {
469
504
  /**
470
- * Custom mapTiler Cloud API key to use instead of the one in global `config`
505
+ * Custom MapTiler Cloud API key to use instead of the one in global `config`
471
506
  */
472
507
  apiKey?: string;
473
508
  /**
@@ -505,7 +540,7 @@ declare const coordinates: {
505
540
  */
506
541
  type GetDataOptions = {
507
542
  /**
508
- * Custom mapTiler Cloud API key to use instead of the one in global `config`
543
+ * Custom MapTiler Cloud API key to use instead of the one in global `config`
509
544
  */
510
545
  apiKey?: string;
511
546
  };
@@ -741,6 +776,10 @@ type MapStyleType = {
741
776
  * Suitable for navigation, with high level of detail on urban areas, plenty of POIs and 3D buildings, in light mode.
742
777
  */
743
778
  LIGHT: MapStyleVariant;
779
+ /**
780
+ * Suitable for navigation, with high level of detail on urban areas, plenty of POIs and 3D buildings, in blue night mode.
781
+ */
782
+ NIGHT: MapStyleVariant;
744
783
  /**
745
784
  * Suitable for navigation, with high level of detail on urban areas, plenty of POIs and 3D buildings, with a pastel color palette.
746
785
  */
@@ -754,6 +793,10 @@ type MapStyleType = {
754
793
  * Suitable for outdoor activities. With elevation isolines and hillshading.
755
794
  */
756
795
  DEFAULT: MapStyleVariant;
796
+ /**
797
+ * Suitable for outdoor activities. With elevation isolines and hillshading, in dark mode.
798
+ */
799
+ DARK: MapStyleVariant;
757
800
  };
758
801
  /**
759
802
  * Suitabe for winter outdoor activities. With ski tracks, elevation isolines and hillshading.
@@ -763,6 +806,10 @@ type MapStyleType = {
763
806
  * Suitabe for winter outdoor activities. With ski tracks, elevation isolines and hillshading.
764
807
  */
765
808
  DEFAULT: MapStyleVariant;
809
+ /**
810
+ * Suitabe for winter outdoor activities. With ski tracks, elevation isolines and hillshading, in dark mode.
811
+ */
812
+ DARK: MapStyleVariant;
766
813
  };
767
814
  /**
768
815
  * High resolution imagery only, without any label.
@@ -834,6 +881,10 @@ type MapStyleType = {
834
881
  * A nice high-contrast, yet less saturated alternative to the `outdoor` style, with hillshading, 3D buildings and fairly high street details
835
882
  */
836
883
  DEFAULT: MapStyleVariant;
884
+ /**
885
+ * A nice high-contrast, yet less saturated alternative to the `outdoor` style, with hillshading, 3D buildings and fairly high street details, in dark mode
886
+ */
887
+ DARK: MapStyleVariant;
837
888
  /**
838
889
  * A nice high-contrast, and high saturation alternative to the `outdoor` style, with hillshading, 3D buildings and fairly high street details
839
890
  */
@@ -932,7 +983,7 @@ declare const MapStyle: MapStyleType;
932
983
  */
933
984
  type StaticMapBaseOptions = {
934
985
  /**
935
- * Custom mapTiler Cloud API key to use instead of the one in global `config`
986
+ * Custom MapTiler Cloud API key to use instead of the one in global `config`
936
987
  */
937
988
  apiKey?: string;
938
989
  /**
@@ -1102,4 +1153,4 @@ declare class ServiceError extends Error {
1102
1153
  constructor(res: Response, customMessage?: string);
1103
1154
  }
1104
1155
 
1105
- export { AutomaticStaticMapOptions, BoundedStaticMapOptions, CenteredStaticMapOptions, ClientConfig, CoordinateExport, CoordinateGrid, CoordinateId, CoordinateSearch, CoordinateSearchResult, CoordinateTransformResult, CoordinateTransformation, Coordinates, CoordinatesSearchOptions, CoordinatesTransformOptions, FeatureHierarchy, FetchFunction, GeocodingFeature, GeocodingOptions, GeocodingSearchResult, GeolocationInfoOptions, GeolocationResult, GetDataOptions, LanguageGeocoding, LanguageGeocodingString, MapStyle, MapStylePreset, MapStyleType, MapStyleVariant, ReferenceMapStyle, ReverseGeocodingOptions, ServiceError, StaticMapBaseOptions, StaticMapMarker, XYZ, config, coordinates, data, expandMapStyle, geocoding, geolocation, mapStylePresetList, staticMaps };
1156
+ export { AutomaticStaticMapOptions, BoundedStaticMapOptions, CenteredStaticMapOptions, ClientConfig, CommonForwardAndReverseGeocodingOptions, CoordinateExport, CoordinateGrid, CoordinateId, CoordinateSearch, CoordinateSearchResult, CoordinateTransformResult, CoordinateTransformation, Coordinates, CoordinatesSearchOptions, CoordinatesTransformOptions, FeatureHierarchy, FetchFunction, GeocodingFeature, GeocodingOptions, GeocodingSearchResult, GeolocationInfoOptions, GeolocationResult, GetDataOptions, LanguageGeocoding, LanguageGeocodingOptions, LanguageGeocodingString, MapStyle, MapStylePreset, MapStyleType, MapStyleVariant, ReferenceMapStyle, ReverseGeocodingOptions, ServiceError, StaticMapBaseOptions, StaticMapMarker, XYZ, config, coordinates, data, expandMapStyle, geocoding, geolocation, mapStylePresetList, staticMaps };
@@ -1 +1 @@
1
- function V(){return typeof self<"u"?fetch.bind(self):typeof global<"u"&&global.fetch?global.fetch:null}class w{constructor(){this._apiKey="",this._fetch=V()}set apiKey(t){this._apiKey=t}get apiKey(){return this._apiKey}set fetch(t){this._fetch=t}get fetch(){return this._fetch}}const g=new w,A={AUTO:"auto",ALBANIAN:"sq",ARABIC:"ar",ARMENIAN:"hy",AZERBAIJANI:"az",BELORUSSIAN:"be",BOSNIAN:"bs",BRETON:"br",BULGARIAN:"bg",CATALAN:"ca",CHINESE:"zh",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",HUNGARIAN:"hu",ICELANDIC:"is",IRISH:"ga",ITALIAN:"it",JAPANESE:"ja",KANNADA:"kn",KAZAKH:"kk",KOREAN:"ko",ROMAN_LATIN:"la",LATVIAN:"lv",LITHUANIAN:"lt",LUXEMBOURGISH:"lb",MACEDONIAN:"mk",MALTESE:"mt",NORWEGIAN:"no",POLISH:"pl",PORTUGUESE:"pt",ROMANIAN:"ro",ROMANSH:"rm",RUSSIAN:"ru",SCOTTISH_GAELIC:"gd",SERBIAN_CYRILLIC:"sr",SLOVAK:"sk",SLOVENE:"sl",SPANISH:"es",SWEDISH:"sv",THAI:"th",TURKISH:"tr",UKRAINIAN:"uk",WELSH:"cy"},G=new Set(Object.values(A));function N(){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=>G.has(t));return r.length?r[0]:A.ENGLISH}var F=(r,t,e)=>new Promise((a,n)=>{var s=o=>{try{c(e.next(o))}catch(l){n(l)}},i=o=>{try{c(e.throw(o))}catch(l){n(l)}},c=o=>o.done?a(o.value):Promise.resolve(o.value).then(s,i);c((e=e.apply(r,t)).next())});function I(r){return F(this,arguments,function*(t,e={}){if(g.fetch===null)throw new Error("The fetch function was not found. If on NodeJS < 18 please specify the fetch function with config.fetch");if(new URL(t).searchParams.get("key").trim()==="")throw new Error("The MapTiler Cloud API key is missing. Set it in `config.apiKey` or get one for free at https://maptiler.com");return g.fetch(t,e)})}const y={maptilerApiURL:"https://api.maptiler.com/",mapStyle:"streets-v2"};Object.freeze(y);class v extends Error{constructor(t,e=""){super(`Call to enpoint ${t.url} failed with the status code ${t.status}. ${e}`),this.res=t}}var b=(r,t,e)=>new Promise((a,n)=>{var s=o=>{try{c(e.next(o))}catch(l){n(l)}},i=o=>{try{c(e.throw(o))}catch(l){n(l)}},c=o=>o.done?a(o.value):Promise.resolve(o.value).then(s,i);c((e=e.apply(r,t)).next())});const S={400:"Query too long / Invalid parameters",403:"Key is missing, invalid or restricted"};function B(r){return b(this,arguments,function*(t,e={}){var a;if(typeof t!="string"||t.trim().length===0)throw new Error("The query must be a non-empty string");const n=new URL(`geocoding/${encodeURIComponent(t)}.json`,y.maptilerApiURL);if(n.searchParams.set("key",(a=e.apiKey)!=null?a:g.apiKey),"bbox"in e&&n.searchParams.set("bbox",e.bbox.join(",")),"proximity"in e&&n.searchParams.set("proximity",e.proximity.join(",")),"language"in e){const c=Array.from(new Set((Array.isArray(e.language)?e.language:[e.language]).map(o=>o===A.AUTO?N():o))).join(",");n.searchParams.set("language",c)}const s=n.toString(),i=yield I(s);if(!i.ok)throw new v(i,i.status in S?S[i.status]:"");return yield i.json()})}function M(r){return b(this,arguments,function*(t,e={}){var a;if(!Array.isArray(t)||t.length<2)throw new Error("The position must be an array of form [lng, lat].");const n=new URL(`geocoding/${t[0]},${t[1]}.json`,y.maptilerApiURL);if(n.searchParams.set("key",(a=e.apiKey)!=null?a:g.apiKey),"language"in e){const c=Array.from(new Set((Array.isArray(e.language)?e.language:[e.language]).map(o=>o===A.AUTO?N():o))).join(",");n.searchParams.set("language",c)}const s=n.toString(),i=yield I(s);if(!i.ok)throw new v(i,i.status in S?S[i.status]:"");return yield i.json()})}const W={forward:B,reverse:M,language:A};var _=(r,t,e)=>new Promise((a,n)=>{var s=o=>{try{c(e.next(o))}catch(l){n(l)}},i=o=>{try{c(e.throw(o))}catch(l){n(l)}},c=o=>o.done?a(o.value):Promise.resolve(o.value).then(s,i);c((e=e.apply(r,t)).next())});const C={403:"Key is missing, invalid or restricted"};function z(){return _(this,arguments,function*(r={}){var t;const e=new URL("geolocation/ip.json",y.maptilerApiURL);e.searchParams.set("key",(t=r.apiKey)!=null?t:g.apiKey);const a=e.toString(),n=yield I(a);if(!n.ok)throw new v(n,n.status in C?C[n.status]:"");return yield n.json()})}const q={info:z};var K=(r,t,e)=>new Promise((a,n)=>{var s=o=>{try{c(e.next(o))}catch(l){n(l)}},i=o=>{try{c(e.throw(o))}catch(l){n(l)}},c=o=>o.done?a(o.value):Promise.resolve(o.value).then(s,i);c((e=e.apply(r,t)).next())});const L={403:"Key is missing, invalid or restricted"};function Y(r){return K(this,arguments,function*(t,e={}){var a;if(typeof t!="string"||t.trim().length===0)throw new Error("The query must be a non-empty string");const n=new URL(`coordinates/search/${t}.json`,y.maptilerApiURL);n.searchParams.set("key",(a=e.apiKey)!=null?a:g.apiKey),"limit"in e&&n.searchParams.set("limit",e.limit.toString()),"transformations"in e&&n.searchParams.set("transformations",e.transformations.toString()),"exports"in e&&n.searchParams.set("exports",e.exports.toString());const s=n.toString(),i=yield I(s);if(!i.ok)throw new v(i,i.status in L?L[i.status]:"");return yield i.json()})}function Z(r){return K(this,arguments,function*(t,e={}){var a;const n=(Array.isArray(t[0])?t:[t]).map(o=>`${o[0]},${o[1]}`).join(";"),s=new URL(`coordinates/transform/${n}.json`,y.maptilerApiURL);s.searchParams.set("key",(a=e.apiKey)!=null?a:g.apiKey),"sourceCrs"in e&&s.searchParams.set("s_srs",e.sourceCrs.toString()),"targetCrs"in e&&s.searchParams.set("t_srs",e.targetCrs.toString()),"operations"in e&&s.searchParams.set("ops",(Array.isArray(e.operations)?e.operations:[e.operations]).join("|"));const i=s.toString(),c=yield I(i);if(!c.ok)throw new v(c,c.status in L?L[c.status]:"");return yield c.json()})}const J={search:Y,transform:Z};var Q=(r,t,e)=>new Promise((a,n)=>{var s=o=>{try{c(e.next(o))}catch(l){n(l)}},i=o=>{try{c(e.throw(o))}catch(l){n(l)}},c=o=>o.done?a(o.value):Promise.resolve(o.value).then(s,i);c((e=e.apply(r,t)).next())});const O={403:"Key is missing, invalid or restricted"};function X(r){return Q(this,arguments,function*(t,e={}){var a;if(typeof t!="string"||t.trim().length===0)throw new Error("The data ID must be a non-empty string");const n=new URL(`data/${encodeURIComponent(t)}/features.json`,y.maptilerApiURL);n.searchParams.set("key",(a=e.apiKey)!=null?a:g.apiKey);const s=n.toString(),i=yield I(s);if(!i.ok)throw new v(i,i.status in O?O[i.status]:"");return yield i.json()})}const ee={get:X};function x(r){const t=/^maptiler:\/\/(.*)/;let e;const a=r.trim();let n;return a.startsWith("http://")||a.startsWith("https://")?n=a:(e=t.exec(a))!==null?n=`https://api.maptiler.com/maps/${e[1]}/style.json`:n=`https://api.maptiler.com/maps/${a}/style.json`,n}class U{constructor(t,e,a,n,s,i){this.name=t,this.variantType=e,this.id=a,this.referenceStyle=n,this.description=s,this.imageURL=i}getName(){return this.name}getFullName(){return`${this.referenceStyle.getName()} ${this.name}`}getType(){return this.variantType}getId(){return this.id}getDescription(){return this.description}getReferenceStyle(){return this.referenceStyle}hasVariant(t){return this.referenceStyle.hasVariant(t)}getVariant(t){return this.referenceStyle.getVariant(t)}getVariants(){return this.referenceStyle.getVariants().filter(t=>t!==this)}getImageURL(){return this.imageURL}getExpandedStyleURL(){return x(this.getId())}}class D{constructor(t,e){this.name=t,this.id=e,this.variants={},this.orderedVariants=[]}getName(){return this.name}getId(){return this.id}addVariant(t){this.variants[t.getType()]=t,this.orderedVariants.push(t)}hasVariant(t){return t in this.variants}getVariant(t){return t in this.variants?this.variants[t]:this.orderedVariants[0]}getVariants(){return Object.values(this.variants)}getDefaultVariant(){return this.orderedVariants[0]}}const R=[{referenceStyleID:"STREETS",name:"Streets",description:"",variants:[{id:"streets-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"streets-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"streets-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"streets-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"OUTDOOR",name:"Outdoor",description:"",variants:[{id:"outdoor-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"WINTER",name:"Winter",description:"",variants:[{id:"winter-v2",name:"Winter",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"SATELLITE",name:"Satellite",description:"",variants:[{id:"satellite",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"HYBRID",name:"Hybrid",description:"",variants:[{id:"hybrid",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"BASIC",name:"Basic",description:"",variants:[{id:"basic-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"basic-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"basic-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"BRIGHT",name:"Bright",description:"",variants:[{id:"bright-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"bright-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"bright-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"bright-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"OPENSTREETMAP",name:"OpenStreetMap",description:"",variants:[{id:"openstreetmap",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"TOPO",name:"Topo",description:"",variants:[{id:"topo-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"topo-v2-shiny",name:"Shiny",variantType:"SHINY",description:"",imageURL:""},{id:"topo-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""},{id:"topo-v2-topographique",name:"Topographique",variantType:"TOPOGRAPHIQUE",description:"",imageURL:""}]},{referenceStyleID:"VOYAGER",name:"Voyager",description:"",variants:[{id:"voyager-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"voyager-v2-darkmatter",name:"Darkmatter",variantType:"DARK",description:"",imageURL:""},{id:"voyager-v2-positron",name:"Positron",variantType:"LIGHT",description:"",imageURL:""},{id:"voyager-v2-vintage",name:"Vintage",variantType:"VINTAGE",description:"",imageURL:""}]},{referenceStyleID:"TONER",name:"Toner",description:"",variants:[{id:"toner-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"toner-v2-background",name:"Background",variantType:"BACKGROUND",description:"",imageURL:""},{id:"toner-v2-lite",name:"Lite",variantType:"LITE",description:"",imageURL:""},{id:"toner-v2-lines",name:"Lines",variantType:"LINES",description:"",imageURL:""}]},{referenceStyleID:"DATAVIZ",name:"Dataviz",description:"",variants:[{id:"dataviz",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"dataviz-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"dataviz-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"OCEAN",name:"Ocean",description:"",variants:[{id:"ocean",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]}];function te(r){return new Proxy(r,{get(t,e,a){return t.hasVariant(e)?t.getVariant(e):e.toString().toUpperCase()===e?r.getDefaultVariant():Reflect.get(t,e,a)}})}function re(){const r={};for(let t=0;t<R.length;t+=1){const e=R[t],a=te(new D(e.name,e.referenceStyleID));for(let n=0;n<e.variants.length;n+=1){const s=e.variants[n],i=new U(s.name,s.variantType,s.id,a,s.description,s.imageURL);a.addVariant(i)}r[e.referenceStyleID]=a}return r}function k(r){if(!r)return H[R[0].referenceStyleID].getDefaultVariant().getId();if(typeof r=="string"||r instanceof String)return r.trim().toLowerCase();if(r instanceof U)return r.getId();if(r instanceof D)return r.getDefaultVariant().getId()}const H=re();function ne(r,t,e){let a=t[0],n=t[1],s=e[0]-a,i=e[1]-n;if(s!==0||i!==0){const c=((r[0]-a)*s+(r[1]-n)*i)/(s*s+i*i);c>1?(a=e[0],n=e[1]):c>0&&(a+=s*c,n+=i*c)}return s=r[0]-a,i=r[1]-n,s*s+i*i}function E(r,t,e,a,n){let s=a,i;for(let c=t+1;c<e;c++){const o=ne(r[c],r[t],r[e]);o>s&&(i=c,s=o)}s>a&&(i-t>1&&E(r,t,i,a,n),n.push(r[i]),e-i>1&&E(r,i,e,a,n))}function ae(r,t){const e=r.length-1,a=[r[0]];return E(r,0,e,t,a),a.push(r[e]),a}function ie(r,t){if(r.length<=2)return r;const e=t!==void 0?t*t:1;return ae(r,e)}function P(r,t=!0){let e=`${r[0]},${r[1]}`;return r.length===3&&t&&(e+=`,${r[2]}`),e}function $(r,t=3e3){let e=r.map(s=>s.join(",")).join("|"),a=5e-6;const n=1e-5;for(;e.length>t;)e=ie(r,a).map(s=>`${s[0]},${s[1]}`).join("|"),a+=n;return e}function se(r,t,e={}){var a,n,s,i,c;const o=k(e.style),l=e.hiDPI?"@2x":"",f=(a=e.format)!=null?a:"png";let u=~~((n=e.width)!=null?n:1024),m=~~((s=e.height)!=null?s:1024);e.hiDPI&&(u=~~(u/2),m=~~(m/2));const p=new URL(`maps/${encodeURIComponent(o)}/static/${r[0]},${r[1]},${t}/${u}x${m}${l}.${f}`,y.maptilerApiURL);if("attribution"in e&&p.searchParams.set("attribution",e.attribution.toString()),"markers"in e){let h="";const d="markerIcon"in e;d&&(h+=`icon:${e.markerIcon}|`),d&&"markerAnchor"in e&&(h+=`anchor:${e.markerAnchor}|`),d&&e.hiDPI&&(h+="scale:2|");const T=Array.isArray(e.markers[0])?e.markers:[e.markers];h+=T.map(j=>P(j,!d)).join("|"),p.searchParams.set("markers",h)}if("path"in e){let h="";if(h+=`fill:${(i=e.pathFillColor)!=null?i:"none"}|`,"pathStrokeColor"in e&&(h+=`stroke:${e.pathStrokeColor}|`),"pathWidth"in e){const d=e.pathWidth/(e.hiDPI?2:1);h+=`width:${d.toString()}|`}h+=$(e.path),p.searchParams.set("path",h)}return p.searchParams.set("key",(c=e.apiKey)!=null?c:g.apiKey),p.toString()}function oe(r,t={}){var e,a,n,s,i;const c=k(t.style),o=t.hiDPI?"@2x":"",l=(e=t.format)!=null?e:"png";let f=~~((a=t.width)!=null?a:1024),u=~~((n=t.height)!=null?n:1024);t.hiDPI&&(f=~~(f/2),u=~~(u/2));const m=new URL(`maps/${encodeURIComponent(c)}/static/${r[0]},${r[1]},${r[2]},${r[3]}/${f}x${u}${o}.${l}`,y.maptilerApiURL);if("attribution"in t&&m.searchParams.set("attribution",t.attribution.toString()),"padding"in t&&m.searchParams.set("padding",t.padding.toString()),"markers"in t){let p="";const h="markerIcon"in t;h&&(p+=`icon:${t.markerIcon}|`),h&&"markerAnchor"in t&&(p+=`anchor:${t.markerAnchor}|`),h&&t.hiDPI&&(p+="scale:2|");const d=Array.isArray(t.markers[0])?t.markers:[t.markers];p+=d.map(T=>P(T,!h)).join("|"),m.searchParams.set("markers",p)}if("path"in t){let p="";if(p+=`fill:${(s=t.pathFillColor)!=null?s:"none"}|`,"pathStrokeColor"in t&&(p+=`stroke:${t.pathStrokeColor}|`),"pathWidth"in t){const h=t.pathWidth/(t.hiDPI?2:1);p+=`width:${h.toString()}|`}p+=$(t.path),m.searchParams.set("path",p)}return m.searchParams.set("key",(i=t.apiKey)!=null?i:g.apiKey),m.toString()}function ce(r={}){var t,e,a,n,s;if(!("markers"in r)&&!("path"in r))throw new Error("Automatic static maps require markers and/or path to be created.");const i=k(r.style),c=r.hiDPI?"@2x":"",o=(t=r.format)!=null?t:"png";let l=~~((e=r.width)!=null?e:1024),f=~~((a=r.height)!=null?a:1024);r.hiDPI&&(l=~~(l/2),f=~~(f/2));const u=new URL(`maps/${encodeURIComponent(i)}/static/auto/${l}x${f}${c}.${o}`,y.maptilerApiURL);if("attribution"in r&&u.searchParams.set("attribution",r.attribution.toString()),"padding"in r&&u.searchParams.set("padding",r.padding.toString()),"markers"in r){let m="";const p="markerIcon"in r;p&&(m+=`icon:${r.markerIcon}|`),p&&"markerAnchor"in r&&(m+=`anchor:${r.markerAnchor}|`),p&&r.hiDPI&&(m+="scale:2|");const h=Array.isArray(r.markers[0])?r.markers:[r.markers];m+=h.map(d=>P(d,!p)).join("|"),u.searchParams.set("markers",m)}if("path"in r){let m="";if(m+=`fill:${(n=r.pathFillColor)!=null?n:"none"}|`,"pathStrokeColor"in r&&(m+=`stroke:${r.pathStrokeColor}|`),"pathWidth"in r){const p=r.pathWidth/(r.hiDPI?2:1);m+=`width:${p.toString()}|`}m+=$(r.path),u.searchParams.set("path",m)}return u.searchParams.set("key",(s=r.apiKey)!=null?s:g.apiKey),u.toString()}const le={centered:se,bounded:oe,automatic:ce};export{w as ClientConfig,A as LanguageGeocoding,H as MapStyle,U as MapStyleVariant,D as ReferenceMapStyle,v as ServiceError,g as config,J as coordinates,ee as data,x as expandMapStyle,W as geocoding,q as geolocation,R as mapStylePresetList,le as staticMaps};
1
+ function F(){return typeof self<"u"?fetch.bind(self):typeof global<"u"&&global.fetch?global.fetch:null}class N{constructor(){this._apiKey="",this._fetch=F()}set apiKey(e){this._apiKey=e}get apiKey(){return this._apiKey}set fetch(e){this._fetch=e}get fetch(){return this._fetch}}const y=new N,L={AUTO:"auto",ALBANIAN:"sq",ARABIC:"ar",ARMENIAN:"hy",AZERBAIJANI:"az",BELORUSSIAN:"be",BOSNIAN:"bs",BRETON:"br",BULGARIAN:"bg",CATALAN:"ca",CHINESE:"zh",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",HUNGARIAN:"hu",ICELANDIC:"is",IRISH:"ga",ITALIAN:"it",JAPANESE:"ja",KANNADA:"kn",KAZAKH:"kk",KOREAN:"ko",ROMAN_LATIN:"la",LATVIAN:"lv",LITHUANIAN:"lt",LUXEMBOURGISH:"lb",MACEDONIAN:"mk",MALTESE:"mt",NORWEGIAN:"no",POLISH:"pl",PORTUGUESE:"pt",ROMANIAN:"ro",ROMANSH:"rm",RUSSIAN:"ru",SCOTTISH_GAELIC:"gd",SERBIAN_CYRILLIC:"sr",SLOVAK:"sk",SLOVENE:"sl",SPANISH:"es",SWEDISH:"sv",THAI:"th",TURKISH:"tr",UKRAINIAN:"uk",WELSH:"cy"},M=new Set(Object.values(L));function B(){if(typeof navigator>"u")return Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];const n=Array.from(new Set(navigator.languages.map(e=>e.split("-")[0]))).filter(e=>M.has(e));return n.length?n[0]:L.ENGLISH}var W=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});function A(n){return W(this,arguments,function*(e,t={}){if(y.fetch===null)throw new Error("The fetch function was not found. If on NodeJS < 18 please specify the fetch function with config.fetch");if(new URL(e).searchParams.get("key").trim()==="")throw new Error("The MapTiler Cloud API key is missing. Set it in `config.apiKey` or get one for free at https://maptiler.com");return y.fetch(e,t)})}const d={maptilerApiURL:"https://api.maptiler.com/",mapStyle:"streets-v2"};Object.freeze(d);class v extends Error{constructor(e,t=""){super(`Call to enpoint ${e.url} failed with the status code ${e.status}. ${t}`),this.res=e}}var R=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});const I={400:"Query too long / Invalid parameters",403:"Key is missing, invalid or restricted"};function b(n,e){if(e.language==null)return;const t=Array.from(new Set((Array.isArray(e.language)?e.language:[e.language]).map(r=>r===L.AUTO?B():r))).join(",");n.set("language",t)}function C(n,e){var t;n.set("key",(t=e.apiKey)!=null?t:y.apiKey),e.limit!=null&&n.set("limit",String(e.limit)),e.types!=null&&n.set("types",e.types.join(",")),b(n,e)}function K(n,e){C(n,e),e.bbox!=null&&n.set("bbox",e.bbox.join(",")),e.proximity!=null&&n.set("proximity",e.proximity.join(",")),e.country!=null&&n.set("country",e.country.join(",")),e.fuzzyMatch!=null&&n.set("fuzzyMatch",e.fuzzyMatch?"true":"false"),e.autocomplete!=null&&n.set("autocomplete",e.autocomplete?"true":"false")}function z(n){return R(this,arguments,function*(e,t={}){var r;if(typeof e!="string"||e.trim().length===0)throw new Error("The query must be a non-empty string");const i=new URL(`geocoding/${encodeURIComponent(e)}.json`,d.maptilerApiURL),{searchParams:s}=i;K(s,t);const a=i.toString(),c=yield A(a);if(!c.ok)throw new v(c,(r=I[c.status])!=null?r:"");return yield c.json()})}function _(n){return R(this,arguments,function*(e,t={}){var r;if(!Array.isArray(e)||e.length<2)throw new Error("The position must be an array of form [lng, lat].");const i=new URL(`geocoding/${e[0]},${e[1]}.json`,d.maptilerApiURL);C(i.searchParams,t);const s=i.toString(),a=yield A(s);if(!a.ok)throw new v(a,(r=I[a.status])!=null?r:"");return yield a.json()})}function q(n){return R(this,arguments,function*(e,t={}){var r;const i=new URL(`geocoding/${e}.json`,d.maptilerApiURL);b(i.searchParams,t);const s=i.toString(),a=yield A(s);if(!a.ok)throw new v(a,(r=I[a.status])!=null?r:"");return yield a.json()})}function Y(n){return R(this,arguments,function*(e,t={}){var r;if(!e.length)return[];const i=e.map(g=>encodeURIComponent(g)).join(";"),s=new URL(`geocoding/${i}.json`,d.maptilerApiURL),{searchParams:a}=s;K(a,t);const c=s.toString(),o=yield A(c);if(!o.ok)throw new v(o,(r=I[o.status])!=null?r:"");const l=yield o.json();return e.length===1?[l]:l})}const Z={forward:z,reverse:_,byId:q,batch:Y,language:L};var J=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});const O={403:"Key is missing, invalid or restricted"};function Q(){return J(this,arguments,function*(n={}){var e;const t=new URL("geolocation/ip.json",d.maptilerApiURL);t.searchParams.set("key",(e=n.apiKey)!=null?e:y.apiKey);const r=t.toString(),i=yield A(r);if(!i.ok)throw new v(i,i.status in O?O[i.status]:"");return yield i.json()})}const X={info:Q};var j=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});const S={403:"Key is missing, invalid or restricted"};function ee(n){return j(this,arguments,function*(e,t={}){var r;if(typeof e!="string"||e.trim().length===0)throw new Error("The query must be a non-empty string");const i=new URL(`coordinates/search/${e}.json`,d.maptilerApiURL);i.searchParams.set("key",(r=t.apiKey)!=null?r:y.apiKey),"limit"in t&&i.searchParams.set("limit",t.limit.toString()),"transformations"in t&&i.searchParams.set("transformations",t.transformations.toString()),"exports"in t&&i.searchParams.set("exports",t.exports.toString());const s=i.toString(),a=yield A(s);if(!a.ok)throw new v(a,a.status in S?S[a.status]:"");return yield a.json()})}function te(n){return j(this,arguments,function*(e,t={}){var r;const i=(Array.isArray(e[0])?e:[e]).map(o=>`${o[0]},${o[1]}`).join(";"),s=new URL(`coordinates/transform/${i}.json`,d.maptilerApiURL);s.searchParams.set("key",(r=t.apiKey)!=null?r:y.apiKey),"sourceCrs"in t&&s.searchParams.set("s_srs",t.sourceCrs.toString()),"targetCrs"in t&&s.searchParams.set("t_srs",t.targetCrs.toString()),"operations"in t&&s.searchParams.set("ops",(Array.isArray(t.operations)?t.operations:[t.operations]).join("|"));const a=s.toString(),c=yield A(a);if(!c.ok)throw new v(c,c.status in S?S[c.status]:"");return yield c.json()})}const ne={search:ee,transform:te};var re=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});const H={403:"Key is missing, invalid or restricted"};function ie(n){return re(this,arguments,function*(e,t={}){var r;if(typeof e!="string"||e.trim().length===0)throw new Error("The data ID must be a non-empty string");const i=new URL(`data/${encodeURIComponent(e)}/features.json`,d.maptilerApiURL);i.searchParams.set("key",(r=t.apiKey)!=null?r:y.apiKey);const s=i.toString(),a=yield A(s);if(!a.ok)throw new v(a,a.status in H?H[a.status]:"");return yield a.json()})}const ae={get:ie};function x(n){const e=/^maptiler:\/\/(.*)/;let t;const r=n.trim();let i;return r.startsWith("http://")||r.startsWith("https://")?i=r:(t=e.exec(r))!==null?i=`https://api.maptiler.com/maps/${t[1]}/style.json`:i=`https://api.maptiler.com/maps/${r}/style.json`,i}class D{constructor(e,t,r,i,s,a){this.name=e,this.variantType=t,this.id=r,this.referenceStyle=i,this.description=s,this.imageURL=a}getName(){return this.name}getFullName(){return`${this.referenceStyle.getName()} ${this.name}`}getType(){return this.variantType}getId(){return this.id}getDescription(){return this.description}getReferenceStyle(){return this.referenceStyle}hasVariant(e){return this.referenceStyle.hasVariant(e)}getVariant(e){return this.referenceStyle.getVariant(e)}getVariants(){return this.referenceStyle.getVariants().filter(e=>e!==this)}getImageURL(){return this.imageURL}getExpandedStyleURL(){return x(this.getId())}}class k{constructor(e,t){this.name=e,this.id=t,this.variants={},this.orderedVariants=[]}getName(){return this.name}getId(){return this.id}addVariant(e){this.variants[e.getType()]=e,this.orderedVariants.push(e)}hasVariant(e){return e in this.variants}getVariant(e){return e in this.variants?this.variants[e]:this.orderedVariants[0]}getVariants(){return Object.values(this.variants)}getDefaultVariant(){return this.orderedVariants[0]}}const T=[{referenceStyleID:"STREETS",name:"Streets",description:"",variants:[{id:"streets-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"streets-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"streets-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"streets-v2-night",name:"Night",variantType:"NIGHT",description:"",imageURL:""},{id:"streets-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"OUTDOOR",name:"Outdoor",description:"",variants:[{id:"outdoor-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"outdoor-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"WINTER",name:"Winter",description:"",variants:[{id:"winter-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"winter-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"SATELLITE",name:"Satellite",description:"",variants:[{id:"satellite",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"HYBRID",name:"Hybrid",description:"",variants:[{id:"hybrid",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"BASIC",name:"Basic",description:"",variants:[{id:"basic-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"basic-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"basic-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"BRIGHT",name:"Bright",description:"",variants:[{id:"bright-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"bright-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"bright-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"bright-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"OPENSTREETMAP",name:"OpenStreetMap",description:"",variants:[{id:"openstreetmap",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"TOPO",name:"Topo",description:"",variants:[{id:"topo-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"topo-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"topo-v2-shiny",name:"Shiny",variantType:"SHINY",description:"",imageURL:""},{id:"topo-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""},{id:"topo-v2-topographique",name:"Topographique",variantType:"TOPOGRAPHIQUE",description:"",imageURL:""}]},{referenceStyleID:"VOYAGER",name:"Voyager",description:"",variants:[{id:"voyager-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"voyager-v2-darkmatter",name:"Darkmatter",variantType:"DARK",description:"",imageURL:""},{id:"voyager-v2-positron",name:"Positron",variantType:"LIGHT",description:"",imageURL:""},{id:"voyager-v2-vintage",name:"Vintage",variantType:"VINTAGE",description:"",imageURL:""}]},{referenceStyleID:"TONER",name:"Toner",description:"",variants:[{id:"toner-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"toner-v2-background",name:"Background",variantType:"BACKGROUND",description:"",imageURL:""},{id:"toner-v2-lite",name:"Lite",variantType:"LITE",description:"",imageURL:""},{id:"toner-v2-lines",name:"Lines",variantType:"LINES",description:"",imageURL:""}]},{referenceStyleID:"DATAVIZ",name:"Dataviz",description:"",variants:[{id:"dataviz",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"dataviz-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"dataviz-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"OCEAN",name:"Ocean",description:"",variants:[{id:"ocean",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]}];function se(n){return new Proxy(n,{get(e,t,r){return e.hasVariant(t)?e.getVariant(t):t.toString().toUpperCase()===t?n.getDefaultVariant():Reflect.get(e,t,r)}})}function oe(){const n={};for(let e=0;e<T.length;e+=1){const t=T[e],r=se(new k(t.name,t.referenceStyleID));for(let i=0;i<t.variants.length;i+=1){const s=t.variants[i],a=new D(s.name,s.variantType,s.id,r,s.description,s.imageURL);r.addVariant(a)}n[t.referenceStyleID]=r}return n}function $(n){if(!n)return V[T[0].referenceStyleID].getDefaultVariant().getId();if(typeof n=="string"||n instanceof String)return n.trim().toLowerCase();if(n instanceof D)return n.getId();if(n instanceof k)return n.getDefaultVariant().getId()}const V=oe();function ce(n,e,t){let r=e[0],i=e[1],s=t[0]-r,a=t[1]-i;if(s!==0||a!==0){const c=((n[0]-r)*s+(n[1]-i)*a)/(s*s+a*a);c>1?(r=t[0],i=t[1]):c>0&&(r+=s*c,i+=a*c)}return s=n[0]-r,a=n[1]-i,s*s+a*a}function E(n,e,t,r,i){let s=r,a;for(let c=e+1;c<t;c++){const o=ce(n[c],n[e],n[t]);o>s&&(a=c,s=o)}s>r&&(a-e>1&&E(n,e,a,r,i),i.push(n[a]),t-a>1&&E(n,a,t,r,i))}function le(n,e){const t=n.length-1,r=[n[0]];return E(n,0,t,e,r),r.push(n[t]),r}function pe(n,e){if(n.length<=2)return n;const t=e!==void 0?e*e:1;return le(n,t)}function w(n,e=!0){let t=`${n[0]},${n[1]}`;return n.length===3&&e&&(t+=`,${n[2]}`),t}function P(n,e=3e3){let t=n.map(s=>s.join(",")).join("|"),r=5e-6;const i=1e-5;for(;t.length>e;)t=pe(n,r).map(s=>`${s[0]},${s[1]}`).join("|"),r+=i;return t}function me(n,e,t={}){var r,i,s,a,c;const o=$(t.style),l=t.hiDPI?"@2x":"",g=(r=t.format)!=null?r:"png";let u=~~((i=t.width)!=null?i:1024),m=~~((s=t.height)!=null?s:1024);t.hiDPI&&(u=~~(u/2),m=~~(m/2));const p=new URL(`maps/${encodeURIComponent(o)}/static/${n[0]},${n[1]},${e}/${u}x${m}${l}.${g}`,d.maptilerApiURL);if("attribution"in t&&p.searchParams.set("attribution",t.attribution.toString()),"markers"in t){let h="";const f="markerIcon"in t;f&&(h+=`icon:${t.markerIcon}|`),f&&"markerAnchor"in t&&(h+=`anchor:${t.markerAnchor}|`),f&&t.hiDPI&&(h+="scale:2|");const U=Array.isArray(t.markers[0])?t.markers:[t.markers];h+=U.map(G=>w(G,!f)).join("|"),p.searchParams.set("markers",h)}if("path"in t){let h="";if(h+=`fill:${(a=t.pathFillColor)!=null?a:"none"}|`,"pathStrokeColor"in t&&(h+=`stroke:${t.pathStrokeColor}|`),"pathWidth"in t){const f=t.pathWidth/(t.hiDPI?2:1);h+=`width:${f.toString()}|`}h+=P(t.path),p.searchParams.set("path",h)}return p.searchParams.set("key",(c=t.apiKey)!=null?c:y.apiKey),p.toString()}function he(n,e={}){var t,r,i,s,a;const c=$(e.style),o=e.hiDPI?"@2x":"",l=(t=e.format)!=null?t:"png";let g=~~((r=e.width)!=null?r:1024),u=~~((i=e.height)!=null?i:1024);e.hiDPI&&(g=~~(g/2),u=~~(u/2));const m=new URL(`maps/${encodeURIComponent(c)}/static/${n[0]},${n[1]},${n[2]},${n[3]}/${g}x${u}${o}.${l}`,d.maptilerApiURL);if("attribution"in e&&m.searchParams.set("attribution",e.attribution.toString()),"padding"in e&&m.searchParams.set("padding",e.padding.toString()),"markers"in e){let p="";const h="markerIcon"in e;h&&(p+=`icon:${e.markerIcon}|`),h&&"markerAnchor"in e&&(p+=`anchor:${e.markerAnchor}|`),h&&e.hiDPI&&(p+="scale:2|");const f=Array.isArray(e.markers[0])?e.markers:[e.markers];p+=f.map(U=>w(U,!h)).join("|"),m.searchParams.set("markers",p)}if("path"in e){let p="";if(p+=`fill:${(s=e.pathFillColor)!=null?s:"none"}|`,"pathStrokeColor"in e&&(p+=`stroke:${e.pathStrokeColor}|`),"pathWidth"in e){const h=e.pathWidth/(e.hiDPI?2:1);p+=`width:${h.toString()}|`}p+=P(e.path),m.searchParams.set("path",p)}return m.searchParams.set("key",(a=e.apiKey)!=null?a:y.apiKey),m.toString()}function ue(n={}){var e,t,r,i,s;if(!("markers"in n)&&!("path"in n))throw new Error("Automatic static maps require markers and/or path to be created.");const a=$(n.style),c=n.hiDPI?"@2x":"",o=(e=n.format)!=null?e:"png";let l=~~((t=n.width)!=null?t:1024),g=~~((r=n.height)!=null?r:1024);n.hiDPI&&(l=~~(l/2),g=~~(g/2));const u=new URL(`maps/${encodeURIComponent(a)}/static/auto/${l}x${g}${c}.${o}`,d.maptilerApiURL);if("attribution"in n&&u.searchParams.set("attribution",n.attribution.toString()),"padding"in n&&u.searchParams.set("padding",n.padding.toString()),"markers"in n){let m="";const p="markerIcon"in n;p&&(m+=`icon:${n.markerIcon}|`),p&&"markerAnchor"in n&&(m+=`anchor:${n.markerAnchor}|`),p&&n.hiDPI&&(m+="scale:2|");const h=Array.isArray(n.markers[0])?n.markers:[n.markers];m+=h.map(f=>w(f,!p)).join("|"),u.searchParams.set("markers",m)}if("path"in n){let m="";if(m+=`fill:${(i=n.pathFillColor)!=null?i:"none"}|`,"pathStrokeColor"in n&&(m+=`stroke:${n.pathStrokeColor}|`),"pathWidth"in n){const p=n.pathWidth/(n.hiDPI?2:1);m+=`width:${p.toString()}|`}m+=P(n.path),u.searchParams.set("path",m)}return u.searchParams.set("key",(s=n.apiKey)!=null?s:y.apiKey),u.toString()}const de={centered:me,bounded:he,automatic:ue};export{N as ClientConfig,L as LanguageGeocoding,V as MapStyle,D as MapStyleVariant,k as ReferenceMapStyle,v as ServiceError,y as config,ne as coordinates,ae as data,x as expandMapStyle,Z as geocoding,X as geolocation,T as mapStylePresetList,de as staticMaps};
@@ -189,6 +189,48 @@ const customMessages$3 = {
189
189
  400: "Query too long / Invalid parameters",
190
190
  403: "Key is missing, invalid or restricted"
191
191
  };
192
+ function addLanguageGeocodingOptions(searchParams, options) {
193
+ if (options.language == void 0) {
194
+ return;
195
+ }
196
+ const languages = Array.from(
197
+ new Set(
198
+ (Array.isArray(options.language) ? options.language : [options.language]).map(
199
+ (lang) => lang === LanguageGeocoding.AUTO ? getAutoLanguageGeocoding() : lang
200
+ )
201
+ )
202
+ ).join(",");
203
+ searchParams.set("language", languages);
204
+ }
205
+ function addCommonForwardAndReverseGeocodingOptions(searchParams, options) {
206
+ var _a;
207
+ searchParams.set("key", (_a = options.apiKey) != null ? _a : config.apiKey);
208
+ if (options.limit != void 0) {
209
+ searchParams.set("limit", String(options.limit));
210
+ }
211
+ if (options.types != void 0) {
212
+ searchParams.set("types", options.types.join(","));
213
+ }
214
+ addLanguageGeocodingOptions(searchParams, options);
215
+ }
216
+ function addForwardGeocodingOptions(searchParams, options) {
217
+ addCommonForwardAndReverseGeocodingOptions(searchParams, options);
218
+ if (options.bbox != void 0) {
219
+ searchParams.set("bbox", options.bbox.join(","));
220
+ }
221
+ if (options.proximity != void 0) {
222
+ searchParams.set("proximity", options.proximity.join(","));
223
+ }
224
+ if (options.country != void 0) {
225
+ searchParams.set("country", options.country.join(","));
226
+ }
227
+ if (options.fuzzyMatch != void 0) {
228
+ searchParams.set("fuzzyMatch", options.fuzzyMatch ? "true" : "false");
229
+ }
230
+ if (options.autocomplete != void 0) {
231
+ searchParams.set("autocomplete", options.autocomplete ? "true" : "false");
232
+ }
233
+ }
192
234
  function forward(_0) {
193
235
  return __async$3(this, arguments, function* (query, options = {}) {
194
236
  var _a;
@@ -199,30 +241,12 @@ function forward(_0) {
199
241
  `geocoding/${encodeURIComponent(query)}.json`,
200
242
  defaults.maptilerApiURL
201
243
  );
202
- endpoint.searchParams.set("key", (_a = options.apiKey) != null ? _a : config.apiKey);
203
- if ("bbox" in options) {
204
- endpoint.searchParams.set("bbox", options.bbox.join(","));
205
- }
206
- if ("proximity" in options) {
207
- endpoint.searchParams.set("proximity", options.proximity.join(","));
208
- }
209
- if ("language" in options) {
210
- const languages = Array.from(
211
- new Set(
212
- (Array.isArray(options.language) ? options.language : [options.language]).map(
213
- (lang) => lang === LanguageGeocoding.AUTO ? getAutoLanguageGeocoding() : lang
214
- )
215
- )
216
- ).join(",");
217
- endpoint.searchParams.set("language", languages);
218
- }
244
+ const { searchParams } = endpoint;
245
+ addForwardGeocodingOptions(searchParams, options);
219
246
  const urlWithParams = endpoint.toString();
220
247
  const res = yield callFetch(urlWithParams);
221
248
  if (!res.ok) {
222
- throw new ServiceError(
223
- res,
224
- res.status in customMessages$3 ? customMessages$3[res.status] : ""
225
- );
249
+ throw new ServiceError(res, (_a = customMessages$3[res.status]) != null ? _a : "");
226
250
  }
227
251
  const obj = yield res.json();
228
252
  return obj;
@@ -238,32 +262,57 @@ function reverse(_0) {
238
262
  `geocoding/${position[0]},${position[1]}.json`,
239
263
  defaults.maptilerApiURL
240
264
  );
241
- endpoint.searchParams.set("key", (_a = options.apiKey) != null ? _a : config.apiKey);
242
- if ("language" in options) {
243
- const languages = Array.from(
244
- new Set(
245
- (Array.isArray(options.language) ? options.language : [options.language]).map(
246
- (lang) => lang === LanguageGeocoding.AUTO ? getAutoLanguageGeocoding() : lang
247
- )
248
- )
249
- ).join(",");
250
- endpoint.searchParams.set("language", languages);
265
+ addCommonForwardAndReverseGeocodingOptions(endpoint.searchParams, options);
266
+ const urlWithParams = endpoint.toString();
267
+ const res = yield callFetch(urlWithParams);
268
+ if (!res.ok) {
269
+ throw new ServiceError(res, (_a = customMessages$3[res.status]) != null ? _a : "");
251
270
  }
271
+ const obj = yield res.json();
272
+ return obj;
273
+ });
274
+ }
275
+ function byId(_0) {
276
+ return __async$3(this, arguments, function* (id, options = {}) {
277
+ var _a;
278
+ const endpoint = new URL(`geocoding/${id}.json`, defaults.maptilerApiURL);
279
+ addLanguageGeocodingOptions(endpoint.searchParams, options);
252
280
  const urlWithParams = endpoint.toString();
253
281
  const res = yield callFetch(urlWithParams);
254
282
  if (!res.ok) {
255
- throw new ServiceError(
256
- res,
257
- res.status in customMessages$3 ? customMessages$3[res.status] : ""
258
- );
283
+ throw new ServiceError(res, (_a = customMessages$3[res.status]) != null ? _a : "");
259
284
  }
260
285
  const obj = yield res.json();
261
286
  return obj;
262
287
  });
263
288
  }
289
+ function batch(_0) {
290
+ return __async$3(this, arguments, function* (queries, options = {}) {
291
+ var _a;
292
+ if (!queries.length) {
293
+ return [];
294
+ }
295
+ const joinedQuery = queries.map((query) => encodeURIComponent(query)).join(";");
296
+ const endpoint = new URL(
297
+ `geocoding/${joinedQuery}.json`,
298
+ defaults.maptilerApiURL
299
+ );
300
+ const { searchParams } = endpoint;
301
+ addForwardGeocodingOptions(searchParams, options);
302
+ const urlWithParams = endpoint.toString();
303
+ const res = yield callFetch(urlWithParams);
304
+ if (!res.ok) {
305
+ throw new ServiceError(res, (_a = customMessages$3[res.status]) != null ? _a : "");
306
+ }
307
+ const obj = yield res.json();
308
+ return queries.length === 1 ? [obj] : obj;
309
+ });
310
+ }
264
311
  const geocoding = {
265
312
  forward,
266
313
  reverse,
314
+ byId,
315
+ batch,
267
316
  language: LanguageGeocoding
268
317
  };
269
318
 
@@ -651,6 +700,13 @@ const mapStylePresetList = [
651
700
  description: "",
652
701
  imageURL: ""
653
702
  },
703
+ {
704
+ id: "streets-v2-night",
705
+ name: "Night",
706
+ variantType: "NIGHT",
707
+ description: "",
708
+ imageURL: ""
709
+ },
654
710
  {
655
711
  id: "streets-v2-pastel",
656
712
  name: "Pastel",
@@ -671,6 +727,13 @@ const mapStylePresetList = [
671
727
  variantType: "DEFAULT",
672
728
  description: "",
673
729
  imageURL: ""
730
+ },
731
+ {
732
+ id: "outdoor-v2-dark",
733
+ name: "Dark",
734
+ variantType: "DARK",
735
+ description: "",
736
+ imageURL: ""
674
737
  }
675
738
  ]
676
739
  },
@@ -681,10 +744,17 @@ const mapStylePresetList = [
681
744
  variants: [
682
745
  {
683
746
  id: "winter-v2",
684
- name: "Winter",
747
+ name: "Default",
685
748
  variantType: "DEFAULT",
686
749
  description: "",
687
750
  imageURL: ""
751
+ },
752
+ {
753
+ id: "winter-v2-dark",
754
+ name: "Dark",
755
+ variantType: "DARK",
756
+ description: "",
757
+ imageURL: ""
688
758
  }
689
759
  ]
690
760
  },
@@ -805,6 +875,13 @@ const mapStylePresetList = [
805
875
  description: "",
806
876
  imageURL: ""
807
877
  },
878
+ {
879
+ id: "topo-v2-dark",
880
+ name: "Dark",
881
+ variantType: "DARK",
882
+ description: "",
883
+ imageURL: ""
884
+ },
808
885
  {
809
886
  id: "topo-v2-shiny",
810
887
  name: "Shiny",