@maptiler/sdk 1.0.11 → 1.1.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.
@@ -1 +1 @@
1
- import a from"maplibre-gl";export*from"maplibre-gl";import{Base64 as W}from"js-base64";import{v4 as J}from"uuid";import Z from"events";import{config as T,expandMapStyle as Y,MapStyleVariant as X,ReferenceMapStyle as Q,MapStyle as tt,mapStylePresetList as et,geolocation as w}from"@maptiler/client";import{LanguageGeocoding as me,MapStyle as ye,MapStyleVariant as Ae,ReferenceMapStyle as fe,ServiceError as Le,coordinates as _e,data as Se,geocoding as xe,geolocation as Ce,staticMaps as Te}from"@maptiler/client";const L={AUTO:"auto",LATIN:"latin",NON_LATIN:"nonlatin",LOCAL:"",ALBANIAN:"sq",AMHARIC:"am",ARABIC:"ar",ARMENIAN:"hy",AZERBAIJANI:"az",BASQUE:"eu",BELORUSSIAN:"be",BOSNIAN:"bs",BRETON:"br",BULGARIAN:"bg",CATALAN:"ca",CHINESE:"zh",CORSICAN:"co",CROATIAN:"hr",CZECH:"cs",DANISH:"da",DUTCH:"nl",ENGLISH:"en",ESPERANTO:"eo",ESTONIAN:"et",FINNISH:"fi",FRENCH:"fr",FRISIAN:"fy",GEORGIAN:"ka",GERMAN:"de",GREEK:"el",HEBREW:"he",HINDI:"hi",HUNGARIAN:"hu",ICELANDIC:"is",INDONESIAN:"id",IRISH:"ga",ITALIAN:"it",JAPANESE:"ja",JAPANESE_HIRAGANA:"ja-Hira",JAPANESE_KANA:"ja_kana",JAPANESE_LATIN:"ja_rm",JAPANESE_2018:"ja-Latn",KANNADA:"kn",KAZAKH:"kk",KOREAN:"ko",KOREAN_LATIN:"ko-Latn",KURDISH:"ku",ROMAN_LATIN:"la",LATVIAN:"lv",LITHUANIAN:"lt",LUXEMBOURGISH:"lb",MACEDONIAN:"mk",MALAYALAM:"ml",MALTESE:"mt",NORWEGIAN:"no",OCCITAN:"oc",POLISH:"pl",PORTUGUESE:"pt",ROMANIAN:"ro",ROMANSH:"rm",RUSSIAN:"ru",SCOTTISH_GAELIC:"gd",SERBIAN_CYRILLIC:"sr",SERBIAN_LATIN:"sr-Latn",SLOVAK:"sk",SLOVENE:"sl",SPANISH:"es",SWEDISH:"sv",TAMIL:"ta",TELUGU:"te",THAI:"th",TURKISH:"tr",UKRAINIAN:"uk",WELSH:"cy"},rt=new Set(Object.values(L));function v(r){return rt.has(r)}const it=new Set(Object.values(L));function b(){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=>it.has(t));return r.length?r[0]:L.LATIN}let E=class extends Z{constructor(){super(),this.primaryLanguage=L.AUTO,this.secondaryLanguage=null,this.session=!0,this._unit="metric",this._apiKey=""}set unit(t){this._unit=t,this.emit("unit",t)}get unit(){return this._unit}set apiKey(t){this._apiKey=t,T.apiKey=t,this.emit("apiKey",t)}get apiKey(){return this._apiKey}set fetch(t){T.fetch=t}get fetch(){return T.fetch}};const A=new E,y={maptilerLogoURL:"https://api.maptiler.com/resources/logo.svg",maptilerURL:"https://www.maptiler.com/",maptilerApiHost:"api.maptiler.com",rtlPluginURL:"https://cdn.maptiler.com/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.min.js",primaryLanguage:L.AUTO,secondaryLanguage:L.LOCAL,terrainSourceURL:"https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json",terrainSourceId:"maptiler-terrain"};Object.freeze(y);class N extends a.LogoControl{onAdd(t){return super.onAdd(t)}}class I extends N{constructor(t={}){var e,n;super(t),this.logoURL="",this.linkURL="",this.logoURL=(e=t.logoURL)!=null?e:y.maptilerLogoURL,this.linkURL=(n=t.linkURL)!=null?n:y.maptilerURL}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=window.document.createElement("div"),this._container.className="maplibregl-ctrl";const e=window.document.createElement("a");return e.style.backgroundRepeat="no-repeat",e.style.cursor="pointer",e.style.display="block",e.style.height="23px",e.style.margin="0 0 -4px -4px",e.style.overflow="hidden",e.style.width="88px",e.style.backgroundImage=`url(${this.logoURL})`,e.style.backgroundSize="100px 30px",e.style.width="100px",e.style.height="30px",e.target="_blank",e.rel="noopener nofollow",e.href=this.linkURL,e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}}function nt(){a.getRTLTextPluginStatus()==="unavailable"&&a.setRTLTextPlugin(y.rtlPluginURL,null,!0)}function at(r,t){r.forEach(e=>{t[e]&&(t[e]=t[e].bind(t))})}function S(r,t,e){const n=window.document.createElement(r);return t!==void 0&&(n.className=t),e&&e.appendChild(n),n}function ot(r){r.parentNode&&r.parentNode.removeChild(r)}function R(r){return r?typeof r=="string"||r instanceof String?!r.startsWith("http")&&r.toLowerCase().includes(".json")?r:Y(r):r instanceof X?r.getExpandedStyleURL():r instanceof Q?r.getDefaultVariant().getExpandedStyleURL():r:tt[et[0].referenceStyleID].getDefaultVariant().getExpandedStyleURL()}class P{constructor(){at(["_toggleTerrain","_updateTerrainIcon"],this)}onAdd(t){return this._map=t,this._container=S("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=S("button","maplibregl-ctrl-terrain",this._container),S("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){ot(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}_toggleTerrain(){this._map.hasTerrain()?this._map.disableTerrain():this._map.enableTerrain(),this._updateTerrainIcon()}_updateTerrainIcon(){this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.hasTerrain()?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"))}}class M extends a.NavigationControl{onAdd(t){return super.onAdd(t)}}class O extends M{constructor(){super({showCompass:!0,showZoom:!0,visualizePitch:!0}),this._compass.removeEventListener("click",this._compass.clickFunction),this._compass.addEventListener("click",t=>{this._map.getPitch()===0?this._map.easeTo({pitch:Math.min(this._map.getMaxPitch(),80)}):this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})}_createButton(t,e){const n=super._createButton(t,e);return n.clickFunction=e,n}_rotateCompassArrow(){const t=this.options.visualizePitch?`scale(${Math.min(1.5,1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5))}) rotateX(${Math.min(70,this._map.transform.pitch)}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=t}}class U extends a.GeolocateControl{onAdd(t){return super.onAdd(t)}}var st=Object.defineProperty,lt=Object.defineProperties,ct=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,ht=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable,B=(r,t,e)=>t in r?st(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,dt=(r,t)=>{for(var e in t||(t={}))ht.call(t,e)&&B(r,e,t[e]);if(k)for(var e of k(t))ut.call(t,e)&&B(r,e,t[e]);return r},gt=(r,t)=>lt(r,ct(t));const $=a.Marker,G=a.LngLat;class H extends U{constructor(){super(...arguments),this.lastUpdatedCenter=new G(0,0)}_updateCamera(t){const e=new G(t.coords.longitude,t.coords.latitude),n=t.coords.accuracy,s=this._map.getBearing(),d=gt(dt({bearing:s},this.options.fitBoundsOptions),{linear:!0}),u=this._map.getZoom();u>this.options.fitBoundsOptions.maxZoom&&(d.zoom=u),this._map.fitBounds(e.toBounds(n),d,{geolocateSource:!0});let h=!1;const o=()=>{h=!0};this._map.once("click",o),this._map.once("dblclick",o),this._map.once("dragstart",o),this._map.once("mousedown",o),this._map.once("touchstart",o),this._map.once("wheel",o),this._map.once("moveend",()=>{this._map.off("click",o),this._map.off("dblclick",o),this._map.off("dragstart",o),this._map.off("mousedown",o),this._map.off("touchstart",o),this._map.off("wheel",o),!h&&(this.lastUpdatedCenter=this._map.getCenter())})}_setupUI(t){if(this.lastUpdatedCenter=this._map.getCenter(),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=S("button","maplibregl-ctrl-geolocate",this._container),S("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",t===!1){const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=S("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new $(this._dotElement),this._circleElement=S("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new $({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("move",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("moveend",e=>{const n=e.originalEvent&&e.originalEvent.type==="resize",s=this.lastUpdatedCenter.distanceTo(this._map.getCenter());!e.geolocateSource&&this._watchState==="ACTIVE_LOCK"&&!n&&s>1&&(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new Event("trackuserlocationend")))})}_updateCircleRadius(){if(this._watchState!=="BACKGROUND"&&this._watchState!=="ACTIVE_LOCK")return;const t=[this._lastKnownPosition.coords.longitude,this._lastKnownPosition.coords.latitude],e=this._map.project(t),n=this._map.unproject([e.x,e.y]),s=this._map.unproject([e.x+20,e.y]),d=n.distanceTo(s)/20,u=Math.ceil(2*this._accuracy/d);this._circleElement.style.width=`${u}px`,this._circleElement.style.height=`${u}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}}class j extends a.AttributionControl{onAdd(t){return super.onAdd(t)}}class K extends a.ScaleControl{onAdd(t){return super.onAdd(t)}}class F extends a.FullscreenControl{onAdd(t){return super.onAdd(t)}}var pt=Object.defineProperty,mt=Object.defineProperties,yt=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,At=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable,V=(r,t,e)=>t in r?pt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Lt=(r,t)=>{for(var e in t||(t={}))At.call(t,e)&&V(r,e,t[e]);if(D)for(var e of D(t))ft.call(t,e)&&V(r,e,t[e]);return r},_t=(r,t)=>mt(r,yt(t)),_=(r,t,e)=>new Promise((n,s)=>{var d=o=>{try{h(e.next(o))}catch(m){s(m)}},u=o=>{try{h(e.throw(o))}catch(m){s(m)}},h=o=>o.done?n(o.value):Promise.resolve(o.value).then(d,u);h((e=e.apply(r,t)).next())});const z=J(),q={POINT:"POINT",COUNTRY:"COUNTRY"};class St extends a.Map{constructor(t){var e,n,s;t.apiKey&&(A.apiKey=t.apiKey);const d=R(t.style),u=location.hash;A.apiKey||console.warn("MapTiler Cloud API key is not set. Visit https://maptiler.com and try Cloud for free!"),super(_t(Lt({},t),{style:d,maplibreLogo:!1,transformRequest:c=>{let i=null;try{i=new URL(c)}catch{return{url:c,headers:{}}}return i.host===y.maptilerApiHost&&(i.searchParams.has("key")||i.searchParams.append("key",A.apiKey),A.session&&i.searchParams.append("mtsid",z)),{url:i.href,headers:{}}}})),this.isTerrainEnabled=!1,this.terrainExaggeration=1,this.primaryLanguage=null,this.secondaryLanguage=null,this.terrainGrowing=!1,this.terrainFlattening=!1,this.primaryLanguage=(e=t.language)!=null?e:A.primaryLanguage,this.secondaryLanguage=A.secondaryLanguage,this.terrainExaggeration=(n=t.terrainExaggeration)!=null?n:this.terrainExaggeration,this.once("styledata",()=>_(this,null,function*(){if(!t.geolocate||t.center||t.hash&&u)return;try{if(t.geolocate===q.COUNTRY){yield this.fitToIpBounds();return}}catch(i){console.warn(i.message)}let c=null;try{yield this.centerOnIpPoint(t.zoom),c=this.getCameraHash()}catch(i){console.warn(i.message)}(yield navigator.permissions.query({name:"geolocation"})).state==="granted"&&navigator.geolocation.getCurrentPosition(i=>{c===this.getCameraHash()&&(this.terrain?this.easeTo({center:[i.coords.longitude,i.coords.latitude],zoom:t.zoom||12,duration:2e3}):this.once("terrain",()=>{this.easeTo({center:[i.coords.longitude,i.coords.latitude],zoom:t.zoom||12,duration:2e3})}))},null,{maximumAge:24*3600*1e3,timeout:5e3,enableHighAccuracy:!1})})),this.on("styledata",()=>{this.setPrimaryLanguage(this.primaryLanguage),this.setSecondaryLanguage(this.secondaryLanguage)}),this.on("styledata",()=>{this.getTerrain()===null&&this.isTerrainEnabled&&this.enableTerrain(this.terrainExaggeration)}),this.once("load",()=>_(this,null,function*(){nt()})),this.once("load",()=>_(this,null,function*(){let c={logo:null};try{const i=Object.keys(this.style.sourceCaches).map(l=>this.getSource(l)).filter(l=>typeof l.url=="string"&&l.url.includes("tiles.json")),p=new URL(i[0].url);p.searchParams.has("key")||p.searchParams.append("key",A.apiKey),c=yield(yield fetch(p.href)).json()}catch{}if("logo"in c&&c.logo){const i=c.logo;this.addControl(new I({logoURL:i}),t.logoPosition),t.attributionControl===!1&&this.addControl(new j(t))}else t.maptilerLogo&&this.addControl(new I,t.logoPosition);if(t.scaleControl){const i=t.scaleControl===!0||t.scaleControl===void 0?"bottom-right":t.scaleControl,p=new K({unit:A.unit});this.addControl(p,i),A.on("unit",l=>{p.setUnit(l)})}if(t.navigationControl!==!1){const i=t.navigationControl===!0||t.navigationControl===void 0?"top-right":t.navigationControl;this.addControl(new O,i)}if(t.geolocateControl!==!1){const i=t.geolocateControl===!0||t.geolocateControl===void 0?"top-right":t.geolocateControl;this.addControl(new H({positionOptions:{enableHighAccuracy:!0,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!0,showAccuracyCircle:!0,showUserLocation:!0}),i)}if(t.terrainControl){const i=t.terrainControl===!0||t.terrainControl===void 0?"top-right":t.terrainControl;this.addControl(new P,i)}if(t.fullscreenControl){const i=t.fullscreenControl===!0||t.fullscreenControl===void 0?"top-right":t.fullscreenControl;this.addControl(new F({}),i)}}));let h=!1,o=!1,m=null;this.once("load",c=>{h=!0,o&&this.fire("loadWithTerrain",m)});const g=c=>{c.terrain&&(o=!0,m={type:"loadWithTerrain",target:this,terrain:c.terrain},this.off("terrain",g),h&&this.fire("loadWithTerrain",m))};this.on("terrain",g),t.terrain&&this.enableTerrain((s=t.terrainExaggeration)!=null?s:this.terrainExaggeration)}onLoadAsync(){return _(this,null,function*(){return new Promise((t,e)=>{if(this.loaded())return t(this);this.once("load",n=>{t(this)})})})}onLoadWithTerrainAsync(){return _(this,null,function*(){return new Promise((t,e)=>{if(this.loaded()&&this.terrain)return t(this);this.once("loadWithTerrain",n=>{t(this)})})})}setStyle(t,e){return super.setStyle(R(t),e)}setLanguage(t=y.primaryLanguage){if(t===L.AUTO)return this.setLanguage(b());this.setPrimaryLanguage(t)}setPrimaryLanguage(t=y.primaryLanguage){v(t)&&(this.primaryLanguage=t,this.onStyleReady(()=>{if(t===L.AUTO)return this.setPrimaryLanguage(b());const e=this.getStyle().layers,n=/^\s*{\s*name\s*(:\s*(\S*))?\s*}$/,s=/^\s*name\s*(:\s*(\S*))?\s*$/,d=/^\s*{\s*name\s*(:\s*(\S*))?\s*}(\s*){\s*name\s*(:\s*(\S*))?\s*}$/,u=/^(.*)({\s*name\s*(:\s*(\S*))?\s*})(.*)$/,h=t?`name:${t}`:"name",o=["case",["has",h],["get",h],["get","name:latin"]];for(let m=0;m<e.length;m+=1){const g=e[m],c=g.layout;if(!c||!c["text-field"])continue;const i=this.getLayoutProperty(g.id,"text-field");let p;if(Array.isArray(i)&&i.length>=2&&i[0].trim().toLowerCase()==="concat"){const l=i.slice();for(let x=0;x<i.length;x+=1){const f=i[x];if((typeof f=="string"||f instanceof String)&&n.exec(f.toString())){l[x]=o;break}else if(Array.isArray(f)&&f.length>=2&&f[0].trim().toLowerCase()==="get"&&s.exec(f[1].toString())){l[x]=o;break}else if(Array.isArray(f)&&f.length===4&&f[0].trim().toLowerCase()==="case"){l[x]=o;break}}this.setLayoutProperty(g.id,"text-field",l)}else if(Array.isArray(i)&&i.length>=2&&i[0].trim().toLowerCase()==="get"&&s.exec(i[1].toString())){const l=o;this.setLayoutProperty(g.id,"text-field",l)}else if((typeof i=="string"||i instanceof String)&&n.exec(i.toString())){const l=o;this.setLayoutProperty(g.id,"text-field",l)}else if(Array.isArray(i)&&i.length===4&&i[0].trim().toLowerCase()==="case"){const l=o;this.setLayoutProperty(g.id,"text-field",l)}else if((typeof i=="string"||i instanceof String)&&(p=d.exec(i.toString()))!==null){const l=`{${h}}${p[3]}{name${p[4]||""}}`;this.setLayoutProperty(g.id,"text-field",l)}else if((typeof i=="string"||i instanceof String)&&(p=u.exec(i.toString()))!==null){const l=`${p[1]}{${h}}${p[5]}`;this.setLayoutProperty(g.id,"text-field",l)}}}))}setSecondaryLanguage(t=y.secondaryLanguage){v(t)&&(this.secondaryLanguage=t,this.onStyleReady(()=>{if(t===L.AUTO)return this.setSecondaryLanguage(b());const e=this.getStyle().layers,n=/^\s*{\s*name\s*(:\s*(\S*))?\s*}$/,s=/^\s*name\s*(:\s*(\S*))?\s*$/,d=/^\s*{\s*name\s*(:\s*(\S*))?\s*}(\s*){\s*name\s*(:\s*(\S*))?\s*}$/;let u;for(let h=0;h<e.length;h+=1){const o=e[h],m=o.layout;if(!m||!m["text-field"])continue;const g=this.getLayoutProperty(o.id,"text-field");let c;if(Array.isArray(g)&&g.length>=2&&g[0].trim().toLowerCase()==="concat"){c=g.slice();let i=0;for(let p=0;p<g.length;p+=1){const l=g[p];if((typeof l=="string"||l instanceof String)&&n.exec(l.toString())){if(i===1){c[p]=`{name:${t}}`;break}i+=1}else if(Array.isArray(l)&&l.length>=2&&l[0].trim().toLowerCase()==="get"&&s.exec(l[1].toString())){if(i===1){c[p][1]=`name:${t}`;break}i+=1}else if(Array.isArray(l)&&l.length===4&&l[0].trim().toLowerCase()==="case"){if(i===1){c[p]=["get",`name:${t}`];break}i+=1}}this.setLayoutProperty(o.id,"text-field",c)}else if((typeof g=="string"||g instanceof String)&&(u=d.exec(g.toString()))!==null){const i=t?`name:${t}`:"name";c=`{name${u[1]||""}}${u[3]}{${i}}`,this.setLayoutProperty(o.id,"text-field",c)}}}))}getPrimaryLanguage(){return this.primaryLanguage}getSecondaryLanguage(){return this.secondaryLanguage}getTerrainExaggeration(){return this.terrainExaggeration}hasTerrain(){return this.isTerrainEnabled}growTerrain(t,e=1e3){if(!this.terrain)return;const n=performance.now(),s=this.terrain.exaggeration,d=t-s,u=()=>{if(!this.terrain||this.terrainFlattening)return;const h=(performance.now()-n)/e;if(h<.99){const o=1-Math.pow(1-h,4),m=s+o*d;this.terrain.exaggeration=m,requestAnimationFrame(u)}else this.terrainGrowing=!1,this.terrainFlattening=!1,this.terrain.exaggeration=t;this.triggerRepaint()};this.terrainGrowing=!0,this.terrainFlattening=!1,requestAnimationFrame(u)}enableTerrain(t=this.terrainExaggeration){if(t<0){console.warn("Terrain exaggeration cannot be negative.");return}const e=s=>_(this,null,function*(){!this.terrain||s.type!=="data"||s.dataType!=="source"||!("source"in s)||s.sourceId!=="maptiler-terrain"||s.source.type!=="raster-dem"||s.isSourceLoaded&&(this.off("data",e),this.growTerrain(t))}),n=()=>{this.isTerrainEnabled=!0,this.terrainExaggeration=t,this.on("data",e),this.addSource(y.terrainSourceId,{type:"raster-dem",url:y.terrainSourceURL}),this.setTerrain({source:y.terrainSourceId,exaggeration:0})};if(this.getTerrain()){this.isTerrainEnabled=!0,this.growTerrain(t);return}this.loaded()||this.isTerrainEnabled?n():this.once("load",()=>{this.getTerrain()&&this.getSource(y.terrainSourceId)||n()})}disableTerrain(){if(!this.terrain)return;this.isTerrainEnabled=!1;const t=1*1e3,e=performance.now(),n=this.terrain.exaggeration,s=()=>{if(!this.terrain||this.terrainGrowing)return;const d=(performance.now()-e)/t;if(d<.99){const u=Math.pow(1-d,4),h=n*u;this.terrain.exaggeration=h,requestAnimationFrame(s)}else this.terrain.exaggeration=0,this.terrainGrowing=!1,this.terrainFlattening=!1,this.setTerrain(null),this.getSource(y.terrainSourceId)&&this.removeSource(y.terrainSourceId);this.triggerRepaint()};this.terrainGrowing=!1,this.terrainFlattening=!0,requestAnimationFrame(s)}setTerrainExaggeration(t,e=!0){!e&&this.terrain?(this.terrainExaggeration=t,this.terrain.exaggeration=t,this.triggerRepaint()):this.enableTerrain(t)}onStyleReady(t){this.isStyleLoaded()?t():this.once("styledata",()=>{t()})}fitToIpBounds(){return _(this,null,function*(){const t=yield w.info();this.fitBounds(t.country_bounds,{duration:0,padding:100})})}centerOnIpPoint(t){return _(this,null,function*(){const e=yield w.info();this.jumpTo({center:[e.longitude,e.latitude],zoom:t||11})})}getCameraHash(){const t=new Float32Array(5),e=this.getCenter();return t[0]=e.lng,t[1]=e.lat,t[2]=this.getZoom(),t[3]=this.getPitch(),t[4]=this.getBearing(),W.fromUint8Array(new Uint8Array(t.buffer))}getSdkConfig(){return A}getMaptilerSessionId(){return z}}class xt extends a.Marker{addTo(t){return super.addTo(t)}}class Ct extends a.Popup{addTo(t){return super.addTo(t)}}class Tt extends a.Style{constructor(t,e={}){super(t,e)}}class bt extends a.CanvasSource{onAdd(t){super.onAdd(t)}}class It extends a.GeoJSONSource{onAdd(t){super.onAdd(t)}}class wt extends a.ImageSource{onAdd(t){super.onAdd(t)}}class vt extends a.RasterTileSource{onAdd(t){super.onAdd(t)}}class Et extends a.RasterDEMTileSource{onAdd(t){super.onAdd(t)}}class Nt extends a.VectorTileSource{onAdd(t){super.onAdd(t)}}class Rt extends a.VideoSource{onAdd(t){super.onAdd(t)}}class Pt extends a.TerrainControl{onAdd(t){return super.onAdd(t)}}class C{constructor(t,e){this.x=t,this.y=e}_matMult(t){const e=t[0]*this.x+t[1]*this.y,n=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=n,this}_add(t){return this.x+=t.x,this.y+=t.y,this}_sub(t){return this.x-=t.x,this.y-=t.y,this}_mult(t){return this.x*=t,this.y*=t,this}_div(t){return this.x/=t,this.y/=t,this}_multByPoint(t){return this.x*=t.x,this.y*=t.y,this}_divByPoint(t){return this.x/=t.x,this.y/=t.y,this}_unit(){return this._div(this.mag()),this}_perp(){const t=this.y;return this.y=this.x,this.x=-t,this}_rotate(t){const e=Math.cos(t),n=Math.sin(t),s=e*this.x-n*this.y,d=n*this.x+e*this.y;return this.x=s,this.y=d,this}_rotateAround(t,e){const n=Math.cos(t),s=Math.sin(t),d=e.x+n*(this.x-e.x)-s*(this.y-e.y),u=e.y+s*(this.x-e.x)+n*(this.y-e.y);return this.x=d,this.y=u,this}_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}clone(){return new C(this.x,this.y)}add(t){return this.clone()._add(t)}sub(t){return this.clone()._sub(t)}multByPoint(t){return this.clone()._multByPoint(t)}divByPoint(t){return this.clone()._divByPoint(t)}mult(t){return this.clone()._mult(t)}div(t){return this.clone()._div(t)}rotate(t){return this.clone()._rotate(t)}rotateAround(t,e){return this.clone()._rotateAround(t,e)}matMult(t){return this.clone()._matMult(t)}unit(){return this.clone()._unit()}perp(){return this.clone()._perp()}round(){return this.clone()._round()}mag(){return Math.sqrt(this.x*this.x+this.y*this.y)}equals(t){return this.x===t.x&&this.y===t.y}dist(t){return Math.sqrt(this.distSqr(t))}distSqr(t){const e=t.x-this.x,n=t.y-this.y;return e*e+n*n}angle(){return Math.atan2(this.y,this.x)}angleTo(t){return Math.atan2(this.y-t.y,this.x-t.x)}angleWith(t){return this.angleWithSep(t.x,t.y)}angleWithSep(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)}static convert(t){return t instanceof C?t:Array.isArray(t)?new C(t[0],t[1]):t}}const{supported:Mt,setRTLTextPlugin:Ot,getRTLTextPluginStatus:Ut,LngLat:kt,LngLatBounds:Bt,MercatorCoordinate:$t,Evented:Gt,AJAXError:Ht,prewarm:jt,clearPrewarmedResources:Kt,version:Ft,workerCount:Dt,maxParallelImageRequests:Vt,workerUrl:zt,addProtocol:qt,removeProtocol:Wt}=a,Jt=a.Map,Zt=a.Marker,Yt=a.Popup,Xt=a.Style,Qt=a.CanvasSource,te=a.GeoJSONSource,ee=a.ImageSource,re=a.RasterTileSource,ie=a.RasterDEMTileSource,ne=a.VectorTileSource,ae=a.VideoSource;a.NavigationControl,a.GeolocateControl,a.AttributionControl,a.LogoControl,a.ScaleControl,a.FullscreenControl,a.TerrainControl;export{Ht as AJAXError,j as AttributionControl,bt as CanvasSource,Qt as CanvasSourceMLGL,Gt as Evented,F as FullscreenControl,It as GeoJSONSource,te as GeoJSONSourceMLGL,U as GeolocateControl,q as GeolocationType,wt as ImageSource,ee as ImageSourceMLGL,L as Language,me as LanguageGeocoding,kt as LngLat,Bt as LngLatBounds,N as LogoControl,St as Map,Jt as MapMLGL,ye as MapStyle,Ae as MapStyleVariant,H as MaptilerGeolocateControl,I as MaptilerLogoControl,O as MaptilerNavigationControl,P as MaptilerTerrainControl,xt as Marker,Zt as MarkerMLGL,$t as MercatorCoordinate,M as NavigationControl,C as Point,Ct as Popup,Yt as PopupMLGL,Et as RasterDEMTileSource,ie as RasterDEMTileSourceMLGL,vt as RasterTileSource,re as RasterTileSourceMLGL,fe as ReferenceMapStyle,K as ScaleControl,E as SdkConfig,Le as ServiceError,Tt as Style,Xt as StyleMLGL,Pt as TerrainControl,Nt as VectorTileSource,ne as VectorTileSourceMLGL,Rt as VideoSource,ae as VideoSourceMLGL,qt as addProtocol,Kt as clearPrewarmedResources,A as config,_e as coordinates,Se as data,xe as geocoding,Ce as geolocation,Ut as getRTLTextPluginStatus,Vt as maxParallelImageRequests,jt as prewarm,Wt as removeProtocol,Ot as setRTLTextPlugin,Te as staticMaps,Mt as supported,Ft as version,Dt as workerCount,zt as workerUrl};
1
+ import a from"maplibre-gl";export*from"maplibre-gl";import{Base64 as Q}from"js-base64";import tt from"events";import{config as C,expandMapStyle as et,MapStyleVariant as rt,ReferenceMapStyle as nt,MapStyle as it,mapStylePresetList as at,geolocation as w}from"@maptiler/client";import{LanguageGeocoding as Te,MapStyle as Ce,MapStyleVariant as be,ReferenceMapStyle as ve,ServiceError as we,coordinates as Ee,data as Ie,geocoding as Re,geolocation as Ne,staticMaps as Pe}from"@maptiler/client";import{v4 as ot}from"uuid";const f={AUTO:"auto",STYLE_LOCK:"style_lock",LATIN:"latin",NON_LATIN:"nonlatin",LOCAL:"",ALBANIAN:"sq",AMHARIC:"am",ARABIC:"ar",ARMENIAN:"hy",AZERBAIJANI:"az",BASQUE:"eu",BELORUSSIAN:"be",BOSNIAN:"bs",BRETON:"br",BULGARIAN:"bg",CATALAN:"ca",CHINESE:"zh",CORSICAN:"co",CROATIAN:"hr",CZECH:"cs",DANISH:"da",DUTCH:"nl",ENGLISH:"en",ESPERANTO:"eo",ESTONIAN:"et",FINNISH:"fi",FRENCH:"fr",FRISIAN:"fy",GEORGIAN:"ka",GERMAN:"de",GREEK:"el",HEBREW:"he",HINDI:"hi",HUNGARIAN:"hu",ICELANDIC:"is",INDONESIAN:"id",IRISH:"ga",ITALIAN:"it",JAPANESE:"ja",JAPANESE_HIRAGANA:"ja-Hira",JAPANESE_KANA:"ja_kana",JAPANESE_LATIN:"ja_rm",JAPANESE_2018:"ja-Latn",KANNADA:"kn",KAZAKH:"kk",KOREAN:"ko",KOREAN_LATIN:"ko-Latn",KURDISH:"ku",ROMAN_LATIN:"la",LATVIAN:"lv",LITHUANIAN:"lt",LUXEMBOURGISH:"lb",MACEDONIAN:"mk",MALAYALAM:"ml",MALTESE:"mt",NORWEGIAN:"no",OCCITAN:"oc",POLISH:"pl",PORTUGUESE:"pt",ROMANIAN:"ro",ROMANSH:"rm",RUSSIAN:"ru",SCOTTISH_GAELIC:"gd",SERBIAN_CYRILLIC:"sr",SERBIAN_LATIN:"sr-Latn",SLOVAK:"sk",SLOVENE:"sl",SPANISH:"es",SWEDISH:"sv",TAMIL:"ta",TELUGU:"te",THAI:"th",TURKISH:"tr",UKRAINIAN:"uk",WELSH:"cy"},st=new Set(Object.values(f));function E(r){return st.has(r)}const lt=new Set(Object.values(f));function b(){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=>lt.has(t));return r.length?r[0]:f.LATIN}const I=ot();let R=class extends tt{constructor(){super(),this.primaryLanguage=f.AUTO,this.secondaryLanguage=null,this.session=!0,this._unit="metric",this._apiKey=""}set unit(t){this._unit=t,this.emit("unit",t)}get unit(){return this._unit}set apiKey(t){this._apiKey=t,C.apiKey=t,this.emit("apiKey",t)}get apiKey(){return this._apiKey}set fetch(t){C.fetch=t}get fetch(){return C.fetch}};const L=new R,y={maptilerLogoURL:"https://api.maptiler.com/resources/logo.svg",maptilerURL:"https://www.maptiler.com/",maptilerApiHost:"api.maptiler.com",rtlPluginURL:"https://cdn.maptiler.com/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.min.js",primaryLanguage:f.AUTO,secondaryLanguage:f.LOCAL,terrainSourceURL:"https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json",terrainSourceId:"maptiler-terrain"};Object.freeze(y);class N extends a.LogoControl{onAdd(t){return super.onAdd(t)}}class v extends N{constructor(t={}){var e,i;super(t),this.logoURL="",this.linkURL="",this.logoURL=(e=t.logoURL)!=null?e:y.maptilerLogoURL,this.linkURL=(i=t.linkURL)!=null?i:y.maptilerURL}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=window.document.createElement("div"),this._container.className="maplibregl-ctrl";const e=window.document.createElement("a");return e.style.backgroundRepeat="no-repeat",e.style.cursor="pointer",e.style.display="block",e.style.height="23px",e.style.margin="0 0 -4px -4px",e.style.overflow="hidden",e.style.width="88px",e.style.backgroundImage=`url(${this.logoURL})`,e.style.backgroundSize="100px 30px",e.style.width="100px",e.style.height="30px",e.target="_blank",e.rel="noopener",e.href=this.linkURL,e.setAttribute("aria-label","MapTiler logo"),e.setAttribute("rel","noopener"),this._container.appendChild(e),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}}var ct=Object.defineProperty,P=Object.getOwnPropertySymbols,ht=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable,O=(r,t,e)=>t in r?ct(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,M=(r,t)=>{for(var e in t||(t={}))ht.call(t,e)&&O(r,e,t[e]);if(P)for(var e of P(t))ut.call(t,e)&&O(r,e,t[e]);return r};function gt(){a.getRTLTextPluginStatus()==="unavailable"&&a.setRTLTextPlugin(y.rtlPluginURL,null,!0)}function dt(r,t){r.forEach(e=>{t[e]&&(t[e]=t[e].bind(t))})}function _(r,t,e){const i=window.document.createElement(r);return t!==void 0&&(i.className=t),e&&e.appendChild(i),i}function pt(r){r.parentNode&&r.parentNode.removeChild(r)}function U(r,t){let e=null;try{e=new URL(r)}catch{return{url:r}}return e.host===y.maptilerApiHost&&(e.searchParams.has("key")||e.searchParams.append("key",L.apiKey),L.session&&e.searchParams.append("mtsid",I)),{url:e.href}}function k(r=null){return function(t,e){if(r){const i=r(t,e),s=U(i.url);return M(M({},i),s)}else return U(t)}}function B(r){return r?typeof r=="string"||r instanceof String?!r.startsWith("http")&&r.toLowerCase().includes(".json")?r:et(r):r instanceof rt?r.getExpandedStyleURL():r instanceof nt?r.getDefaultVariant().getExpandedStyleURL():r:it[at[0].referenceStyleID].getDefaultVariant().getExpandedStyleURL()}class ${constructor(){dt(["_toggleTerrain","_updateTerrainIcon"],this)}onAdd(t){return this._map=t,this._container=_("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=_("button","maplibregl-ctrl-terrain",this._container),_("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){pt(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}_toggleTerrain(){this._map.hasTerrain()?this._map.disableTerrain():this._map.enableTerrain(),this._updateTerrainIcon()}_updateTerrainIcon(){this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.hasTerrain()?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"))}}class G extends a.NavigationControl{onAdd(t){return super.onAdd(t)}}class K extends G{constructor(){super({showCompass:!0,showZoom:!0,visualizePitch:!0}),this._compass.removeEventListener("click",this._compass.clickFunction),this._compass.addEventListener("click",t=>{this._map.getPitch()===0?this._map.easeTo({pitch:Math.min(this._map.getMaxPitch(),80)}):this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})}_createButton(t,e){const i=super._createButton(t,e);return i.clickFunction=e,i}_rotateCompassArrow(){const t=this.options.visualizePitch?`scale(${Math.min(1.5,1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5))}) rotateX(${Math.min(70,this._map.transform.pitch)}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=t}}class j extends a.GeolocateControl{onAdd(t){return super.onAdd(t)}}var mt=Object.defineProperty,yt=Object.defineProperties,ft=Object.getOwnPropertyDescriptors,H=Object.getOwnPropertySymbols,Lt=Object.prototype.hasOwnProperty,At=Object.prototype.propertyIsEnumerable,D=(r,t,e)=>t in r?mt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,St=(r,t)=>{for(var e in t||(t={}))Lt.call(t,e)&&D(r,e,t[e]);if(H)for(var e of H(t))At.call(t,e)&&D(r,e,t[e]);return r},_t=(r,t)=>yt(r,ft(t));const F=a.Marker,q=a.LngLat,xt=a.LngLatBounds;class V extends j{constructor(){super(...arguments),this.lastUpdatedCenter=new q(0,0)}_updateCamera(t){const e=new q(t.coords.longitude,t.coords.latitude),i=t.coords.accuracy,s=this._map.getBearing(),g=_t(St({bearing:s},this.options.fitBoundsOptions),{linear:!0}),h=this._map.getZoom();h>this.options.fitBoundsOptions.maxZoom&&(g.zoom=h),this._map.fitBounds(xt.fromLngLat(e,i),g,{geolocateSource:!0});let c=!1;const o=()=>{c=!0};this._map.once("click",o),this._map.once("dblclick",o),this._map.once("dragstart",o),this._map.once("mousedown",o),this._map.once("touchstart",o),this._map.once("wheel",o),this._map.once("moveend",()=>{this._map.off("click",o),this._map.off("dblclick",o),this._map.off("dragstart",o),this._map.off("mousedown",o),this._map.off("touchstart",o),this._map.off("wheel",o),!c&&(this.lastUpdatedCenter=this._map.getCenter())})}_setupUI(t){if(this.lastUpdatedCenter=this._map.getCenter(),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=_("button","maplibregl-ctrl-geolocate",this._container),_("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",t===!1){const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=_("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new F(this._dotElement),this._circleElement=_("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new F({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("move",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("moveend",e=>{const i=e.originalEvent&&e.originalEvent.type==="resize",s=this.lastUpdatedCenter.distanceTo(this._map.getCenter());!e.geolocateSource&&this._watchState==="ACTIVE_LOCK"&&!i&&s>1&&(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new Event("trackuserlocationend")))})}_updateCircleRadius(){if(this._watchState!=="BACKGROUND"&&this._watchState!=="ACTIVE_LOCK")return;const t=[this._lastKnownPosition.coords.longitude,this._lastKnownPosition.coords.latitude],e=this._map.project(t),i=this._map.unproject([e.x,e.y]),s=this._map.unproject([e.x+20,e.y]),g=i.distanceTo(s)/20,h=Math.ceil(2*this._accuracy/g);this._circleElement.style.width=`${h}px`,this._circleElement.style.height=`${h}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}}class z extends a.AttributionControl{onAdd(t){return super.onAdd(t)}}class W extends a.ScaleControl{onAdd(t){return super.onAdd(t)}}class J extends a.FullscreenControl{onAdd(t){return super.onAdd(t)}}var Tt=Object.defineProperty,Ct=Object.defineProperties,bt=Object.getOwnPropertyDescriptors,Z=Object.getOwnPropertySymbols,vt=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable,Y=(r,t,e)=>t in r?Tt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Et=(r,t)=>{for(var e in t||(t={}))vt.call(t,e)&&Y(r,e,t[e]);if(Z)for(var e of Z(t))wt.call(t,e)&&Y(r,e,t[e]);return r},It=(r,t)=>Ct(r,bt(t)),S=(r,t,e)=>new Promise((i,s)=>{var g=o=>{try{c(e.next(o))}catch(m){s(m)}},h=o=>{try{c(e.throw(o))}catch(m){s(m)}},c=o=>o.done?i(o.value):Promise.resolve(o.value).then(g,h);c((e=e.apply(r,t)).next())});const X={POINT:"POINT",COUNTRY:"COUNTRY"};class Rt extends a.Map{constructor(t){var e,i,s;t.apiKey&&(L.apiKey=t.apiKey);const g=B(t.style),h=location.hash;L.apiKey||console.warn("MapTiler Cloud API key is not set. Visit https://maptiler.com and try Cloud for free!"),super(It(Et({},t),{style:g,maplibreLogo:!1,transformRequest:k(t.transformRequest)})),this.isTerrainEnabled=!1,this.terrainExaggeration=1,this.primaryLanguage=null,this.secondaryLanguage=null,this.terrainGrowing=!1,this.terrainFlattening=!1,this.primaryLanguage=(e=t.language)!=null?e:L.primaryLanguage,this.secondaryLanguage=L.secondaryLanguage,this.terrainExaggeration=(i=t.terrainExaggeration)!=null?i:this.terrainExaggeration,this.once("styledata",()=>S(this,null,function*(){if(!t.geolocate||t.center||t.hash&&h)return;try{if(t.geolocate===X.COUNTRY){yield this.fitToIpBounds();return}}catch(n){console.warn(n.message)}let u=null;try{yield this.centerOnIpPoint(t.zoom),u=this.getCameraHash()}catch(n){console.warn(n.message)}(yield navigator.permissions.query({name:"geolocation"})).state==="granted"&&navigator.geolocation.getCurrentPosition(n=>{u===this.getCameraHash()&&(this.terrain?this.easeTo({center:[n.coords.longitude,n.coords.latitude],zoom:t.zoom||12,duration:2e3}):this.once("terrain",()=>{this.easeTo({center:[n.coords.longitude,n.coords.latitude],zoom:t.zoom||12,duration:2e3})}))},null,{maximumAge:24*3600*1e3,timeout:5e3,enableHighAccuracy:!1})})),this.on("styledata",()=>{this.setPrimaryLanguage(this.primaryLanguage),this.setSecondaryLanguage(this.secondaryLanguage)}),this.on("styledata",()=>{this.getTerrain()===null&&this.isTerrainEnabled&&this.enableTerrain(this.terrainExaggeration)}),this.once("load",()=>S(this,null,function*(){gt()})),this.once("load",()=>S(this,null,function*(){let u={logo:null};try{const n=Object.keys(this.style.sourceCaches).map(l=>this.getSource(l)).filter(l=>typeof l.url=="string"&&l.url.includes("tiles.json")),p=new URL(n[0].url);p.searchParams.has("key")||p.searchParams.append("key",L.apiKey),u=yield(yield fetch(p.href)).json()}catch{}if("logo"in u&&u.logo){const n=u.logo;this.addControl(new v({logoURL:n}),t.logoPosition),t.attributionControl===!1&&this.addControl(new z({customAttribution:t.customAttribution}))}else t.maptilerLogo&&this.addControl(new v,t.logoPosition);if(t.scaleControl){const n=t.scaleControl===!0||t.scaleControl===void 0?"bottom-right":t.scaleControl,p=new W({unit:L.unit});this.addControl(p,n),L.on("unit",l=>{p.setUnit(l)})}if(t.navigationControl!==!1){const n=t.navigationControl===!0||t.navigationControl===void 0?"top-right":t.navigationControl;this.addControl(new K,n)}if(t.geolocateControl!==!1){const n=t.geolocateControl===!0||t.geolocateControl===void 0?"top-right":t.geolocateControl;this.addControl(new V({positionOptions:{enableHighAccuracy:!0,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!0,showAccuracyCircle:!0,showUserLocation:!0}),n)}if(t.terrainControl){const n=t.terrainControl===!0||t.terrainControl===void 0?"top-right":t.terrainControl;this.addControl(new $,n)}if(t.fullscreenControl){const n=t.fullscreenControl===!0||t.fullscreenControl===void 0?"top-right":t.fullscreenControl;this.addControl(new J({}),n)}}));let c=!1,o=!1,m=null;this.once("load",u=>{c=!0,o&&this.fire("loadWithTerrain",m)});const d=u=>{u.terrain&&(o=!0,m={type:"loadWithTerrain",target:this,terrain:u.terrain},this.off("terrain",d),c&&this.fire("loadWithTerrain",m))};this.on("terrain",d),t.terrain&&this.enableTerrain((s=t.terrainExaggeration)!=null?s:this.terrainExaggeration)}onLoadAsync(){return S(this,null,function*(){return new Promise((t,e)=>{if(this.loaded())return t(this);this.once("load",i=>{t(this)})})})}onLoadWithTerrainAsync(){return S(this,null,function*(){return new Promise((t,e)=>{if(this.loaded()&&this.terrain)return t(this);this.once("loadWithTerrain",i=>{t(this)})})})}setStyle(t,e){return super.setStyle(B(t),e)}setLanguage(t=y.primaryLanguage){if(t===f.AUTO)return this.setLanguage(b());this.setPrimaryLanguage(t)}setPrimaryLanguage(t=y.primaryLanguage){if(this.primaryLanguage===f.STYLE_LOCK){console.warn("The language cannot be changed because this map has been instantiated with the STYLE_LOCK language flag.");return}E(t)&&(this.primaryLanguage=t,this.onStyleReady(()=>{if(t===f.AUTO)return this.setPrimaryLanguage(b());const e=this.getStyle().layers,i=/^\s*{\s*name\s*(:\s*(\S*))?\s*}$/,s=/^\s*name\s*(:\s*(\S*))?\s*$/,g=/^\s*{\s*name\s*(:\s*(\S*))?\s*}(\s*){\s*name\s*(:\s*(\S*))?\s*}$/,h=/^(.*)({\s*name\s*(:\s*(\S*))?\s*})(.*)$/,c=t?`name:${t}`:"name",o=["case",["has",c],["get",c],["get","name"]];for(let m=0;m<e.length;m+=1){const d=e[m],u=d.layout;if(!u||!u["text-field"])continue;const n=this.getLayoutProperty(d.id,"text-field");let p;if(Array.isArray(n)&&n.length>=2&&n[0].trim().toLowerCase()==="concat"){const l=n.slice();for(let x=0;x<n.length;x+=1){const A=n[x];if((typeof A=="string"||A instanceof String)&&i.exec(A.toString())){l[x]=o;break}else if(Array.isArray(A)&&A.length>=2&&A[0].trim().toLowerCase()==="get"&&s.exec(A[1].toString())){l[x]=o;break}else if(Array.isArray(A)&&A.length===4&&A[0].trim().toLowerCase()==="case"){l[x]=o;break}}this.setLayoutProperty(d.id,"text-field",l)}else if(Array.isArray(n)&&n.length>=2&&n[0].trim().toLowerCase()==="get"&&s.exec(n[1].toString())){const l=o;this.setLayoutProperty(d.id,"text-field",l)}else if((typeof n=="string"||n instanceof String)&&i.exec(n.toString())){const l=o;this.setLayoutProperty(d.id,"text-field",l)}else if(Array.isArray(n)&&n.length===4&&n[0].trim().toLowerCase()==="case"){const l=o;this.setLayoutProperty(d.id,"text-field",l)}else if((typeof n=="string"||n instanceof String)&&(p=g.exec(n.toString()))!==null){const l=`{${c}}${p[3]}{name${p[4]||""}}`;this.setLayoutProperty(d.id,"text-field",l)}else if((typeof n=="string"||n instanceof String)&&(p=h.exec(n.toString()))!==null){const l=`${p[1]}{${c}}${p[5]}`;this.setLayoutProperty(d.id,"text-field",l)}}}))}setSecondaryLanguage(t=y.secondaryLanguage){if(this.primaryLanguage===f.STYLE_LOCK){console.warn("The language cannot be changed because this map has been instantiated with the STYLE_LOCK language flag.");return}E(t)&&(this.secondaryLanguage=t,this.onStyleReady(()=>{if(t===f.AUTO)return this.setSecondaryLanguage(b());const e=this.getStyle().layers,i=/^\s*{\s*name\s*(:\s*(\S*))?\s*}$/,s=/^\s*name\s*(:\s*(\S*))?\s*$/,g=/^\s*{\s*name\s*(:\s*(\S*))?\s*}(\s*){\s*name\s*(:\s*(\S*))?\s*}$/;let h;for(let c=0;c<e.length;c+=1){const o=e[c],m=o.layout;if(!m||!m["text-field"])continue;const d=this.getLayoutProperty(o.id,"text-field");let u;if(Array.isArray(d)&&d.length>=2&&d[0].trim().toLowerCase()==="concat"){u=d.slice();let n=0;for(let p=0;p<d.length;p+=1){const l=d[p];if((typeof l=="string"||l instanceof String)&&i.exec(l.toString())){if(n===1){u[p]=`{name:${t}}`;break}n+=1}else if(Array.isArray(l)&&l.length>=2&&l[0].trim().toLowerCase()==="get"&&s.exec(l[1].toString())){if(n===1){u[p][1]=`name:${t}`;break}n+=1}else if(Array.isArray(l)&&l.length===4&&l[0].trim().toLowerCase()==="case"){if(n===1){u[p]=["get",`name:${t}`];break}n+=1}}this.setLayoutProperty(o.id,"text-field",u)}else if((typeof d=="string"||d instanceof String)&&(h=g.exec(d.toString()))!==null){const n=t?`name:${t}`:"name";u=`{name${h[1]||""}}${h[3]}{${n}}`,this.setLayoutProperty(o.id,"text-field",u)}}}))}getPrimaryLanguage(){return this.primaryLanguage}getSecondaryLanguage(){return this.secondaryLanguage}getTerrainExaggeration(){return this.terrainExaggeration}hasTerrain(){return this.isTerrainEnabled}growTerrain(t,e=1e3){if(!this.terrain)return;const i=performance.now(),s=this.terrain.exaggeration,g=t-s,h=()=>{if(!this.terrain||this.terrainFlattening)return;const c=(performance.now()-i)/e;if(c<.99){const o=1-Math.pow(1-c,4),m=s+o*g;this.terrain.exaggeration=m,requestAnimationFrame(h)}else this.terrainGrowing=!1,this.terrainFlattening=!1,this.terrain.exaggeration=t;this.triggerRepaint()};this.terrainGrowing=!0,this.terrainFlattening=!1,requestAnimationFrame(h)}enableTerrain(t=this.terrainExaggeration){if(t<0){console.warn("Terrain exaggeration cannot be negative.");return}const e=s=>S(this,null,function*(){!this.terrain||s.type!=="data"||s.dataType!=="source"||!("source"in s)||s.sourceId!=="maptiler-terrain"||s.source.type!=="raster-dem"||s.isSourceLoaded&&(this.off("data",e),this.growTerrain(t))}),i=()=>{this.isTerrainEnabled=!0,this.terrainExaggeration=t,this.on("data",e),this.addSource(y.terrainSourceId,{type:"raster-dem",url:y.terrainSourceURL}),this.setTerrain({source:y.terrainSourceId,exaggeration:0})};if(this.getTerrain()){this.isTerrainEnabled=!0,this.growTerrain(t);return}this.loaded()||this.isTerrainEnabled?i():this.once("load",()=>{this.getTerrain()&&this.getSource(y.terrainSourceId)||i()})}disableTerrain(){if(!this.terrain)return;this.isTerrainEnabled=!1;const t=1*1e3,e=performance.now(),i=this.terrain.exaggeration,s=()=>{if(!this.terrain||this.terrainGrowing)return;const g=(performance.now()-e)/t;if(g<.99){const h=Math.pow(1-g,4),c=i*h;this.terrain.exaggeration=c,requestAnimationFrame(s)}else this.terrain.exaggeration=0,this.terrainGrowing=!1,this.terrainFlattening=!1,this.setTerrain(null),this.getSource(y.terrainSourceId)&&this.removeSource(y.terrainSourceId);this.triggerRepaint()};this.terrainGrowing=!1,this.terrainFlattening=!0,requestAnimationFrame(s)}setTerrainExaggeration(t,e=!0){!e&&this.terrain?(this.terrainExaggeration=t,this.terrain.exaggeration=t,this.triggerRepaint()):this.enableTerrain(t)}onStyleReady(t){this.isStyleLoaded()?t():this.once("styledata",()=>{t()})}fitToIpBounds(){return S(this,null,function*(){const t=yield w.info();this.fitBounds(t.country_bounds,{duration:0,padding:100})})}centerOnIpPoint(t){return S(this,null,function*(){const e=yield w.info();this.jumpTo({center:[e.longitude,e.latitude],zoom:t||11})})}getCameraHash(){const t=new Float32Array(5),e=this.getCenter();return t[0]=e.lng,t[1]=e.lat,t[2]=this.getZoom(),t[3]=this.getPitch(),t[4]=this.getBearing(),Q.fromUint8Array(new Uint8Array(t.buffer))}getSdkConfig(){return L}getMaptilerSessionId(){return I}setTransformRequest(t){return super.setTransformRequest(k(t)),this}}class Nt extends a.Marker{addTo(t){return super.addTo(t)}}class Pt extends a.Popup{addTo(t){return super.addTo(t)}}class Ot extends a.Style{constructor(t,e={}){super(t,e)}}class Mt extends a.CanvasSource{onAdd(t){super.onAdd(t)}}class Ut extends a.GeoJSONSource{onAdd(t){super.onAdd(t)}}class kt extends a.ImageSource{onAdd(t){super.onAdd(t)}}class Bt extends a.RasterTileSource{onAdd(t){super.onAdd(t)}}class $t extends a.RasterDEMTileSource{onAdd(t){super.onAdd(t)}}class Gt extends a.VectorTileSource{onAdd(t){super.onAdd(t)}}class Kt extends a.VideoSource{onAdd(t){super.onAdd(t)}}class jt extends a.TerrainControl{onAdd(t){return super.onAdd(t)}}class T{constructor(t,e){this.x=t,this.y=e}_matMult(t){const e=t[0]*this.x+t[1]*this.y,i=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=i,this}_add(t){return this.x+=t.x,this.y+=t.y,this}_sub(t){return this.x-=t.x,this.y-=t.y,this}_mult(t){return this.x*=t,this.y*=t,this}_div(t){return this.x/=t,this.y/=t,this}_multByPoint(t){return this.x*=t.x,this.y*=t.y,this}_divByPoint(t){return this.x/=t.x,this.y/=t.y,this}_unit(){return this._div(this.mag()),this}_perp(){const t=this.y;return this.y=this.x,this.x=-t,this}_rotate(t){const e=Math.cos(t),i=Math.sin(t),s=e*this.x-i*this.y,g=i*this.x+e*this.y;return this.x=s,this.y=g,this}_rotateAround(t,e){const i=Math.cos(t),s=Math.sin(t),g=e.x+i*(this.x-e.x)-s*(this.y-e.y),h=e.y+s*(this.x-e.x)+i*(this.y-e.y);return this.x=g,this.y=h,this}_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}clone(){return new T(this.x,this.y)}add(t){return this.clone()._add(t)}sub(t){return this.clone()._sub(t)}multByPoint(t){return this.clone()._multByPoint(t)}divByPoint(t){return this.clone()._divByPoint(t)}mult(t){return this.clone()._mult(t)}div(t){return this.clone()._div(t)}rotate(t){return this.clone()._rotate(t)}rotateAround(t,e){return this.clone()._rotateAround(t,e)}matMult(t){return this.clone()._matMult(t)}unit(){return this.clone()._unit()}perp(){return this.clone()._perp()}round(){return this.clone()._round()}mag(){return Math.sqrt(this.x*this.x+this.y*this.y)}equals(t){return this.x===t.x&&this.y===t.y}dist(t){return Math.sqrt(this.distSqr(t))}distSqr(t){const e=t.x-this.x,i=t.y-this.y;return e*e+i*i}angle(){return Math.atan2(this.y,this.x)}angleTo(t){return Math.atan2(this.y-t.y,this.x-t.x)}angleWith(t){return this.angleWithSep(t.x,t.y)}angleWithSep(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)}static convert(t){return t instanceof T?t:Array.isArray(t)?new T(t[0],t[1]):t}}const{setRTLTextPlugin:Ht,getRTLTextPluginStatus:Dt,LngLat:Ft,LngLatBounds:qt,MercatorCoordinate:Vt,Evented:zt,AJAXError:Wt,prewarm:Jt,clearPrewarmedResources:Zt,version:Yt,workerCount:Xt,maxParallelImageRequests:Qt,workerUrl:te,addProtocol:ee,removeProtocol:re}=a,ne=a.Map,ie=a.Marker,ae=a.Popup,oe=a.Style,se=a.CanvasSource,le=a.GeoJSONSource,ce=a.ImageSource,he=a.RasterTileSource,ue=a.RasterDEMTileSource,ge=a.VectorTileSource,de=a.VideoSource;a.NavigationControl,a.GeolocateControl,a.AttributionControl,a.LogoControl,a.ScaleControl,a.FullscreenControl,a.TerrainControl;export{Wt as AJAXError,z as AttributionControl,Mt as CanvasSource,se as CanvasSourceMLGL,zt as Evented,J as FullscreenControl,Ut as GeoJSONSource,le as GeoJSONSourceMLGL,j as GeolocateControl,X as GeolocationType,kt as ImageSource,ce as ImageSourceMLGL,f as Language,Te as LanguageGeocoding,Ft as LngLat,qt as LngLatBounds,N as LogoControl,Rt as Map,ne as MapMLGL,Ce as MapStyle,be as MapStyleVariant,V as MaptilerGeolocateControl,v as MaptilerLogoControl,K as MaptilerNavigationControl,$ as MaptilerTerrainControl,Nt as Marker,ie as MarkerMLGL,Vt as MercatorCoordinate,G as NavigationControl,T as Point,Pt as Popup,ae as PopupMLGL,$t as RasterDEMTileSource,ue as RasterDEMTileSourceMLGL,Bt as RasterTileSource,he as RasterTileSourceMLGL,ve as ReferenceMapStyle,W as ScaleControl,R as SdkConfig,we as ServiceError,Ot as Style,oe as StyleMLGL,jt as TerrainControl,Gt as VectorTileSource,ge as VectorTileSourceMLGL,Kt as VideoSource,de as VideoSourceMLGL,ee as addProtocol,Zt as clearPrewarmedResources,L as config,Ee as coordinates,Ie as data,Re as geocoding,Ne as geolocation,Dt as getRTLTextPluginStatus,Qt as maxParallelImageRequests,Jt as prewarm,re as removeProtocol,Ht as setRTLTextPlugin,Pe as staticMaps,Yt as version,Xt as workerCount,te as workerUrl};
@@ -1,16 +1,22 @@
1
1
  import maplibregl__default from 'maplibre-gl';
2
2
  export * from 'maplibre-gl';
3
3
  import { Base64 } from 'js-base64';
4
- import { v4 } from 'uuid';
5
4
  import EventEmitter from 'events';
6
5
  import { config as config$1, MapStyle, mapStylePresetList, expandMapStyle, MapStyleVariant, ReferenceMapStyle, geolocation } from '@maptiler/client';
7
6
  export { LanguageGeocoding, MapStyle, MapStyleVariant, ReferenceMapStyle, ServiceError, coordinates, data, geocoding, geolocation, staticMaps } from '@maptiler/client';
7
+ import { v4 } from 'uuid';
8
8
 
9
9
  const Language = {
10
10
  /**
11
11
  * AUTO mode uses the language of the browser
12
12
  */
13
13
  AUTO: "auto",
14
+ /**
15
+ * STYLE is a custom flag to keep the language of the map as defined into the style.
16
+ * If STYLE is set in the constructor, then further modification of the language
17
+ * with `.setLanguage()` is not possible.
18
+ */
19
+ STYLE_LOCK: "style_lock",
14
20
  /**
15
21
  * Default fallback languages that uses latin charaters
16
22
  */
@@ -109,6 +115,7 @@ function getBrowserLanguage() {
109
115
  return canditatelangs.length ? canditatelangs[0] : Language.LATIN;
110
116
  }
111
117
 
118
+ const MAPTILER_SESSION_ID = v4();
112
119
  class SdkConfig extends EventEmitter {
113
120
  constructor() {
114
121
  super();
@@ -225,13 +232,10 @@ class MaptilerLogoControl extends LogoControl {
225
232
  anchor.style.width = "100px";
226
233
  anchor.style.height = "30px";
227
234
  anchor.target = "_blank";
228
- anchor.rel = "noopener nofollow";
235
+ anchor.rel = "noopener";
229
236
  anchor.href = this.linkURL;
230
- anchor.setAttribute(
231
- "aria-label",
232
- this._map._getUIString("LogoControl.Title")
233
- );
234
- anchor.setAttribute("rel", "noopener nofollow");
237
+ anchor.setAttribute("aria-label", "MapTiler logo");
238
+ anchor.setAttribute("rel", "noopener");
235
239
  this._container.appendChild(anchor);
236
240
  this._container.style.display = "block";
237
241
  this._map.on("resize", this._updateCompact);
@@ -240,6 +244,22 @@ class MaptilerLogoControl extends LogoControl {
240
244
  }
241
245
  }
242
246
 
247
+ var __defProp$2 = Object.defineProperty;
248
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
249
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
250
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
251
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
252
+ var __spreadValues$2 = (a, b) => {
253
+ for (var prop in b || (b = {}))
254
+ if (__hasOwnProp$2.call(b, prop))
255
+ __defNormalProp$2(a, prop, b[prop]);
256
+ if (__getOwnPropSymbols$2)
257
+ for (var prop of __getOwnPropSymbols$2(b)) {
258
+ if (__propIsEnum$2.call(b, prop))
259
+ __defNormalProp$2(a, prop, b[prop]);
260
+ }
261
+ return a;
262
+ };
243
263
  function enableRTL() {
244
264
  if (maplibregl__default.getRTLTextPluginStatus() === "unavailable") {
245
265
  maplibregl__default.setRTLTextPlugin(
@@ -271,6 +291,38 @@ function DOMremove(node) {
271
291
  node.parentNode.removeChild(node);
272
292
  }
273
293
  }
294
+ function maptilerCloudTransformRequest(url, resourceType) {
295
+ let reqUrl = null;
296
+ try {
297
+ reqUrl = new URL(url);
298
+ } catch (e) {
299
+ return {
300
+ url
301
+ };
302
+ }
303
+ if (reqUrl.host === defaults.maptilerApiHost) {
304
+ if (!reqUrl.searchParams.has("key")) {
305
+ reqUrl.searchParams.append("key", config.apiKey);
306
+ }
307
+ if (config.session) {
308
+ reqUrl.searchParams.append("mtsid", MAPTILER_SESSION_ID);
309
+ }
310
+ }
311
+ return {
312
+ url: reqUrl.href
313
+ };
314
+ }
315
+ function combineTransformRequest(userDefinedRTF = null) {
316
+ return function(url, resourceType) {
317
+ if (userDefinedRTF) {
318
+ const rp = userDefinedRTF(url, resourceType);
319
+ const rp2 = maptilerCloudTransformRequest(rp.url);
320
+ return __spreadValues$2(__spreadValues$2({}, rp), rp2);
321
+ } else {
322
+ return maptilerCloudTransformRequest(url);
323
+ }
324
+ };
325
+ }
274
326
 
275
327
  function styleToStyle(style) {
276
328
  if (!style) {
@@ -423,6 +475,7 @@ var __spreadValues$1 = (a, b) => {
423
475
  var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
424
476
  const Marker$1 = maplibregl__default.Marker;
425
477
  const LngLat$1 = maplibregl__default.LngLat;
478
+ const LngLatBounds$1 = maplibregl__default.LngLatBounds;
426
479
  class MaptilerGeolocateControl extends GeolocateControl {
427
480
  constructor() {
428
481
  super(...arguments);
@@ -450,7 +503,7 @@ class MaptilerGeolocateControl extends GeolocateControl {
450
503
  if (currentMapZoom > this.options.fitBoundsOptions.maxZoom) {
451
504
  options.zoom = currentMapZoom;
452
505
  }
453
- this._map.fitBounds(center.toBounds(radius), options, {
506
+ this._map.fitBounds(LngLatBounds$1.fromLngLat(center, radius), options, {
454
507
  geolocateSource: true
455
508
  // tag this camera change so it won't cause the control to change to background state
456
509
  });
@@ -629,7 +682,6 @@ var __async = (__this, __arguments, generator) => {
629
682
  step((generator = generator.apply(__this, __arguments)).next());
630
683
  });
631
684
  };
632
- const MAPTILER_SESSION_ID = v4();
633
685
  const GeolocationType = {
634
686
  POINT: "POINT",
635
687
  COUNTRY: "COUNTRY"
@@ -650,29 +702,7 @@ class Map extends maplibregl__default.Map {
650
702
  super(__spreadProps(__spreadValues({}, options), {
651
703
  style,
652
704
  maplibreLogo: false,
653
- transformRequest: (url) => {
654
- let reqUrl = null;
655
- try {
656
- reqUrl = new URL(url);
657
- } catch (e) {
658
- return {
659
- url,
660
- headers: {}
661
- };
662
- }
663
- if (reqUrl.host === defaults.maptilerApiHost) {
664
- if (!reqUrl.searchParams.has("key")) {
665
- reqUrl.searchParams.append("key", config.apiKey);
666
- }
667
- if (config.session) {
668
- reqUrl.searchParams.append("mtsid", MAPTILER_SESSION_ID);
669
- }
670
- }
671
- return {
672
- url: reqUrl.href,
673
- headers: {}
674
- };
675
- }
705
+ transformRequest: combineTransformRequest(options.transformRequest)
676
706
  }));
677
707
  this.isTerrainEnabled = false;
678
708
  this.terrainExaggeration = 1;
@@ -782,7 +812,11 @@ class Map extends maplibregl__default.Map {
782
812
  options.logoPosition
783
813
  );
784
814
  if (options.attributionControl === false) {
785
- this.addControl(new AttributionControl(options));
815
+ this.addControl(
816
+ new AttributionControl({
817
+ customAttribution: options.customAttribution
818
+ })
819
+ );
786
820
  }
787
821
  } else if (options.maptilerLogo) {
788
822
  this.addControl(new MaptilerLogoControl(), options.logoPosition);
@@ -924,6 +958,12 @@ class Map extends maplibregl__default.Map {
924
958
  * @param language
925
959
  */
926
960
  setPrimaryLanguage(language = defaults.primaryLanguage) {
961
+ if (this.primaryLanguage === Language.STYLE_LOCK) {
962
+ console.warn(
963
+ "The language cannot be changed because this map has been instantiated with the STYLE_LOCK language flag."
964
+ );
965
+ return;
966
+ }
927
967
  if (!isLanguageSupported(language)) {
928
968
  return;
929
969
  }
@@ -942,7 +982,7 @@ class Map extends maplibregl__default.Map {
942
982
  "case",
943
983
  ["has", langStr],
944
984
  ["get", langStr],
945
- ["get", "name:latin"]
985
+ ["get", "name"]
946
986
  ];
947
987
  for (let i = 0; i < layers.length; i += 1) {
948
988
  const layer = layers[i];
@@ -1003,6 +1043,12 @@ class Map extends maplibregl__default.Map {
1003
1043
  * @param language
1004
1044
  */
1005
1045
  setSecondaryLanguage(language = defaults.secondaryLanguage) {
1046
+ if (this.primaryLanguage === Language.STYLE_LOCK) {
1047
+ console.warn(
1048
+ "The language cannot be changed because this map has been instantiated with the STYLE_LOCK language flag."
1049
+ );
1050
+ return;
1051
+ }
1006
1052
  if (!isLanguageSupported(language)) {
1007
1053
  return;
1008
1054
  }
@@ -1303,6 +1349,21 @@ class Map extends maplibregl__default.Map {
1303
1349
  getMaptilerSessionId() {
1304
1350
  return MAPTILER_SESSION_ID;
1305
1351
  }
1352
+ /**
1353
+ * Updates the requestManager's transform request with a new function.
1354
+ *
1355
+ * @param transformRequest A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests.
1356
+ * Expected to return an object with a `url` property and optionally `headers` and `credentials` properties
1357
+ *
1358
+ * @returns {Map} `this`
1359
+ *
1360
+ * @example
1361
+ * map.setTransformRequest((url: string, resourceType: string) => {});
1362
+ */
1363
+ setTransformRequest(transformRequest) {
1364
+ super.setTransformRequest(combineTransformRequest(transformRequest));
1365
+ return this;
1366
+ }
1306
1367
  }
1307
1368
 
1308
1369
  class Marker extends maplibregl__default.Marker {
@@ -1657,7 +1718,7 @@ class Point {
1657
1718
  }
1658
1719
 
1659
1720
  const {
1660
- supported,
1721
+ // supported,
1661
1722
  setRTLTextPlugin,
1662
1723
  getRTLTextPluginStatus,
1663
1724
  LngLat,
@@ -1693,5 +1754,5 @@ maplibregl__default.ScaleControl;
1693
1754
  maplibregl__default.FullscreenControl;
1694
1755
  maplibregl__default.TerrainControl;
1695
1756
 
1696
- export { AJAXError, AttributionControl, CanvasSource, CanvasSourceMLGL, Evented, FullscreenControl, GeoJSONSource, GeoJSONSourceMLGL, GeolocateControl, GeolocationType, ImageSource, ImageSourceMLGL, Language, LngLat, LngLatBounds, LogoControl, Map, MapMLGL, MaptilerGeolocateControl, MaptilerLogoControl, MaptilerNavigationControl, MaptilerTerrainControl, Marker, MarkerMLGL, MercatorCoordinate, NavigationControl, Point, Popup, PopupMLGL, RasterDEMTileSource, RasterDEMTileSourceMLGL, RasterTileSource, RasterTileSourceMLGL, ScaleControl, SdkConfig, Style, StyleMLGL, TerrainControl, VectorTileSource, VectorTileSourceMLGL, VideoSource, VideoSourceMLGL, addProtocol, clearPrewarmedResources, config, getRTLTextPluginStatus, maxParallelImageRequests, prewarm, removeProtocol, setRTLTextPlugin, supported, version, workerCount, workerUrl };
1757
+ export { AJAXError, AttributionControl, CanvasSource, CanvasSourceMLGL, Evented, FullscreenControl, GeoJSONSource, GeoJSONSourceMLGL, GeolocateControl, GeolocationType, ImageSource, ImageSourceMLGL, Language, LngLat, LngLatBounds, LogoControl, Map, MapMLGL, MaptilerGeolocateControl, MaptilerLogoControl, MaptilerNavigationControl, MaptilerTerrainControl, Marker, MarkerMLGL, MercatorCoordinate, NavigationControl, Point, Popup, PopupMLGL, RasterDEMTileSource, RasterDEMTileSourceMLGL, RasterTileSource, RasterTileSourceMLGL, ScaleControl, SdkConfig, Style, StyleMLGL, TerrainControl, VectorTileSource, VectorTileSourceMLGL, VideoSource, VideoSourceMLGL, addProtocol, clearPrewarmedResources, config, getRTLTextPluginStatus, maxParallelImageRequests, prewarm, removeProtocol, setRTLTextPlugin, version, workerCount, workerUrl };
1697
1758
  //# sourceMappingURL=maptiler-sdk.mjs.map