@maptiler/client 2.2.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -1
- package/dist/maptiler-client.cjs +70 -14
- package/dist/maptiler-client.cjs.map +1 -1
- package/dist/maptiler-client.d.ts +32 -0
- package/dist/maptiler-client.min.mjs +1 -1
- package/dist/maptiler-client.mjs +70 -14
- package/dist/maptiler-client.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1679,6 +1679,7 @@ type MapStyleType = {
|
|
|
1679
1679
|
VOYAGER: ReferenceMapStyle & {
|
|
1680
1680
|
/**
|
|
1681
1681
|
* A nice alternative to `streets` with a soft color palette
|
|
1682
|
+
*
|
|
1682
1683
|
*/
|
|
1683
1684
|
DEFAULT: MapStyleVariant;
|
|
1684
1685
|
/**
|
|
@@ -1758,6 +1759,37 @@ type MapStyleType = {
|
|
|
1758
1759
|
*/
|
|
1759
1760
|
LIGHT: MapStyleVariant;
|
|
1760
1761
|
};
|
|
1762
|
+
LANDSCAPE: ReferenceMapStyle & {
|
|
1763
|
+
/**
|
|
1764
|
+
* Light terrain map for data overlays and visualisations
|
|
1765
|
+
*/
|
|
1766
|
+
DEFAULT: MapStyleVariant;
|
|
1767
|
+
/**
|
|
1768
|
+
* Dark terrain map for data overlays and visualisations
|
|
1769
|
+
*/
|
|
1770
|
+
DARK: MapStyleVariant;
|
|
1771
|
+
/**
|
|
1772
|
+
* Vivid terrain map for data overlays and visualisations
|
|
1773
|
+
*/
|
|
1774
|
+
VIVID: MapStyleVariant;
|
|
1775
|
+
};
|
|
1776
|
+
/**
|
|
1777
|
+
* Watercolor map for creative use
|
|
1778
|
+
*/
|
|
1779
|
+
AQUARELLE: ReferenceMapStyle & {
|
|
1780
|
+
/**
|
|
1781
|
+
* Watercolor map for creative use
|
|
1782
|
+
*/
|
|
1783
|
+
DEFAULT: MapStyleVariant;
|
|
1784
|
+
/**
|
|
1785
|
+
* Dark watercolor map for creative use
|
|
1786
|
+
*/
|
|
1787
|
+
DARK: MapStyleVariant;
|
|
1788
|
+
/**
|
|
1789
|
+
* Vivid watercolor map for creative use
|
|
1790
|
+
*/
|
|
1791
|
+
VIVID: MapStyleVariant;
|
|
1792
|
+
};
|
|
1761
1793
|
};
|
|
1762
1794
|
declare const mapStylePresetList: Array<MapStylePreset>;
|
|
1763
1795
|
declare function styleToStyle(style: string | ReferenceMapStyle | MapStyleVariant | null | undefined): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import we from"quick-lru";function Ee(){return typeof self<"u"?fetch.bind(self):typeof global<"u"&&global.fetch?global.fetch:null}class X{constructor(){this._apiKey="",this._fetch=Ee(),this.tileCacheSize=200}set apiKey(n){this._apiKey=n}get apiKey(){return this._apiKey}set fetch(n){this._fetch=n}get fetch(){return this._fetch}}const m=new X,ee={AUTO:{code:null,flag:"auto",name:"Auto",latin:!1,isMode:!0,geocoding:!0},LATIN:{code:"latin",flag:"name:latin",name:"Latin",latin:!0,isMode:!1,geocoding:!1},NON_LATIN:{code:"nonlatin",flag:"name:nonlatin",name:"Non Latin",latin:!1,isMode:!1,geocoding:!1},LOCAL:{code:null,flag:"name",name:"Local",latin:!0,isMode:!1,geocoding:!1}},ne={ALBANIAN:{code:"sq",flag:"name:sq",name:"Albanian",latin:!0,isMode:!1,geocoding:!0},AMHARIC:{code:"am",flag:"name:am",name:"Amharic",latin:!1,isMode:!1,geocoding:!1},ARABIC:{code:"ar",flag:"name:ar",name:"Arabic",latin:!1,isMode:!1,geocoding:!0},ARMENIAN:{code:"hy",flag:"name:hy",name:"Armenian",latin:!1,isMode:!1,geocoding:!0},AZERBAIJANI:{code:"az",flag:"name:az",name:"Azerbaijani",latin:!0,isMode:!1,geocoding:!0},BASQUE:{code:"eu",flag:"name:eu",name:"Basque",latin:!0,isMode:!1,geocoding:!1},BELARUSIAN:{code:"be",flag:"name:be",name:"Belarusian",latin:!1,isMode:!1,geocoding:!0},BENGALI:{code:"bn",flag:"name:bn",name:"Bengali",latin:!0,isMode:!1,geocoding:!1},BOSNIAN:{code:"bs",flag:"name:bs",name:"Bosnian",latin:!0,isMode:!1,geocoding:!0},BRETON:{code:"br",flag:"name:br",name:"Breton",latin:!0,isMode:!1,geocoding:!0},BULGARIAN:{code:"bg",flag:"bg",name:"Bulgarian",latin:!1,isMode:!1,geocoding:!0},CATALAN:{code:"ca",flag:"name:ca",name:"Catalan",latin:!0,isMode:!1,geocoding:!0},CHINESE:{code:"zh",flag:"name:zh",name:"Chinese",latin:!1,isMode:!1,geocoding:!0},TRADITIONAL_CHINESE:{code:"zh-Hant",flag:"name:zh-Hant",name:"Chinese (traditional)",latin:!1,isMode:!1,geocoding:!1},SIMPLIFIED_CHINESE:{code:"zh-Hans",flag:"name:zh-Hans",name:"Chinese (simplified)",latin:!1,isMode:!1,geocoding:!1},CORSICAN:{code:"co",flag:"name:co",name:"Corsican",latin:!0,isMode:!1,geocoding:!1},CROATIAN:{code:"hr",flag:"name:hr",name:"Croatian",latin:!0,isMode:!1,geocoding:!0},CZECH:{code:"cs",flag:"name:cs",name:"Czech",latin:!0,isMode:!1,geocoding:!0},DANISH:{code:"da",flag:"name:da",name:"Danish",latin:!0,isMode:!1,geocoding:!0},DUTCH:{code:"nl",flag:"name:nl",name:"Dutch",latin:!0,isMode:!1,geocoding:!0},GERMAN:{code:"de",flag:"name:de",name:"German",latin:!0,isMode:!1,geocoding:!0},GREEK:{code:"el",flag:"name:el",name:"Greek",latin:!1,isMode:!1,geocoding:!0},ENGLISH:{code:"en",flag:"name:en",name:"English",latin:!0,isMode:!1,geocoding:!0},ESPERANTO:{code:"eo",flag:"name:eo",name:"Esperanto",latin:!0,isMode:!1,geocoding:!0},ESTONIAN:{code:"et",flag:"name:et",name:"Estonian",latin:!0,isMode:!1,geocoding:!0},FINNISH:{code:"fi",flag:"name:fi",name:"Finnish",latin:!0,isMode:!1,geocoding:!0},FRENCH:{code:"fr",flag:"name:fr",name:"French",latin:!0,isMode:!1,geocoding:!0},FRISIAN:{code:"fy",flag:"name:fy",name:"Frisian (West)",latin:!0,isMode:!1,geocoding:!0},GEORGIAN:{code:"ka",flag:"name:ka",name:"Georgian",latin:!1,isMode:!1,geocoding:!0},HEBREW:{code:"he",flag:"name:he",name:"Hebrew",latin:!1,isMode:!1,geocoding:!0},HINDI:{code:"hi",flag:"name:hi",name:"Hindi",latin:!1,isMode:!1,geocoding:!1},HUNGARIAN:{code:"hu",flag:"name:hu",name:"Hungarian",latin:!0,isMode:!1,geocoding:!0},ICELANDIC:{code:"is",flag:"name:is",name:"Icelandic",latin:!0,isMode:!1,geocoding:!0},INDONESIAN:{code:"id",flag:"name:id",name:"Indonesian",latin:!0,isMode:!1,geocoding:!1},IRISH:{code:"ga",flag:"name:ga",name:"Irish",latin:!0,isMode:!1,geocoding:!0},ITALIAN:{code:"it",flag:"name:it",name:"Italian",latin:!0,isMode:!1,geocoding:!0},JAPANESE:{code:"ja",flag:"name:ja",name:"Japanese",latin:!1,isMode:!1,geocoding:!0},JAPANESE_HIRAGANA:{code:"ja-Hira",flag:"name:ja-Hira",name:"Japanese Hiragana form",latin:!1,isMode:!1,geocoding:!1},JAPANESE_2018:{code:"ja-Latn",flag:"name:ja-Latn",name:"Japanese (Latin 2018)",latin:!0,isMode:!1,geocoding:!1},JAPANESE_KANA:{code:"ja_kana",flag:"name:ja_kana",name:"Japanese (Kana)",latin:!1,isMode:!1,geocoding:!1},JAPANESE_LATIN:{code:"ja_rm",flag:"name:ja_rm",name:"Japanese (Latin script)",latin:!0,isMode:!1,geocoding:!1},KANNADA:{code:"kn",flag:"name:kn",name:"Kannada",latin:!0,isMode:!1,geocoding:!0},KAZAKH:{code:"kk",flag:"name:kk",name:"Kazakh",latin:!1,isMode:!1,geocoding:!0},KOREAN:{code:"ko",flag:"name:ko",name:"Korean",latin:!1,isMode:!1,geocoding:!0},KOREAN_LATIN:{code:"ko-Latn",flag:"name:ko-Latn",name:"Korean (Latin script)",latin:!0,isMode:!1,geocoding:!1},KURDISH:{code:"ku",flag:"name:ku",name:"Kurdish",latin:!0,isMode:!1,geocoding:!1},CLASSICAL_LATIN:{code:"la",flag:"name:la",name:"Latin",latin:!0,isMode:!1,geocoding:!0},LATVIAN:{code:"lv",flag:"name:lv",name:"Latvian",latin:!0,isMode:!1,geocoding:!0},LITHUANIAN:{code:"lt",flag:"name:lt",name:"Lithuanian",latin:!0,isMode:!1,geocoding:!0},LUXEMBOURGISH:{code:"lb",flag:"name:lb",name:"Luxembourgish",latin:!0,isMode:!1,geocoding:!0},MACEDONIAN:{code:"mk",flag:"name:mk",name:"Macedonian",latin:!1,isMode:!1,geocoding:!0},MALAYALAM:{code:"ml",flag:"name:ml",name:"Malayalam",latin:!1,isMode:!1,geocoding:!1},MALTESE:{code:"mt",flag:"name:mt",name:"Maltese",latin:!0,isMode:!1,geocoding:!0},NORWEGIAN:{code:"no",flag:"name:no",name:"Norwegian",latin:!0,isMode:!1,geocoding:!0},OCCITAN:{code:"oc",flag:"name:oc",name:"Occitan",latin:!0,isMode:!1,geocoding:!1},PERSIAN:{code:"fa",flag:"name:fa",name:"Persian",latin:!1,isMode:!1,geocoding:!1},POLISH:{code:"pl",flag:"name:pl",name:"Polish",latin:!0,isMode:!1,geocoding:!0},PORTUGUESE:{code:"pt",flag:"name:pt",name:"Portuguese",latin:!0,isMode:!1,geocoding:!0},PUNJABI:{code:"pa",flag:"name:pa",name:"Punjabi",latin:!1,isMode:!1,geocoding:!1},WESTERN_PUNJABI:{code:"pnb",flag:"name:pnb",name:"Western Punjabi",latin:!1,isMode:!1,geocoding:!1},ROMANIAN:{code:"ro",flag:"name:ro",name:"Romanian",latin:!0,isMode:!1,geocoding:!0},ROMANSH:{code:"rm",flag:"name:rm",name:"Romansh",latin:!0,isMode:!1,geocoding:!0},RUSSIAN:{code:"ru",flag:"name:ru",name:"Russian",latin:!1,isMode:!1,geocoding:!0},SERBIAN_CYRILLIC:{code:"sr",flag:"name:sr",name:"Serbian (Cyrillic script)",latin:!1,isMode:!1,geocoding:!0},SERBIAN_LATIN:{code:"sr-Latn",flag:"name:sr-Latn",name:"Serbian (Latin script)",latin:!0,isMode:!1,geocoding:!1},SCOTTISH_GAELIC:{code:"gd",flag:"name:gd",name:"Scottish Gaelic",latin:!0,isMode:!1,geocoding:!0},SLOVAK:{code:"sk",flag:"name:sk",name:"Slovak",latin:!0,isMode:!1,geocoding:!0},SLOVENE:{code:"sl",flag:"name:sl",name:"Slovene",latin:!0,isMode:!1,geocoding:!0},SPANISH:{code:"es",flag:"name:es",name:"Spanish",latin:!0,isMode:!1,geocoding:!0},SWEDISH:{code:"sv",flag:"name:sv",name:"Swedish",latin:!0,isMode:!1,geocoding:!0},TAMIL:{code:"ta",flag:"name:ta",name:"Tamil",latin:!1,isMode:!1,geocoding:!1},TELUGU:{code:"te",flag:"name:te",name:"Telugu",latin:!1,isMode:!1,geocoding:!1},THAI:{code:"th",flag:"name:th",name:"Thai",latin:!1,isMode:!1,geocoding:!0},TURKISH:{code:"tr",flag:"name:tr",name:"Turkish",latin:!0,isMode:!1,geocoding:!0},UKRAINIAN:{code:"uk",flag:"name:uk",name:"Ukrainian",latin:!1,isMode:!1,geocoding:!0},VIETNAMESE:{code:"vi",flag:"name:vi",name:"Vietnamese (Latin script)",latin:!0,isMode:!1,geocoding:!1},WELSH:{code:"cy",flag:"name:cy",name:"Welsh",latin:!0,isMode:!1,geocoding:!0}},I={...ee,...ne};function te(e,n=I){return e in n?e[e]:null}function k(e,n=I){for(const t of Object.values(n))if(t.code===e)return t;return null}function N(e,n=I){for(const t of Object.values(n))if(t.flag===e)return t;return null}function O(){if(typeof navigator>"u"){const e=Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];return k(e)??I.ENGLISH}return Array.from(new Set(navigator.languages.map(e=>e.split("-")[0]))).map(e=>k(e)).filter(e=>e)[0]??I.ENGLISH}function j(e){return e!==null&&typeof e=="object"&&"code"in e&&"flag"in e&&"name"in e&&"latin"in e&&"isMode"in e&&"geocoding"in e&&(typeof e.code=="string"||e.code===null)&&typeof e.flag=="string"&&typeof e.name=="string"&&typeof e.latin=="boolean"&&typeof e.isMode=="boolean"&&typeof e.geocoding=="boolean"}function H(e,n=I){return j(e)?N(e.flag,n):typeof e!="string"?null:te(e,n)||k(e,n)||N(e,n)||null}function Ue(e,n,t=I){const a=H(e,t),i=H(n,t);return a&&i&&a.flag===i.flag}async function S(e,n={}){if(m.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 m.fetch(e,n)}const y={maptilerApiURL:"https://api.maptiler.com/",mapStyle:"streets-v2"};Object.freeze(y);class L extends Error{constructor(n,t=""){super(`Call to enpoint ${n.url} failed with the status code ${n.status}. ${t}`),this.res=n}}const P={400:"Query too long / Invalid parameters",403:"Key is missing, invalid or restricted"};function ae(e,n){const{language:t}=n;if(t===void 0)return;const a=(Array.isArray(t)?t:[t]).map(o=>ke(o)).filter(o=>o),i=Array.from(new Set(a)).join(",");e.set("language",i)}function ke(e){const n=e===I.AUTO.flag?O():typeof e=="string"?k(e):j(e)?e.flag===I.AUTO.flag?O():N(e.flag):null;return n?.geocoding?n.code:null}function ie(e,n){const{apiKey:t,limit:a,types:i,excludeTypes:o}=n;e.set("key",t??m.apiKey),a!==void 0&&e.set("limit",String(a)),i!==void 0&&e.set("types",i.join(",")),o!==void 0&&e.set("excludeTypes",String(o)),ae(e,n)}function oe(e,n){ie(e,n);const{bbox:t,proximity:a,country:i,fuzzyMatch:o,autocomplete:r}=n;t!==void 0&&e.set("bbox",t.join(",")),a!==void 0&&e.set("proximity",a==="ip"?a:a.join(",")),i!==void 0&&e.set("country",i.join(",")),o!==void 0&&e.set("fuzzyMatch",o?"true":"false"),r!==void 0&&e.set("autocomplete",r?"true":"false")}async function De(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new Error("The query must be a non-empty string");const t=new URL(`geocoding/${encodeURIComponent(e)}.json`,y.maptilerApiURL);oe(t.searchParams,n);const a=await S(t.toString());if(!a.ok)throw new L(a,P[a.status]??"");return await a.json()}async function Ne(e,n={}){if(!Array.isArray(e)||e.length<2)throw new Error("The position must be an array of form [lng, lat].");const t=new URL(`geocoding/${e[0]},${e[1]}.json`,y.maptilerApiURL);ie(t.searchParams,n);const a=await S(t.toString());if(!a.ok)throw new L(a,P[a.status]??"");return await a.json()}async function Pe(e,n={}){const t=new URL(`geocoding/${e}.json`,y.maptilerApiURL);t.searchParams.set("key",n.apiKey??m.apiKey),ae(t.searchParams,n);const a=await S(t.toString());if(!a.ok)throw new L(a,P[a.status]??"");return await a.json()}async function $e(e,n={}){if(!e.length)return[];const t=e.map(r=>encodeURIComponent(r)).join(";"),a=new URL(`geocoding/${t}.json`,y.maptilerApiURL);oe(a.searchParams,n);const i=await S(a.toString());if(!i.ok)throw new L(i,P[i.status]??"");const o=await i.json();return e.length===1?[o]:o}const be={forward:De,reverse:Ne,byId:Pe,batch:$e},re={403:"Key is missing, invalid or restricted"};async function Ce(e={}){const n=new URL("geolocation/ip.json",y.maptilerApiURL);n.searchParams.set("key",e.apiKey??m.apiKey);const t=n.toString(),a=await S(t);if(!a.ok)throw new L(a,a.status in re?re[a.status]:"");return await a.json()}const Ke={info:Ce},$={403:"Key is missing, invalid or restricted"};async function Oe(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new Error("The query must be a non-empty string");const t=new URL(`coordinates/search/${e}.json`,y.maptilerApiURL);t.searchParams.set("key",n.apiKey??m.apiKey),"limit"in n&&t.searchParams.set("limit",n.limit.toString()),"transformations"in n&&t.searchParams.set("transformations",n.transformations.toString()),"exports"in n&&t.searchParams.set("exports",n.exports.toString());const a=t.toString(),i=await S(a);if(!i.ok)throw new L(i,i.status in $?$[i.status]:"");return await i.json()}async function je(e,n={}){const t=(Array.isArray(e[0])?e:[e]).map(r=>`${r[0]},${r[1]}`).join(";"),a=new URL(`coordinates/transform/${t}.json`,y.maptilerApiURL);a.searchParams.set("key",n.apiKey??m.apiKey),"sourceCrs"in n&&a.searchParams.set("s_srs",n.sourceCrs.toString()),"targetCrs"in n&&a.searchParams.set("t_srs",n.targetCrs.toString()),"operations"in n&&a.searchParams.set("ops",(Array.isArray(n.operations)?n.operations:[n.operations]).join("|"));const i=a.toString(),o=await S(i);if(!o.ok)throw new L(o,o.status in $?$[o.status]:"");return await o.json()}const He={search:Oe,transform:je},se={403:"Key is missing, invalid or restricted"};async function xe(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new Error("The data ID must be a non-empty string");const t=new URL(`data/${encodeURIComponent(e)}/features.json`,y.maptilerApiURL);t.searchParams.set("key",n.apiKey??m.apiKey);const a=t.toString(),i=await S(a);if(!i.ok)throw new L(i,i.status in se?se[i.status]:"");return await i.json()}const Fe={get:xe};function ce(e){const n=/^maptiler:\/\/(.*)/;let t;const a=e.trim();let i;return a.startsWith("http://")||a.startsWith("https://")?i=a:(t=n.exec(a))!==null?i=`https://api.maptiler.com/maps/${t[1]}/style.json`:i=`https://api.maptiler.com/maps/${a}/style.json`,i}class x{constructor(n,t,a,i,o,r){this.name=n,this.variantType=t,this.id=a,this.referenceStyle=i,this.description=o,this.imageURL=r}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(n){return this.referenceStyle.hasVariant(n)}getVariant(n){return this.referenceStyle.getVariant(n)}getVariants(){return this.referenceStyle.getVariants().filter(n=>n!==this)}getImageURL(){return this.imageURL}getExpandedStyleURL(){return ce(this.getId())}}class F{constructor(n,t){this.name=n,this.id=t,this.variants={},this.orderedVariants=[]}getName(){return this.name}getId(){return this.id}addVariant(n){this.variants[n.getType()]=n,this.orderedVariants.push(n)}hasVariant(n){return n in this.variants}getVariant(n){return n in this.variants?this.variants[n]:this.orderedVariants[0]}getVariants(){return Object.values(this.variants)}getDefaultVariant(){return this.orderedVariants[0]}}const b=[{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:"BACKDROP",name:"Backdrop",description:"",variants:[{id:"backdrop",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"backdrop-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"backdrop-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"OCEAN",name:"Ocean",description:"",variants:[{id:"ocean",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]}];function _e(e){return new Proxy(e,{get(n,t,a){return n.hasVariant(t)?n.getVariant(t):t.toString().toUpperCase()===t?e.getDefaultVariant():Reflect.get(n,t,a)}})}function Be(){const e={};for(let n=0;n<b.length;n+=1){const t=b[n],a=_e(new F(t.name,t.referenceStyleID));for(let i=0;i<t.variants.length;i+=1){const o=t.variants[i],r=new x(o.name,o.variantType,o.id,a,o.description,o.imageURL);a.addVariant(r)}e[t.referenceStyleID]=a}return e}function C(e){if(!e)return ge[b[0].referenceStyleID].getDefaultVariant().getId();if(typeof e=="string"||e instanceof String)return e.trim().toLowerCase();if(e instanceof x)return e.getId();if(e instanceof F)return e.getDefaultVariant().getId()}const ge=Be();function Ge(e){const n=[];function t(o){(o.type==="LineString"||o.type==="MultiLineString")&&n.push(o)}function a(o){o.geometry&&t(o.geometry)}function i(o){for(const r of o.features)r.type==="Feature"?a(r):r.type==="FeatureCollection"&&i(r)}return e.type==="Feature"?a(e):e.type==="FeatureCollection"?i(e):t(e),n}function ze(e,n,t){let a=n[0],i=n[1],o=t[0]-a,r=t[1]-i;if(o!==0||r!==0){const s=((e[0]-a)*o+(e[1]-i)*r)/(o*o+r*r);s>1?(a=t[0],i=t[1]):s>0&&(a+=o*s,i+=r*s)}return o=e[0]-a,r=e[1]-i,o*o+r*r}function _(e,n,t,a,i){let o=a,r;for(let s=n+1;s<t;s++){const c=ze(e[s],e[n],e[t]);c>o&&(r=s,o=c)}o>a&&(r-n>1&&_(e,n,r,a,i),i.push(e[r]),t-r>1&&_(e,r,t,a,i))}function Ve(e,n){const t=e.length-1,a=[e[0]];return _(e,0,t,n,a),a.push(e[t]),a}function We(e,n){if(e.length<=2)return e;const t=n!==void 0?n*n:1;return Ve(e,t)}const le={extractLineStrings:Ge,simplify:We};function B(e,n=!0){let t=`${e[0]},${e[1]}`;return e.length===3&&n&&(t+=`,${e[2]}`),t}function G(e,n=3e3){let t=e.map(o=>o.join(",")).join("|"),a=5e-6;const i=1e-5;for(;t.length>n;)t=le.simplify(e,a).map(o=>`${o[0]},${o[1]}`).join("|"),a+=i;return t}function Je(e,n,t={}){const a=C(t.style),i=t.hiDPI?"@2x":"",o=t.format??"png";let r=~~(t.width??1024),s=~~(t.height??1024);t.hiDPI&&(r=~~(r/2),s=~~(s/2));const c=new URL(`maps/${encodeURIComponent(a)}/static/${e[0]},${e[1]},${n}/${r}x${s}${i}.${o}`,y.maptilerApiURL);if("attribution"in t&&c.searchParams.set("attribution",t.attribution.toString()),"markers"in t){let l="";const d="markerIcon"in t;d&&(l+=`icon:${t.markerIcon}|`),d&&"markerAnchor"in t&&(l+=`anchor:${t.markerAnchor}|`),d&&t.hiDPI&&(l+="scale:2|");const A=Array.isArray(t.markers[0])?t.markers:[t.markers];l+=A.map(h=>B(h,!d)).join("|"),c.searchParams.set("markers",l)}if("path"in t){let l="";if(l+=`fill:${t.pathFillColor??"none"}|`,"pathStrokeColor"in t&&(l+=`stroke:${t.pathStrokeColor}|`),"pathWidth"in t){const d=t.pathWidth/(t.hiDPI?2:1);l+=`width:${d.toString()}|`}l+=G(t.path),c.searchParams.set("path",l)}return c.searchParams.set("key",t.apiKey??m.apiKey),c.toString()}function qe(e,n={}){const t=C(n.style),a=n.hiDPI?"@2x":"",i=n.format??"png";let o=~~(n.width??1024),r=~~(n.height??1024);n.hiDPI&&(o=~~(o/2),r=~~(r/2));const s=new URL(`maps/${encodeURIComponent(t)}/static/${e[0]},${e[1]},${e[2]},${e[3]}/${o}x${r}${a}.${i}`,y.maptilerApiURL);if("attribution"in n&&s.searchParams.set("attribution",n.attribution.toString()),"padding"in n&&s.searchParams.set("padding",n.padding.toString()),"markers"in n){let c="";const l="markerIcon"in n;l&&(c+=`icon:${n.markerIcon}|`),l&&"markerAnchor"in n&&(c+=`anchor:${n.markerAnchor}|`),l&&n.hiDPI&&(c+="scale:2|");const d=Array.isArray(n.markers[0])?n.markers:[n.markers];c+=d.map(A=>B(A,!l)).join("|"),s.searchParams.set("markers",c)}if("path"in n){let c="";if(c+=`fill:${n.pathFillColor??"none"}|`,"pathStrokeColor"in n&&(c+=`stroke:${n.pathStrokeColor}|`),"pathWidth"in n){const l=n.pathWidth/(n.hiDPI?2:1);c+=`width:${l.toString()}|`}c+=G(n.path),s.searchParams.set("path",c)}return s.searchParams.set("key",n.apiKey??m.apiKey),s.toString()}function Ye(e={}){if(!("markers"in e)&&!("path"in e))throw new Error("Automatic static maps require markers and/or path to be created.");const n=C(e.style),t=e.hiDPI?"@2x":"",a=e.format??"png";let i=~~(e.width??1024),o=~~(e.height??1024);e.hiDPI&&(i=~~(i/2),o=~~(o/2));const r=new URL(`maps/${encodeURIComponent(n)}/static/auto/${i}x${o}${t}.${a}`,y.maptilerApiURL);if("attribution"in e&&r.searchParams.set("attribution",e.attribution.toString()),"padding"in e&&r.searchParams.set("padding",e.padding.toString()),"markers"in e){let s="";const c="markerIcon"in e;c&&(s+=`icon:${e.markerIcon}|`),c&&"markerAnchor"in e&&(s+=`anchor:${e.markerAnchor}|`),c&&e.hiDPI&&(s+="scale:2|");const l=Array.isArray(e.markers[0])?e.markers:[e.markers];s+=l.map(d=>B(d,!c)).join("|"),r.searchParams.set("markers",s)}if("path"in e){let s="";if(s+=`fill:${e.pathFillColor??"none"}|`,"pathStrokeColor"in e&&(s+=`stroke:${e.pathStrokeColor}|`),"pathWidth"in e){const c=e.pathWidth/(e.hiDPI?2:1);s+=`width:${c.toString()}|`}s+=G(e.path),r.searchParams.set("path",s)}return r.searchParams.set("key",e.apiKey??m.apiKey),r.toString()}const Ze={centered:Je,bounded:qe,automatic:Ye},K=63710088e-1,de=2*Math.PI*K;function me(e){return(180+e)/360}function fe(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function he(e){const n=ye(e);return[me(n[0]),fe(n[1])]}function pe(e){return e*360-180}function ue(e){const n=180-e*360;return 360/Math.PI*Math.atan(Math.exp(n*Math.PI/180))-90}function Qe(e){return[pe(e[0]),ue(e[1])]}function z(e,n){const t=Math.PI/180,a=e[1]*t,i=n[1]*t,o=Math.sin(a)*Math.sin(i)+Math.cos(a)*Math.cos(i)*Math.cos((n[0]-e[0])*t);return K*Math.acos(Math.min(o,1))}function Xe(e){const n=Array(e.length);n[0]=0;const t=n.length;for(let a=1;a<t;a++)n[a]=z(e[a-1],e[a])+n[a-1];return n}function ye(e){const n=e[0],t=e[1],a=360,i=((n+180)%a+a)%a-180;return[i===-180?180:i,t]}function Ae(e){return de*Math.cos(e*Math.PI/180)}function Le(e,n,t=!0){const a=2**n,i=[e[0]*a,e[1]*a];return t?[~~i[0],~~i[1]]:i}function en(e,n,t=!0){const a=he(e);return Le(a,n,t)}function D(e){return e*Math.PI/180}function V(e){return e*180/Math.PI}function nn(e,n,t){const a=z(e,n),i=D(e[0]),o=D(e[1]),r=D(n[0]),s=D(n[1]),c=a/K,l=Math.sin((1-t)*c)/Math.sin(c),d=Math.sin(t*c)/Math.sin(c),A=l*Math.cos(o)*Math.cos(i)+d*Math.cos(s)*Math.cos(r),h=l*Math.cos(o)*Math.sin(i)+d*Math.cos(s)*Math.sin(r),v=l*Math.sin(o)+d*Math.sin(s),w=Math.atan2(v,Math.sqrt(A*A+h*h)),R=Math.atan2(h,A);return[V(R),V(w)]}const W={EARTH_RADIUS:K,EARTH_CIRCUMFERENCE:de,longitudeToMercatorX:me,latitudeToMercatorY:fe,wgs84ToMercator:he,mercatorXToLongitude:pe,mercatorYToLatitude:ue,mercatorToWgs84:Qe,haversineDistanceWgs84:z,wrapWgs84:ye,circumferenceAtLatitude:Ae,mercatorToTileIndex:Le,wgs84ToTileIndex:en,toRadians:D,toDegrees:V,haversineIntermediateWgs84:nn,haversineCumulatedDistanceWgs84:Xe};let J=null;function q(){return J||(J=new we({maxSize:m.tileCacheSize})),J}async function Se(e){const n=new Blob([e]),t=await createImageBitmap(n),a=document.createElement("canvas"),i=a.getContext("2d");a.width=t.width,a.height=t.height,i.drawImage(t,0,0);const o=i.getImageData(0,0,a.width,a.height);return{pixels:o.data,width:a.width,height:a.height,components:o.data.length/(a.width*a.height)}}function Y(){if(m.bufferToPixelData)return m.bufferToPixelData;if(typeof window<"u")return Se;throw new Error("An image file buffer to pixel data parser is necessary. Specify it in `config.bufferToPixelData`")}const tn="tiles/terrain-rgb-v2/tiles.json";let T=null;const Z={403:"Key is missing, invalid or restricted"};async function Ie(e){const n=new URL(tn,y.maptilerApiURL);n.searchParams.set("key",e);const t=n.toString(),a=await S(t);if(a.ok)return T=await a.json(),T;if(!a.ok)throw new L(a,Z[a.status]??"")}async function an(e,n={}){const t=n.apiKey??m.apiKey;T||await Ie(t);const a=T.maxzoom;let i=~~(n.zoom??a);(i>a||i<0)&&(i=a);const o=W.wgs84ToTileIndex(e,i,!1),r=~~o[0],s=~~o[1];if(!T.tiles.length)throw new Error("Terrain tileJSON tile list is empty.");const c=`terrain_${i.toString()}_${r.toString()}_${s.toString()}`;let l;const d=q();if(d.has(c))l=d.get(c);else{const M=T.tiles[0].replace("{x}",r.toString()).replace("{y}",s.toString()).replace("{z}",i.toString()),f=await S(M);if(!f.ok)throw new L(f,Z[f.status]??"");const p=await f.arrayBuffer();l=await Y()(p),d.set(c,l)}const A=~~(l.width*(o[0]%1)),h=(~~(l.height*(o[1]%1))*l.width+A)*l.components,v=l.pixels[h],w=l.pixels[h+1],R=l.pixels[h+2],g=-1e4+(v*256*256+w*256+R)*.1;return[e[0],e[1],g]}async function Q(e,n={}){const t=n.apiKey??m.apiKey;T||await Ie(t);const a=Y(),i=T.tiles[0],o=q(),r=T.maxzoom;let s=~~(n.zoom??r);(s>r||s<0)&&(s=r);const c=e.map(g=>W.wgs84ToTileIndex(g,s,!1)),l=c.map(g=>[~~g[0],~~g[1]]).map(g=>`terrain_${s.toString()}_${g[0].toString()}_${g[1].toString()}`),d=Array.from(new Set(l.filter(g=>!o.has(g)))).map(g=>g.split("_").slice(1)),A=d.map(g=>i.replace("{x}",g[1].toString()).replace("{y}",g[2].toString()).replace("{z}",g[0].toString())).map(g=>S(g)),h=(await Promise.allSettled(A)).map(g=>g.status==="fulfilled"?g.value:null).filter(g=>g),v=h.filter(g=>!g.ok);if(h.length!==A.length)throw new Error("Some tiles could not be fetched.");if(v.length)throw new L(v[0],Z[v[0].status]??"");const w=await Promise.all(h.map(g=>g.arrayBuffer()));if(!w.every(g=>g.byteLength>0))throw new Error("Some tiles are not available.");(await Promise.all(w.map(g=>a(g)))).forEach((g,M)=>{const f=d[M],p=`terrain_${f[0].toString()}_${f[1].toString()}_${f[2].toString()}`;o.set(p,g)});const R=e.map((g,M)=>{const f=l[M],p=c[M],u=o.get(f),E=Math.min(Math.round(u.width*(p[0]%1)),u.width-1),U=(Math.min(Math.round(u.height*(p[1]%1)),u.height-1)*u.width+E)*u.components,Me=u.pixels[U],Te=u.pixels[U+1],ve=u.pixels[U+2],Re=-1e4+(Me*256*256+Te*256+ve)*.1;return[g[0],g[1],~~(Re*1e3)/1e3]});if(n.smoothingKernelSize){const g=~~(n.smoothingKernelSize/2)*2+1,M=R.map(p=>p[2]),f=~~(g/2);for(let p=f;p<M.length-f-1;p+=1){let u=0;for(let E=0;E<g;E+=1){const U=M[p-f+E];u+=U}u/=g,R[p][2]=u}}return R}async function on(e,n={}){if(e.type!=="LineString")throw new Error("The provided object is not a GeoJSON LineString");const t=structuredClone(e),a=await Q(t.coordinates,n);return t.coordinates=a,t}async function rn(e,n={}){if(e.type!=="MultiLineString")throw new Error("The provided object is not a GeoJSON MultiLineString");const t=structuredClone(e),a=t.coordinates.map(c=>c.length),i=t.coordinates.flat(),o=await Q(i,n),r=[];let s=0;for(const c of a)r.push(o.slice(s,s+c)),s+=c;return t.coordinates=r,t}const sn={at:an,batch:Q,fromLineString:on,fromMultiLineString:rn};export{X as ClientConfig,ne as ISOLanguage,I as Language,ge as MapStyle,x as MapStyleVariant,ee as NonISOLanguage,F as ReferenceMapStyle,L as ServiceError,Ue as areSameLanguages,Se as bufferToPixelDataBrowser,Ae as circumferenceAtLatitude,m as config,He as coordinates,Fe as data,sn as elevation,ce as expandMapStyle,be as geocoding,Ke as geolocation,O as getAutoLanguage,Y as getBufferToPixelDataParser,k as getLanguageInfoFromCode,N as getLanguageInfoFromFlag,te as getLanguageInfoFromKey,q as getTileCache,j as isLanguageInfo,b as mapStylePresetList,W as math,le as misc,Ze as staticMaps,C as styleToStyle,H as toLanguageInfo};
|
|
1
|
+
import we from"quick-lru";function Ue(){return typeof self<"u"?fetch.bind(self):typeof global<"u"&&global.fetch?global.fetch:null}class X{constructor(){this._apiKey="",this._fetch=Ue(),this.tileCacheSize=200}set apiKey(n){this._apiKey=n}get apiKey(){return this._apiKey}set fetch(n){this._fetch=n}get fetch(){return this._fetch}}const m=new X,ee={AUTO:{code:null,flag:"auto",name:"Auto",latin:!1,isMode:!0,geocoding:!0},LATIN:{code:"latin",flag:"name:latin",name:"Latin",latin:!0,isMode:!1,geocoding:!1},NON_LATIN:{code:"nonlatin",flag:"name:nonlatin",name:"Non Latin",latin:!1,isMode:!1,geocoding:!1},LOCAL:{code:null,flag:"name",name:"Local",latin:!0,isMode:!1,geocoding:!1}},ne={ALBANIAN:{code:"sq",flag:"name:sq",name:"Albanian",latin:!0,isMode:!1,geocoding:!0},AMHARIC:{code:"am",flag:"name:am",name:"Amharic",latin:!1,isMode:!1,geocoding:!0},ARABIC:{code:"ar",flag:"name:ar",name:"Arabic",latin:!1,isMode:!1,geocoding:!0},ARMENIAN:{code:"hy",flag:"name:hy",name:"Armenian",latin:!1,isMode:!1,geocoding:!0},AZERBAIJANI:{code:"az",flag:"name:az",name:"Azerbaijani",latin:!0,isMode:!1,geocoding:!0},BASQUE:{code:"eu",flag:"name:eu",name:"Basque",latin:!0,isMode:!1,geocoding:!0},BELARUSIAN:{code:"be",flag:"name:be",name:"Belarusian",latin:!1,isMode:!1,geocoding:!0},BENGALI:{code:"bn",flag:"name:bn",name:"Bengali",latin:!0,isMode:!1,geocoding:!0},BOSNIAN:{code:"bs",flag:"name:bs",name:"Bosnian",latin:!0,isMode:!1,geocoding:!0},BRETON:{code:"br",flag:"name:br",name:"Breton",latin:!0,isMode:!1,geocoding:!0},BULGARIAN:{code:"bg",flag:"bg",name:"Bulgarian",latin:!1,isMode:!1,geocoding:!0},CATALAN:{code:"ca",flag:"name:ca",name:"Catalan",latin:!0,isMode:!1,geocoding:!0},CHINESE:{code:"zh",flag:"name:zh",name:"Chinese",latin:!1,isMode:!1,geocoding:!0},TRADITIONAL_CHINESE:{code:"zh-Hant",flag:"name:zh-Hant",name:"Chinese (traditional)",latin:!1,isMode:!1,geocoding:!1},SIMPLIFIED_CHINESE:{code:"zh-Hans",flag:"name:zh-Hans",name:"Chinese (simplified)",latin:!1,isMode:!1,geocoding:!1},CORSICAN:{code:"co",flag:"name:co",name:"Corsican",latin:!0,isMode:!1,geocoding:!0},CROATIAN:{code:"hr",flag:"name:hr",name:"Croatian",latin:!0,isMode:!1,geocoding:!0},CZECH:{code:"cs",flag:"name:cs",name:"Czech",latin:!0,isMode:!1,geocoding:!0},DANISH:{code:"da",flag:"name:da",name:"Danish",latin:!0,isMode:!1,geocoding:!0},DUTCH:{code:"nl",flag:"name:nl",name:"Dutch",latin:!0,isMode:!1,geocoding:!0},GERMAN:{code:"de",flag:"name:de",name:"German",latin:!0,isMode:!1,geocoding:!0},GREEK:{code:"el",flag:"name:el",name:"Greek",latin:!1,isMode:!1,geocoding:!0},ENGLISH:{code:"en",flag:"name:en",name:"English",latin:!0,isMode:!1,geocoding:!0},ESPERANTO:{code:"eo",flag:"name:eo",name:"Esperanto",latin:!0,isMode:!1,geocoding:!0},ESTONIAN:{code:"et",flag:"name:et",name:"Estonian",latin:!0,isMode:!1,geocoding:!0},FINNISH:{code:"fi",flag:"name:fi",name:"Finnish",latin:!0,isMode:!1,geocoding:!0},FRENCH:{code:"fr",flag:"name:fr",name:"French",latin:!0,isMode:!1,geocoding:!0},FRISIAN:{code:"fy",flag:"name:fy",name:"Frisian (West)",latin:!0,isMode:!1,geocoding:!0},GEORGIAN:{code:"ka",flag:"name:ka",name:"Georgian",latin:!1,isMode:!1,geocoding:!0},HEBREW:{code:"he",flag:"name:he",name:"Hebrew",latin:!1,isMode:!1,geocoding:!0},HINDI:{code:"hi",flag:"name:hi",name:"Hindi",latin:!1,isMode:!1,geocoding:!0},HUNGARIAN:{code:"hu",flag:"name:hu",name:"Hungarian",latin:!0,isMode:!1,geocoding:!0},ICELANDIC:{code:"is",flag:"name:is",name:"Icelandic",latin:!0,isMode:!1,geocoding:!0},INDONESIAN:{code:"id",flag:"name:id",name:"Indonesian",latin:!0,isMode:!1,geocoding:!0},IRISH:{code:"ga",flag:"name:ga",name:"Irish",latin:!0,isMode:!1,geocoding:!0},ITALIAN:{code:"it",flag:"name:it",name:"Italian",latin:!0,isMode:!1,geocoding:!0},JAPANESE:{code:"ja",flag:"name:ja",name:"Japanese",latin:!1,isMode:!1,geocoding:!0},JAPANESE_HIRAGANA:{code:"ja-Hira",flag:"name:ja-Hira",name:"Japanese Hiragana form",latin:!1,isMode:!1,geocoding:!1},JAPANESE_2018:{code:"ja-Latn",flag:"name:ja-Latn",name:"Japanese (Latin 2018)",latin:!0,isMode:!1,geocoding:!1},JAPANESE_KANA:{code:"ja_kana",flag:"name:ja_kana",name:"Japanese (Kana)",latin:!1,isMode:!1,geocoding:!1},JAPANESE_LATIN:{code:"ja_rm",flag:"name:ja_rm",name:"Japanese (Latin script)",latin:!0,isMode:!1,geocoding:!1},KANNADA:{code:"kn",flag:"name:kn",name:"Kannada",latin:!0,isMode:!1,geocoding:!0},KAZAKH:{code:"kk",flag:"name:kk",name:"Kazakh",latin:!1,isMode:!1,geocoding:!0},KOREAN:{code:"ko",flag:"name:ko",name:"Korean",latin:!1,isMode:!1,geocoding:!0},KOREAN_LATIN:{code:"ko-Latn",flag:"name:ko-Latn",name:"Korean (Latin script)",latin:!0,isMode:!1,geocoding:!1},KURDISH:{code:"ku",flag:"name:ku",name:"Kurdish",latin:!0,isMode:!1,geocoding:!0},CLASSICAL_LATIN:{code:"la",flag:"name:la",name:"Latin",latin:!0,isMode:!1,geocoding:!0},LATVIAN:{code:"lv",flag:"name:lv",name:"Latvian",latin:!0,isMode:!1,geocoding:!0},LITHUANIAN:{code:"lt",flag:"name:lt",name:"Lithuanian",latin:!0,isMode:!1,geocoding:!0},LUXEMBOURGISH:{code:"lb",flag:"name:lb",name:"Luxembourgish",latin:!0,isMode:!1,geocoding:!0},MACEDONIAN:{code:"mk",flag:"name:mk",name:"Macedonian",latin:!1,isMode:!1,geocoding:!0},MALAYALAM:{code:"ml",flag:"name:ml",name:"Malayalam",latin:!1,isMode:!1,geocoding:!0},MALTESE:{code:"mt",flag:"name:mt",name:"Maltese",latin:!0,isMode:!1,geocoding:!0},NORWEGIAN:{code:"no",flag:"name:no",name:"Norwegian",latin:!0,isMode:!1,geocoding:!0},OCCITAN:{code:"oc",flag:"name:oc",name:"Occitan",latin:!0,isMode:!1,geocoding:!0},PERSIAN:{code:"fa",flag:"name:fa",name:"Persian",latin:!1,isMode:!1,geocoding:!0},POLISH:{code:"pl",flag:"name:pl",name:"Polish",latin:!0,isMode:!1,geocoding:!0},PORTUGUESE:{code:"pt",flag:"name:pt",name:"Portuguese",latin:!0,isMode:!1,geocoding:!0},PUNJABI:{code:"pa",flag:"name:pa",name:"Punjabi",latin:!1,isMode:!1,geocoding:!0},WESTERN_PUNJABI:{code:"pnb",flag:"name:pnb",name:"Western Punjabi",latin:!1,isMode:!1,geocoding:!1},ROMANIAN:{code:"ro",flag:"name:ro",name:"Romanian",latin:!0,isMode:!1,geocoding:!0},ROMANSH:{code:"rm",flag:"name:rm",name:"Romansh",latin:!0,isMode:!1,geocoding:!0},RUSSIAN:{code:"ru",flag:"name:ru",name:"Russian",latin:!1,isMode:!1,geocoding:!0},SERBIAN_CYRILLIC:{code:"sr",flag:"name:sr",name:"Serbian (Cyrillic script)",latin:!1,isMode:!1,geocoding:!0},SERBIAN_LATIN:{code:"sr-Latn",flag:"name:sr-Latn",name:"Serbian (Latin script)",latin:!0,isMode:!1,geocoding:!1},SCOTTISH_GAELIC:{code:"gd",flag:"name:gd",name:"Scottish Gaelic",latin:!0,isMode:!1,geocoding:!0},SLOVAK:{code:"sk",flag:"name:sk",name:"Slovak",latin:!0,isMode:!1,geocoding:!0},SLOVENE:{code:"sl",flag:"name:sl",name:"Slovene",latin:!0,isMode:!1,geocoding:!0},SPANISH:{code:"es",flag:"name:es",name:"Spanish",latin:!0,isMode:!1,geocoding:!0},SWEDISH:{code:"sv",flag:"name:sv",name:"Swedish",latin:!0,isMode:!1,geocoding:!0},TAMIL:{code:"ta",flag:"name:ta",name:"Tamil",latin:!1,isMode:!1,geocoding:!0},TELUGU:{code:"te",flag:"name:te",name:"Telugu",latin:!1,isMode:!1,geocoding:!0},THAI:{code:"th",flag:"name:th",name:"Thai",latin:!1,isMode:!1,geocoding:!0},TURKISH:{code:"tr",flag:"name:tr",name:"Turkish",latin:!0,isMode:!1,geocoding:!0},UKRAINIAN:{code:"uk",flag:"name:uk",name:"Ukrainian",latin:!1,isMode:!1,geocoding:!0},VIETNAMESE:{code:"vi",flag:"name:vi",name:"Vietnamese (Latin script)",latin:!0,isMode:!1,geocoding:!0},WELSH:{code:"cy",flag:"name:cy",name:"Welsh",latin:!0,isMode:!1,geocoding:!0}},S={...ee,...ne};function ae(e,n=S){return e in n?e[e]:null}function D(e,n=S){for(const a of Object.values(n))if(a.code===e)return a;return null}function N(e,n=S){for(const a of Object.values(n))if(a.flag===e)return a;return null}function O(){if(typeof navigator>"u"){const e=Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];return D(e)??S.ENGLISH}return Array.from(new Set(navigator.languages.map(e=>e.split("-")[0]))).map(e=>D(e)).filter(e=>e)[0]??S.ENGLISH}function j(e){return e!==null&&typeof e=="object"&&"code"in e&&"flag"in e&&"name"in e&&"latin"in e&&"isMode"in e&&"geocoding"in e&&(typeof e.code=="string"||e.code===null)&&typeof e.flag=="string"&&typeof e.name=="string"&&typeof e.latin=="boolean"&&typeof e.isMode=="boolean"&&typeof e.geocoding=="boolean"}function H(e,n=S){return j(e)?N(e.flag,n):typeof e!="string"?null:ae(e,n)||D(e,n)||N(e,n)||null}function Ee(e,n,a=S){const t=H(e,a),i=H(n,a);return t&&i&&t.flag===i.flag}async function I(e,n={}){if(m.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 m.fetch(e,n)}const y={maptilerApiURL:"https://api.maptiler.com/",mapStyle:"streets-v2"};Object.freeze(y);class L extends Error{constructor(n,a=""){super(`Call to enpoint ${n.url} failed with the status code ${n.status}. ${a}`),this.res=n}}const P={400:"Query too long / Invalid parameters",403:"Key is missing, invalid or restricted"};function te(e,n){const{language:a}=n;if(a===void 0)return;const t=(Array.isArray(a)?a:[a]).map(o=>De(o)).filter(o=>o),i=Array.from(new Set(t)).join(",");e.set("language",i)}function De(e){const n=e===S.AUTO.flag?O():typeof e=="string"?D(e):j(e)?e.flag===S.AUTO.flag?O():N(e.flag):null;return n?.geocoding?n.code:null}function ie(e,n){const{apiKey:a,limit:t,types:i,excludeTypes:o}=n;e.set("key",a??m.apiKey),t!==void 0&&e.set("limit",String(t)),i!==void 0&&e.set("types",i.join(",")),o!==void 0&&e.set("excludeTypes",String(o)),te(e,n)}function oe(e,n){ie(e,n);const{bbox:a,proximity:t,country:i,fuzzyMatch:o,autocomplete:r}=n;a!==void 0&&e.set("bbox",a.join(",")),t!==void 0&&e.set("proximity",t==="ip"?t:t.join(",")),i!==void 0&&e.set("country",i.join(",")),o!==void 0&&e.set("fuzzyMatch",o?"true":"false"),r!==void 0&&e.set("autocomplete",r?"true":"false")}async function ke(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new Error("The query must be a non-empty string");const a=new URL(`geocoding/${encodeURIComponent(e)}.json`,y.maptilerApiURL);oe(a.searchParams,n);const t=await I(a.toString());if(!t.ok)throw new L(t,P[t.status]??"");return await t.json()}async function Ne(e,n={}){if(!Array.isArray(e)||e.length<2)throw new Error("The position must be an array of form [lng, lat].");const a=new URL(`geocoding/${e[0]},${e[1]}.json`,y.maptilerApiURL);ie(a.searchParams,n);const t=await I(a.toString());if(!t.ok)throw new L(t,P[t.status]??"");return await t.json()}async function Pe(e,n={}){const a=new URL(`geocoding/${e}.json`,y.maptilerApiURL);a.searchParams.set("key",n.apiKey??m.apiKey),te(a.searchParams,n);const t=await I(a.toString());if(!t.ok)throw new L(t,P[t.status]??"");return await t.json()}async function $e(e,n={}){if(!e.length)return[];const a=e.map(r=>encodeURIComponent(r)).join(";"),t=new URL(`geocoding/${a}.json`,y.maptilerApiURL);oe(t.searchParams,n);const i=await I(t.toString());if(!i.ok)throw new L(i,P[i.status]??"");const o=await i.json();return e.length===1?[o]:o}const be={forward:ke,reverse:Ne,byId:Pe,batch:$e},re={403:"Key is missing, invalid or restricted"};async function Ce(e={}){const n=new URL("geolocation/ip.json",y.maptilerApiURL);n.searchParams.set("key",e.apiKey??m.apiKey);const a=n.toString(),t=await I(a);if(!t.ok)throw new L(t,t.status in re?re[t.status]:"");return await t.json()}const Ke={info:Ce},$={403:"Key is missing, invalid or restricted"};async function Oe(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new Error("The query must be a non-empty string");const a=new URL(`coordinates/search/${e}.json`,y.maptilerApiURL);a.searchParams.set("key",n.apiKey??m.apiKey),"limit"in n&&a.searchParams.set("limit",n.limit.toString()),"transformations"in n&&a.searchParams.set("transformations",n.transformations.toString()),"exports"in n&&a.searchParams.set("exports",n.exports.toString());const t=a.toString(),i=await I(t);if(!i.ok)throw new L(i,i.status in $?$[i.status]:"");return await i.json()}async function je(e,n={}){const a=(Array.isArray(e[0])?e:[e]).map(r=>`${r[0]},${r[1]}`).join(";"),t=new URL(`coordinates/transform/${a}.json`,y.maptilerApiURL);t.searchParams.set("key",n.apiKey??m.apiKey),"sourceCrs"in n&&t.searchParams.set("s_srs",n.sourceCrs.toString()),"targetCrs"in n&&t.searchParams.set("t_srs",n.targetCrs.toString()),"operations"in n&&t.searchParams.set("ops",(Array.isArray(n.operations)?n.operations:[n.operations]).join("|"));const i=t.toString(),o=await I(i);if(!o.ok)throw new L(o,o.status in $?$[o.status]:"");return await o.json()}const He={search:Oe,transform:je},se={403:"Key is missing, invalid or restricted"};async function xe(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new Error("The data ID must be a non-empty string");const a=new URL(`data/${encodeURIComponent(e)}/features.json`,y.maptilerApiURL);a.searchParams.set("key",n.apiKey??m.apiKey);const t=a.toString(),i=await I(t);if(!i.ok)throw new L(i,i.status in se?se[i.status]:"");return await i.json()}const Fe={get:xe};function ce(e){const n=/^maptiler:\/\/(.*)/;let a;const t=e.trim();let i;return t.startsWith("http://")||t.startsWith("https://")?i=t:(a=n.exec(t))!==null?i=`https://api.maptiler.com/maps/${a[1]}/style.json`:i=`https://api.maptiler.com/maps/${t}/style.json`,i}class x{constructor(n,a,t,i,o,r){this.name=n,this.variantType=a,this.id=t,this.referenceStyle=i,this.description=o,this.imageURL=r}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(n){return this.referenceStyle.hasVariant(n)}getVariant(n){return this.referenceStyle.getVariant(n)}getVariants(){return this.referenceStyle.getVariants().filter(n=>n!==this)}getImageURL(){return this.imageURL}getExpandedStyleURL(){return ce(this.getId())}}class F{constructor(n,a){this.name=n,this.id=a,this.variants={},this.orderedVariants=[]}getName(){return this.name}getId(){return this.id}addVariant(n){this.variants[n.getType()]=n,this.orderedVariants.push(n)}hasVariant(n){return n in this.variants}getVariant(n){return n in this.variants?this.variants[n]:this.orderedVariants[0]}getVariants(){return Object.values(this.variants)}getDefaultVariant(){return this.orderedVariants[0]}}const b=[{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:"BACKDROP",name:"Backdrop",description:"",variants:[{id:"backdrop",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"backdrop-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"backdrop-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"OCEAN",name:"Ocean",description:"",variants:[{id:"ocean",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"AQUARELLE",name:"Aquarelle",description:"Watercolor map for creative use",variants:[{id:"aquarelle",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"aquarelle-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"aquarelle-vivid",name:"Vivid",variantType:"VIVID",description:"",imageURL:""}]},{referenceStyleID:"LANDSCAPE",name:"Landscape",description:"Terrain map for data overlays and visualisations",variants:[{id:"landscape",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"landscape-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"landscape-vivid",name:"Vivid",variantType:"VIVID",description:"",imageURL:""}]}];function Ve(e){return new Proxy(e,{get(n,a,t){return n.hasVariant(a)?n.getVariant(a):a.toString().toUpperCase()===a?e.getDefaultVariant():Reflect.get(n,a,t)}})}function _e(){const e={};for(let n=0;n<b.length;n+=1){const a=b[n],t=Ve(new F(a.name,a.referenceStyleID));for(let i=0;i<a.variants.length;i+=1){const o=a.variants[i],r=new x(o.name,o.variantType,o.id,t,o.description,o.imageURL);t.addVariant(r)}e[a.referenceStyleID]=t}return e}function C(e){if(!e)return le[b[0].referenceStyleID].getDefaultVariant().getId();if(typeof e=="string"||e instanceof String)return e.trim().toLowerCase();if(e instanceof x)return e.getId();if(e instanceof F)return e.getDefaultVariant().getId()}const le=_e();function Be(e){const n=[];function a(o){(o.type==="LineString"||o.type==="MultiLineString")&&n.push(o)}function t(o){o.geometry&&a(o.geometry)}function i(o){for(const r of o.features)r.type==="Feature"?t(r):r.type==="FeatureCollection"&&i(r)}return e.type==="Feature"?t(e):e.type==="FeatureCollection"?i(e):a(e),n}function Ge(e,n,a){let t=n[0],i=n[1],o=a[0]-t,r=a[1]-i;if(o!==0||r!==0){const s=((e[0]-t)*o+(e[1]-i)*r)/(o*o+r*r);s>1?(t=a[0],i=a[1]):s>0&&(t+=o*s,i+=r*s)}return o=e[0]-t,r=e[1]-i,o*o+r*r}function V(e,n,a,t,i){let o=t,r;for(let s=n+1;s<a;s++){const c=Ge(e[s],e[n],e[a]);c>o&&(r=s,o=c)}o>t&&(r-n>1&&V(e,n,r,t,i),i.push(e[r]),a-r>1&&V(e,r,a,t,i))}function ze(e,n){const a=e.length-1,t=[e[0]];return V(e,0,a,n,t),t.push(e[a]),t}function We(e,n){if(e.length<=2)return e;const a=n!==void 0?n*n:1;return ze(e,a)}const ge={extractLineStrings:Be,simplify:We};function _(e,n=!0){let a=`${e[0]},${e[1]}`;return e.length===3&&n&&(a+=`,${e[2]}`),a}function B(e,n=3e3){let a=e.map(o=>o.join(",")).join("|"),t=5e-6;const i=1e-5;for(;a.length>n;)a=ge.simplify(e,t).map(o=>`${o[0]},${o[1]}`).join("|"),t+=i;return a}function Je(e,n,a={}){const t=C(a.style),i=a.hiDPI?"@2x":"",o=a.format??"png";let r=~~(a.width??1024),s=~~(a.height??1024);a.hiDPI&&(r=~~(r/2),s=~~(s/2));const c=new URL(`maps/${encodeURIComponent(t)}/static/${e[0]},${e[1]},${n}/${r}x${s}${i}.${o}`,y.maptilerApiURL);if("attribution"in a&&c.searchParams.set("attribution",a.attribution.toString()),"markers"in a){let g="";const d="markerIcon"in a;d&&(g+=`icon:${a.markerIcon}|`),d&&"markerAnchor"in a&&(g+=`anchor:${a.markerAnchor}|`),d&&a.hiDPI&&(g+="scale:2|");const A=Array.isArray(a.markers[0])?a.markers:[a.markers];g+=A.map(f=>_(f,!d)).join("|"),c.searchParams.set("markers",g)}if("path"in a){let g="";if(g+=`fill:${a.pathFillColor??"none"}|`,"pathStrokeColor"in a&&(g+=`stroke:${a.pathStrokeColor}|`),"pathWidth"in a){const d=a.pathWidth/(a.hiDPI?2:1);g+=`width:${d.toString()}|`}g+=B(a.path),c.searchParams.set("path",g)}return c.searchParams.set("key",a.apiKey??m.apiKey),c.toString()}function qe(e,n={}){const a=C(n.style),t=n.hiDPI?"@2x":"",i=n.format??"png";let o=~~(n.width??1024),r=~~(n.height??1024);n.hiDPI&&(o=~~(o/2),r=~~(r/2));const s=new URL(`maps/${encodeURIComponent(a)}/static/${e[0]},${e[1]},${e[2]},${e[3]}/${o}x${r}${t}.${i}`,y.maptilerApiURL);if("attribution"in n&&s.searchParams.set("attribution",n.attribution.toString()),"padding"in n&&s.searchParams.set("padding",n.padding.toString()),"markers"in n){let c="";const g="markerIcon"in n;g&&(c+=`icon:${n.markerIcon}|`),g&&"markerAnchor"in n&&(c+=`anchor:${n.markerAnchor}|`),g&&n.hiDPI&&(c+="scale:2|");const d=Array.isArray(n.markers[0])?n.markers:[n.markers];c+=d.map(A=>_(A,!g)).join("|"),s.searchParams.set("markers",c)}if("path"in n){let c="";if(c+=`fill:${n.pathFillColor??"none"}|`,"pathStrokeColor"in n&&(c+=`stroke:${n.pathStrokeColor}|`),"pathWidth"in n){const g=n.pathWidth/(n.hiDPI?2:1);c+=`width:${g.toString()}|`}c+=B(n.path),s.searchParams.set("path",c)}return s.searchParams.set("key",n.apiKey??m.apiKey),s.toString()}function Ye(e={}){if(!("markers"in e)&&!("path"in e))throw new Error("Automatic static maps require markers and/or path to be created.");const n=C(e.style),a=e.hiDPI?"@2x":"",t=e.format??"png";let i=~~(e.width??1024),o=~~(e.height??1024);e.hiDPI&&(i=~~(i/2),o=~~(o/2));const r=new URL(`maps/${encodeURIComponent(n)}/static/auto/${i}x${o}${a}.${t}`,y.maptilerApiURL);if("attribution"in e&&r.searchParams.set("attribution",e.attribution.toString()),"padding"in e&&r.searchParams.set("padding",e.padding.toString()),"markers"in e){let s="";const c="markerIcon"in e;c&&(s+=`icon:${e.markerIcon}|`),c&&"markerAnchor"in e&&(s+=`anchor:${e.markerAnchor}|`),c&&e.hiDPI&&(s+="scale:2|");const g=Array.isArray(e.markers[0])?e.markers:[e.markers];s+=g.map(d=>_(d,!c)).join("|"),r.searchParams.set("markers",s)}if("path"in e){let s="";if(s+=`fill:${e.pathFillColor??"none"}|`,"pathStrokeColor"in e&&(s+=`stroke:${e.pathStrokeColor}|`),"pathWidth"in e){const c=e.pathWidth/(e.hiDPI?2:1);s+=`width:${c.toString()}|`}s+=B(e.path),r.searchParams.set("path",s)}return r.searchParams.set("key",e.apiKey??m.apiKey),r.toString()}const Qe={centered:Je,bounded:qe,automatic:Ye},K=63710088e-1,de=2*Math.PI*K;function me(e){return(180+e)/360}function pe(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function fe(e){const n=ye(e);return[me(n[0]),pe(n[1])]}function he(e){return e*360-180}function ue(e){const n=180-e*360;return 360/Math.PI*Math.atan(Math.exp(n*Math.PI/180))-90}function Ze(e){return[he(e[0]),ue(e[1])]}function G(e,n){const a=Math.PI/180,t=e[1]*a,i=n[1]*a,o=Math.sin(t)*Math.sin(i)+Math.cos(t)*Math.cos(i)*Math.cos((n[0]-e[0])*a);return K*Math.acos(Math.min(o,1))}function Xe(e){const n=Array(e.length);n[0]=0;const a=n.length;for(let t=1;t<a;t++)n[t]=G(e[t-1],e[t])+n[t-1];return n}function ye(e){const n=e[0],a=e[1],t=360,i=((n+180)%t+t)%t-180;return[i===-180?180:i,a]}function Ae(e){return de*Math.cos(e*Math.PI/180)}function Le(e,n,a=!0){const t=2**n,i=[e[0]*t,e[1]*t];return a?[~~i[0],~~i[1]]:i}function en(e,n,a=!0){const t=fe(e);return Le(t,n,a)}function k(e){return e*Math.PI/180}function z(e){return e*180/Math.PI}function nn(e,n,a){const t=G(e,n),i=k(e[0]),o=k(e[1]),r=k(n[0]),s=k(n[1]),c=t/K,g=Math.sin((1-a)*c)/Math.sin(c),d=Math.sin(a*c)/Math.sin(c),A=g*Math.cos(o)*Math.cos(i)+d*Math.cos(s)*Math.cos(r),f=g*Math.cos(o)*Math.sin(i)+d*Math.cos(s)*Math.sin(r),M=g*Math.sin(o)+d*Math.sin(s),w=Math.atan2(M,Math.sqrt(A*A+f*f)),R=Math.atan2(f,A);return[z(R),z(w)]}const W={EARTH_RADIUS:K,EARTH_CIRCUMFERENCE:de,longitudeToMercatorX:me,latitudeToMercatorY:pe,wgs84ToMercator:fe,mercatorXToLongitude:he,mercatorYToLatitude:ue,mercatorToWgs84:Ze,haversineDistanceWgs84:G,wrapWgs84:ye,circumferenceAtLatitude:Ae,mercatorToTileIndex:Le,wgs84ToTileIndex:en,toRadians:k,toDegrees:z,haversineIntermediateWgs84:nn,haversineCumulatedDistanceWgs84:Xe};let J=null;function q(){return J||(J=new we({maxSize:m.tileCacheSize})),J}async function Ie(e){const n=new Blob([e]),a=await createImageBitmap(n),t=document.createElement("canvas"),i=t.getContext("2d");t.width=a.width,t.height=a.height,i.drawImage(a,0,0);const o=i.getImageData(0,0,t.width,t.height);return{pixels:o.data,width:t.width,height:t.height,components:o.data.length/(t.width*t.height)}}function Y(){if(m.bufferToPixelData)return m.bufferToPixelData;if(typeof window<"u")return Ie;throw new Error("An image file buffer to pixel data parser is necessary. Specify it in `config.bufferToPixelData`")}const an="tiles/terrain-rgb-v2/tiles.json";let v=null;const Q={403:"Key is missing, invalid or restricted"};async function Se(e){const n=new URL(an,y.maptilerApiURL);n.searchParams.set("key",e);const a=n.toString(),t=await I(a);if(t.ok)return v=await t.json(),v;if(!t.ok)throw new L(t,Q[t.status]??"")}async function tn(e,n={}){const a=n.apiKey??m.apiKey;v||await Se(a);const t=v.maxzoom;let i=~~(n.zoom??t);(i>t||i<0)&&(i=t);const o=W.wgs84ToTileIndex(e,i,!1),r=~~o[0],s=~~o[1];if(!v.tiles.length)throw new Error("Terrain tileJSON tile list is empty.");const c=`terrain_${i.toString()}_${r.toString()}_${s.toString()}`;let g;const d=q();if(d.has(c))g=d.get(c);else{const T=v.tiles[0].replace("{x}",r.toString()).replace("{y}",s.toString()).replace("{z}",i.toString()),p=await I(T);if(!p.ok)throw new L(p,Q[p.status]??"");const h=await p.arrayBuffer();g=await Y()(h),d.set(c,g)}const A=~~(g.width*(o[0]%1)),f=(~~(g.height*(o[1]%1))*g.width+A)*g.components,M=g.pixels[f],w=g.pixels[f+1],R=g.pixels[f+2],l=-1e4+(M*256*256+w*256+R)*.1;return[e[0],e[1],l]}async function Z(e,n={}){const a=n.apiKey??m.apiKey;v||await Se(a);const t=Y(),i=v.tiles[0],o=q(),r=v.maxzoom;let s=~~(n.zoom??r);(s>r||s<0)&&(s=r);const c=e.map(l=>W.wgs84ToTileIndex(l,s,!1)),g=c.map(l=>[~~l[0],~~l[1]]).map(l=>`terrain_${s.toString()}_${l[0].toString()}_${l[1].toString()}`),d=Array.from(new Set(g.filter(l=>!o.has(l)))).map(l=>l.split("_").slice(1)),A=d.map(l=>i.replace("{x}",l[1].toString()).replace("{y}",l[2].toString()).replace("{z}",l[0].toString())).map(l=>I(l)),f=(await Promise.allSettled(A)).map(l=>l.status==="fulfilled"?l.value:null).filter(l=>l),M=f.filter(l=>!l.ok);if(f.length!==A.length)throw new Error("Some tiles could not be fetched.");if(M.length)throw new L(M[0],Q[M[0].status]??"");const w=await Promise.all(f.map(l=>l.arrayBuffer()));if(!w.every(l=>l.byteLength>0))throw new Error("Some tiles are not available.");(await Promise.all(w.map(l=>t(l)))).forEach((l,T)=>{const p=d[T],h=`terrain_${p[0].toString()}_${p[1].toString()}_${p[2].toString()}`;o.set(h,l)});const R=e.map((l,T)=>{const p=g[T],h=c[T],u=o.get(p),U=Math.min(Math.round(u.width*(h[0]%1)),u.width-1),E=(Math.min(Math.round(u.height*(h[1]%1)),u.height-1)*u.width+U)*u.components,Te=u.pixels[E],ve=u.pixels[E+1],Me=u.pixels[E+2],Re=-1e4+(Te*256*256+ve*256+Me)*.1;return[l[0],l[1],~~(Re*1e3)/1e3]});if(n.smoothingKernelSize){const l=~~(n.smoothingKernelSize/2)*2+1,T=R.map(h=>h[2]),p=~~(l/2);for(let h=p;h<T.length-p-1;h+=1){let u=0;for(let U=0;U<l;U+=1){const E=T[h-p+U];u+=E}u/=l,R[h][2]=u}}return R}async function on(e,n={}){if(e.type!=="LineString")throw new Error("The provided object is not a GeoJSON LineString");const a=structuredClone(e),t=await Z(a.coordinates,n);return a.coordinates=t,a}async function rn(e,n={}){if(e.type!=="MultiLineString")throw new Error("The provided object is not a GeoJSON MultiLineString");const a=structuredClone(e),t=a.coordinates.map(c=>c.length),i=a.coordinates.flat(),o=await Z(i,n),r=[];let s=0;for(const c of t)r.push(o.slice(s,s+c)),s+=c;return a.coordinates=r,a}const sn={at:tn,batch:Z,fromLineString:on,fromMultiLineString:rn};export{X as ClientConfig,ne as ISOLanguage,S as Language,le as MapStyle,x as MapStyleVariant,ee as NonISOLanguage,F as ReferenceMapStyle,L as ServiceError,Ee as areSameLanguages,Ie as bufferToPixelDataBrowser,Ae as circumferenceAtLatitude,m as config,He as coordinates,Fe as data,sn as elevation,ce as expandMapStyle,be as geocoding,Ke as geolocation,O as getAutoLanguage,Y as getBufferToPixelDataParser,D as getLanguageInfoFromCode,N as getLanguageInfoFromFlag,ae as getLanguageInfoFromKey,q as getTileCache,j as isLanguageInfo,b as mapStylePresetList,W as math,ge as misc,Qe as staticMaps,C as styleToStyle,H as toLanguageInfo};
|
package/dist/maptiler-client.mjs
CHANGED
|
@@ -121,7 +121,7 @@ const ISOLanguage = {
|
|
|
121
121
|
name: "Amharic",
|
|
122
122
|
latin: false,
|
|
123
123
|
isMode: false,
|
|
124
|
-
geocoding:
|
|
124
|
+
geocoding: true
|
|
125
125
|
},
|
|
126
126
|
/**
|
|
127
127
|
* Arabic language (right-to-left script)
|
|
@@ -165,7 +165,7 @@ const ISOLanguage = {
|
|
|
165
165
|
name: "Basque",
|
|
166
166
|
latin: true,
|
|
167
167
|
isMode: false,
|
|
168
|
-
geocoding:
|
|
168
|
+
geocoding: true
|
|
169
169
|
},
|
|
170
170
|
/**
|
|
171
171
|
* Belarusian langauge
|
|
@@ -187,7 +187,7 @@ const ISOLanguage = {
|
|
|
187
187
|
name: "Bengali",
|
|
188
188
|
latin: true,
|
|
189
189
|
isMode: false,
|
|
190
|
-
geocoding:
|
|
190
|
+
geocoding: true
|
|
191
191
|
},
|
|
192
192
|
/**
|
|
193
193
|
* Bosnian language
|
|
@@ -275,7 +275,7 @@ const ISOLanguage = {
|
|
|
275
275
|
name: "Corsican",
|
|
276
276
|
latin: true,
|
|
277
277
|
isMode: false,
|
|
278
|
-
geocoding:
|
|
278
|
+
geocoding: true
|
|
279
279
|
},
|
|
280
280
|
/**
|
|
281
281
|
* Croatian language
|
|
@@ -440,7 +440,7 @@ const ISOLanguage = {
|
|
|
440
440
|
name: "Hindi",
|
|
441
441
|
latin: false,
|
|
442
442
|
isMode: false,
|
|
443
|
-
geocoding:
|
|
443
|
+
geocoding: true
|
|
444
444
|
},
|
|
445
445
|
/**
|
|
446
446
|
* Hungarian language
|
|
@@ -473,7 +473,7 @@ const ISOLanguage = {
|
|
|
473
473
|
name: "Indonesian",
|
|
474
474
|
latin: true,
|
|
475
475
|
isMode: false,
|
|
476
|
-
geocoding:
|
|
476
|
+
geocoding: true
|
|
477
477
|
},
|
|
478
478
|
/**
|
|
479
479
|
* Irish language
|
|
@@ -605,7 +605,7 @@ const ISOLanguage = {
|
|
|
605
605
|
name: "Kurdish",
|
|
606
606
|
latin: true,
|
|
607
607
|
isMode: false,
|
|
608
|
-
geocoding:
|
|
608
|
+
geocoding: true
|
|
609
609
|
},
|
|
610
610
|
/**
|
|
611
611
|
* Classical Latin language
|
|
@@ -671,7 +671,7 @@ const ISOLanguage = {
|
|
|
671
671
|
name: "Malayalam",
|
|
672
672
|
latin: false,
|
|
673
673
|
isMode: false,
|
|
674
|
-
geocoding:
|
|
674
|
+
geocoding: true
|
|
675
675
|
},
|
|
676
676
|
/**
|
|
677
677
|
* Maltese language
|
|
@@ -704,7 +704,7 @@ const ISOLanguage = {
|
|
|
704
704
|
name: "Occitan",
|
|
705
705
|
latin: true,
|
|
706
706
|
isMode: false,
|
|
707
|
-
geocoding:
|
|
707
|
+
geocoding: true
|
|
708
708
|
},
|
|
709
709
|
/**
|
|
710
710
|
* Persian language
|
|
@@ -715,7 +715,7 @@ const ISOLanguage = {
|
|
|
715
715
|
name: "Persian",
|
|
716
716
|
latin: false,
|
|
717
717
|
isMode: false,
|
|
718
|
-
geocoding:
|
|
718
|
+
geocoding: true
|
|
719
719
|
},
|
|
720
720
|
/**
|
|
721
721
|
* Polish language
|
|
@@ -748,7 +748,7 @@ const ISOLanguage = {
|
|
|
748
748
|
name: "Punjabi",
|
|
749
749
|
latin: false,
|
|
750
750
|
isMode: false,
|
|
751
|
-
geocoding:
|
|
751
|
+
geocoding: true
|
|
752
752
|
},
|
|
753
753
|
/**
|
|
754
754
|
* Western Punjabi language
|
|
@@ -880,7 +880,7 @@ const ISOLanguage = {
|
|
|
880
880
|
name: "Tamil",
|
|
881
881
|
latin: false,
|
|
882
882
|
isMode: false,
|
|
883
|
-
geocoding:
|
|
883
|
+
geocoding: true
|
|
884
884
|
},
|
|
885
885
|
/**
|
|
886
886
|
* Telugu language
|
|
@@ -891,7 +891,7 @@ const ISOLanguage = {
|
|
|
891
891
|
name: "Telugu",
|
|
892
892
|
latin: false,
|
|
893
893
|
isMode: false,
|
|
894
|
-
geocoding:
|
|
894
|
+
geocoding: true
|
|
895
895
|
},
|
|
896
896
|
/**
|
|
897
897
|
* Thai language
|
|
@@ -935,7 +935,7 @@ const ISOLanguage = {
|
|
|
935
935
|
name: "Vietnamese (Latin script)",
|
|
936
936
|
latin: true,
|
|
937
937
|
isMode: false,
|
|
938
|
-
geocoding:
|
|
938
|
+
geocoding: true
|
|
939
939
|
},
|
|
940
940
|
/**
|
|
941
941
|
* Welsh language
|
|
@@ -1806,6 +1806,62 @@ const mapStylePresetList = [
|
|
|
1806
1806
|
imageURL: ""
|
|
1807
1807
|
}
|
|
1808
1808
|
]
|
|
1809
|
+
},
|
|
1810
|
+
{
|
|
1811
|
+
referenceStyleID: "AQUARELLE",
|
|
1812
|
+
name: "Aquarelle",
|
|
1813
|
+
description: "Watercolor map for creative use",
|
|
1814
|
+
variants: [
|
|
1815
|
+
{
|
|
1816
|
+
id: "aquarelle",
|
|
1817
|
+
name: "Default",
|
|
1818
|
+
variantType: "DEFAULT",
|
|
1819
|
+
description: "",
|
|
1820
|
+
imageURL: ""
|
|
1821
|
+
},
|
|
1822
|
+
{
|
|
1823
|
+
id: "aquarelle-dark",
|
|
1824
|
+
name: "Dark",
|
|
1825
|
+
variantType: "DARK",
|
|
1826
|
+
description: "",
|
|
1827
|
+
imageURL: ""
|
|
1828
|
+
},
|
|
1829
|
+
{
|
|
1830
|
+
id: "aquarelle-vivid",
|
|
1831
|
+
name: "Vivid",
|
|
1832
|
+
variantType: "VIVID",
|
|
1833
|
+
description: "",
|
|
1834
|
+
imageURL: ""
|
|
1835
|
+
}
|
|
1836
|
+
]
|
|
1837
|
+
},
|
|
1838
|
+
{
|
|
1839
|
+
referenceStyleID: "LANDSCAPE",
|
|
1840
|
+
name: "Landscape",
|
|
1841
|
+
description: "Terrain map for data overlays and visualisations",
|
|
1842
|
+
variants: [
|
|
1843
|
+
{
|
|
1844
|
+
id: "landscape",
|
|
1845
|
+
name: "Default",
|
|
1846
|
+
variantType: "DEFAULT",
|
|
1847
|
+
description: "",
|
|
1848
|
+
imageURL: ""
|
|
1849
|
+
},
|
|
1850
|
+
{
|
|
1851
|
+
id: "landscape-dark",
|
|
1852
|
+
name: "Dark",
|
|
1853
|
+
variantType: "DARK",
|
|
1854
|
+
description: "",
|
|
1855
|
+
imageURL: ""
|
|
1856
|
+
},
|
|
1857
|
+
{
|
|
1858
|
+
id: "landscape-vivid",
|
|
1859
|
+
name: "Vivid",
|
|
1860
|
+
variantType: "VIVID",
|
|
1861
|
+
description: "",
|
|
1862
|
+
imageURL: ""
|
|
1863
|
+
}
|
|
1864
|
+
]
|
|
1809
1865
|
}
|
|
1810
1866
|
];
|
|
1811
1867
|
function makeReferenceStyleProxy(referenceStyle) {
|