From 29f63759d5efe66801576af7333e66b91ab06438 Mon Sep 17 00:00:00 2001 From: lstiz Date: Mon, 29 Jul 2024 12:28:25 +0200 Subject: [PATCH] 0.0.87 modified: time -->map.on --- dist/{index-ChqpbeXL.mjs => index-Cx8g3h7b.mjs} | 6 +++--- ...BWyxJuJN-FEZKbvRu.mjs => index.es-BWyxJuJN-DdIdVRyF.mjs} | 2 +- dist/mapicgc-gl.js | 2 +- dist/mapicgc-gl.mjs | 2 +- dist/mapicgc-gl.umd.js | 2 +- package.json | 2 +- src/map/Map.js | 4 ++-- test/exemples/addControl.html | 1 + 8 files changed, 11 insertions(+), 10 deletions(-) rename dist/{index-ChqpbeXL.mjs => index-Cx8g3h7b.mjs} (99%) rename dist/{index.es-BWyxJuJN-FEZKbvRu.mjs => index.es-BWyxJuJN-DdIdVRyF.mjs} (99%) diff --git a/dist/index-ChqpbeXL.mjs b/dist/index-Cx8g3h7b.mjs similarity index 99% rename from dist/index-ChqpbeXL.mjs rename to dist/index-Cx8g3h7b.mjs index c18fe2c..1eb17d4 100644 --- a/dist/index-ChqpbeXL.mjs +++ b/dist/index-Cx8g3h7b.mjs @@ -58966,7 +58966,7 @@ function(n) { */ function(n) { function e() { - return (Rn.canvg ? Promise.resolve(Rn.canvg) : import("./index.es-BWyxJuJN-FEZKbvRu.mjs")).catch(function(t) { + return (Rn.canvg ? Promise.resolve(Rn.canvg) : import("./index.es-BWyxJuJN-DdIdVRyF.mjs")).catch(function(t) { return Promise.reject(new Error("Could not load canvg: " + t)); }).then(function(t) { return t.default ? t.default : t; @@ -64729,11 +64729,11 @@ let Ah, $f, Sr, gi, oW = class { on(e, t) { setTimeout(() => { try { - this.map.on(e, t); + return this.map.on(e, t); } catch (i) { console.error(`Error adding event ON listener: ${i.message}`); } - }, 500); + }, 100); } /** * Sets the style of the map. diff --git a/dist/index.es-BWyxJuJN-FEZKbvRu.mjs b/dist/index.es-BWyxJuJN-DdIdVRyF.mjs similarity index 99% rename from dist/index.es-BWyxJuJN-FEZKbvRu.mjs rename to dist/index.es-BWyxJuJN-DdIdVRyF.mjs index b6d7e58..8dfcdc1 100644 --- a/dist/index.es-BWyxJuJN-FEZKbvRu.mjs +++ b/dist/index.es-BWyxJuJN-DdIdVRyF.mjs @@ -1,4 +1,4 @@ -import { p as Ui } from "./index-ChqpbeXL.mjs"; +import { p as Ui } from "./index-Cx8g3h7b.mjs"; var Zt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function No(i) { return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i; diff --git a/dist/mapicgc-gl.js b/dist/mapicgc-gl.js index 5553dba..214fc03 100644 --- a/dist/mapicgc-gl.js +++ b/dist/mapicgc-gl.js @@ -2579,7 +2579,7 @@ end`};t.events.push(["putFont",function(s){(function(a){var o=a.font,d=a.out,p=a `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t){const e=new this(t);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;se.set(a)),e}static accessor(t){const n=(this[f4]=this[f4]={accessors:{}}).accessors,i=this.prototype;function s(a){const o=Kg(a);n[o]||(Kit(i,a),n[o]=!0)}return Se.isArray(t)?t.forEach(s):s(t),this}}dl.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Se.reduceDescriptors(dl.prototype,(r,t)=>{let{value:e}=r,n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[n]=i}}}),Se.freezeMethods(dl);function ix(r,t){const e=this||qg,n=t||e,i=dl.from(n.headers);let s=n.data;return Se.forEach(r,function(o){s=o.call(e,s,i.normalize(),t?t.status:void 0)}),i.normalize(),s}function p4(r){return!!(r&&r.__CANCEL__)}function $g(r,t,e){In.call(this,r??"canceled",In.ERR_CANCELED,t,e),this.name="CanceledError"}Se.inherits($g,In,{__CANCEL__:!0});function $it(r,t,e){const n=e.config.validateStatus;!e.status||!n||n(e.status)?r(e):t(new In("Request failed with status code "+e.status,[In.ERR_BAD_REQUEST,In.ERR_BAD_RESPONSE][Math.floor(e.status/100)-4],e.config,e.request,e))}const Wit=Yc.hasStandardBrowserEnv?{write(r,t,e,n,i,s){const a=[r+"="+encodeURIComponent(t)];Se.isNumber(e)&&a.push("expires="+new Date(e).toGMTString()),Se.isString(n)&&a.push("path="+n),Se.isString(i)&&a.push("domain="+i),s===!0&&a.push("secure"),document.cookie=a.join("; ")},read(r){const t=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(r){this.write(r,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Xit(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function Jit(r,t){return t?r.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):r}function g4(r,t){return r&&!Xit(t)?Jit(r,t):t}const Yit=Yc.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),e=document.createElement("a");let n;function i(s){let a=s;return t&&(e.setAttribute("href",a),a=e.href),e.setAttribute("href",a),{href:e.href,protocol:e.protocol?e.protocol.replace(/:$/,""):"",host:e.host,search:e.search?e.search.replace(/^\?/,""):"",hash:e.hash?e.hash.replace(/^#/,""):"",hostname:e.hostname,port:e.port,pathname:e.pathname.charAt(0)==="/"?e.pathname:"/"+e.pathname}}return n=i(window.location.href),function(a){const o=Se.isString(a)?i(a):a;return o.protocol===n.protocol&&o.host===n.host}}():function(){return function(){return!0}}();function Zit(r){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return t&&t[1]||""}function tst(r,t){r=r||10;const e=new Array(r),n=new Array(r);let i=0,s=0,a;return t=t!==void 0?t:1e3,function(d){const p=Date.now(),y=n[s];a||(a=p),e[i]=d,n[i]=p;let b=s,x=0;for(;b!==i;)x+=e[b++],b=b%r;if(i=(i+1)%r,i===s&&(s=(s+1)%r),p-a{const s=i.loaded,a=i.lengthComputable?i.total:void 0,o=s-e,d=n(o),p=s<=a;e=s;const y={loaded:s,total:a,progress:a?s/a:void 0,bytes:o,rate:d||void 0,estimated:d&&a&&p?(a-s)/d:void 0,event:i};y[t?"download":"upload"]=!0,r(y)}}const sx={http:Lit,xhr:typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(e,n){let i=r.data;const s=dl.from(r.headers).normalize();let{responseType:a,withXSRFToken:o}=r,d;function p(){r.cancelToken&&r.cancelToken.unsubscribe(d),r.signal&&r.signal.removeEventListener("abort",d)}let y;if(Se.isFormData(i)){if(Yc.hasStandardBrowserEnv||Yc.hasStandardBrowserWebWorkerEnv)s.setContentType(!1);else if((y=s.getContentType())!==!1){const[M,...k]=y?y.split(";").map(z=>z.trim()).filter(Boolean):[];s.setContentType([M||"multipart/form-data",...k].join("; "))}}let b=new XMLHttpRequest;if(r.auth){const M=r.auth.username||"",k=r.auth.password?unescape(encodeURIComponent(r.auth.password)):"";s.set("Authorization","Basic "+btoa(M+":"+k))}const x=g4(r.baseURL,r.url);b.open(r.method.toUpperCase(),c4(x,r.params,r.paramsSerializer),!0),b.timeout=r.timeout;function C(){if(!b)return;const M=dl.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),z={data:!a||a==="text"||a==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:M,config:r,request:b};$it(function($){e($),p()},function($){n($),p()},z),b=null}if("onloadend"in b?b.onloadend=C:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(C)},b.onabort=function(){b&&(n(new In("Request aborted",In.ECONNABORTED,r,b)),b=null)},b.onerror=function(){n(new In("Network Error",In.ERR_NETWORK,r,b)),b=null},b.ontimeout=function(){let k=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const z=r.transitional||A4;r.timeoutErrorMessage&&(k=r.timeoutErrorMessage),n(new In(k,z.clarifyTimeoutError?In.ETIMEDOUT:In.ECONNABORTED,r,b)),b=null},Yc.hasStandardBrowserEnv&&(o&&Se.isFunction(o)&&(o=o(r)),o||o!==!1&&Yit(x))){const M=r.xsrfHeaderName&&r.xsrfCookieName&&Wit.read(r.xsrfCookieName);M&&s.set(r.xsrfHeaderName,M)}i===void 0&&s.setContentType(null),"setRequestHeader"in b&&Se.forEach(s.toJSON(),function(k,z){b.setRequestHeader(z,k)}),Se.isUndefined(r.withCredentials)||(b.withCredentials=!!r.withCredentials),a&&a!=="json"&&(b.responseType=r.responseType),typeof r.onDownloadProgress=="function"&&b.addEventListener("progress",m4(r.onDownloadProgress,!0)),typeof r.onUploadProgress=="function"&&b.upload&&b.upload.addEventListener("progress",m4(r.onUploadProgress)),(r.cancelToken||r.signal)&&(d=M=>{b&&(n(!M||M.type?new $g(null,r,b):M),b.abort(),b=null)},r.cancelToken&&r.cancelToken.subscribe(d),r.signal&&(r.signal.aborted?d():r.signal.addEventListener("abort",d)));const P=Zit(x);if(P&&Yc.protocols.indexOf(P)===-1){n(new In("Unsupported protocol "+P+":",In.ERR_BAD_REQUEST,r));return}b.send(i||null)})}};Se.forEach(sx,(r,t)=>{if(r){try{Object.defineProperty(r,"name",{value:t})}catch{}Object.defineProperty(r,"adapterName",{value:t})}});const y4=r=>`- ${r}`,est=r=>Se.isFunction(r)||r===null||r===!1,_4={getAdapter:r=>{r=Se.isArray(r)?r:[r];const{length:t}=r;let e,n;const i={};for(let s=0;s{let[d,p]=o;return`adapter ${d} `+(p===!1?"is not supported by the environment":"is not available in the build")});let a=t?s.length>1?`since : `+s.map(y4).join(` `):" "+y4(s[0]):"as no adapter specified";throw new In("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return n},adapters:sx};function ox(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new $g(null,r)}function v4(r){return ox(r),r.headers=dl.from(r.headers),r.data=ix.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),_4.getAdapter(r.adapter||qg.adapter)(r).then(function(n){return ox(r),n.data=ix.call(r,r.transformResponse,n),n.headers=dl.from(n.headers),n},function(n){return p4(n)||(ox(r),n&&n.response&&(n.response.data=ix.call(r,r.transformResponse,n.response),n.response.headers=dl.from(n.response.headers))),Promise.reject(n)})}const b4=r=>r instanceof dl?{...r}:r;function Hf(r,t){t=t||{};const e={};function n(p,y,b){return Se.isPlainObject(p)&&Se.isPlainObject(y)?Se.merge.call({caseless:b},p,y):Se.isPlainObject(y)?Se.merge({},y):Se.isArray(y)?y.slice():y}function i(p,y,b){if(Se.isUndefined(y)){if(!Se.isUndefined(p))return n(void 0,p,b)}else return n(p,y,b)}function s(p,y){if(!Se.isUndefined(y))return n(void 0,y)}function a(p,y){if(Se.isUndefined(y)){if(!Se.isUndefined(p))return n(void 0,p)}else return n(void 0,y)}function o(p,y,b){if(b in t)return n(p,y);if(b in r)return n(void 0,p)}const d={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:o,headers:(p,y)=>i(b4(p),b4(y),!0)};return Se.forEach(Object.keys(Object.assign({},r,t)),function(y){const b=d[y]||i,x=b(r[y],t[y],y);Se.isUndefined(x)&&b!==o||(e[y]=x)}),e}const w4="1.6.8",ax={};["object","boolean","number","function","string","symbol"].forEach((r,t)=>{ax[r]=function(n){return typeof n===r||"a"+(t<1?"n ":" ")+r}});const x4={};ax.transitional=function(t,e,n){function i(s,a){return"[Axios v"+w4+"] Transitional option '"+s+"'"+a+(n?". "+n:"")}return(s,a,o)=>{if(t===!1)throw new In(i(a," has been removed"+(e?" in "+e:"")),In.ERR_DEPRECATED);return e&&!x4[a]&&(x4[a]=!0,console.warn(i(a," has been deprecated since v"+e+" and will be removed in the near future"))),t?t(s,a,o):!0}};function rst(r,t,e){if(typeof r!="object")throw new In("options must be an object",In.ERR_BAD_OPTION_VALUE);const n=Object.keys(r);let i=n.length;for(;i-- >0;){const s=n[i],a=t[s];if(a){const o=r[s],d=o===void 0||a(o,s,r);if(d!==!0)throw new In("option "+s+" must be "+d,In.ERR_BAD_OPTION_VALUE);continue}if(e!==!0)throw new In("Unknown option "+s,In.ERR_BAD_OPTION)}}const lx={assertOptions:rst,validators:ax},$A=lx.validators;class sd{constructor(t){this.defaults=t,this.interceptors={request:new u4,response:new u4}}async request(t,e){try{return await this._request(t,e)}catch(n){if(n instanceof Error){let i;Error.captureStackTrace?Error.captureStackTrace(i={}):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=` -`+s):n.stack=s}throw n}}_request(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=Hf(this.defaults,e);const{transitional:n,paramsSerializer:i,headers:s}=e;n!==void 0&&lx.assertOptions(n,{silentJSONParsing:$A.transitional($A.boolean),forcedJSONParsing:$A.transitional($A.boolean),clarifyTimeoutError:$A.transitional($A.boolean)},!1),i!=null&&(Se.isFunction(i)?e.paramsSerializer={serialize:i}:lx.assertOptions(i,{encode:$A.function,serialize:$A.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let a=s&&Se.merge(s.common,s[e.method]);s&&Se.forEach(["delete","get","head","post","put","patch","common"],P=>{delete s[P]}),e.headers=dl.concat(a,s);const o=[];let d=!0;this.interceptors.request.forEach(function(M){typeof M.runWhen=="function"&&M.runWhen(e)===!1||(d=d&&M.synchronous,o.unshift(M.fulfilled,M.rejected))});const p=[];this.interceptors.response.forEach(function(M){p.push(M.fulfilled,M.rejected)});let y,b=0,x;if(!d){const P=[v4.bind(this),void 0];for(P.unshift.apply(P,o),P.push.apply(P,p),x=P.length,y=Promise.resolve(e);b{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const a=new Promise(o=>{n.subscribe(o),s=o}).then(i);return a.cancel=function(){n.unsubscribe(s)},a},t(function(s,a,o){n.reason||(n.reason=new $g(s,a,o),e(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);e!==-1&&this._listeners.splice(e,1)}static source(){let t;return{token:new cx(function(i){t=i}),cancel:t}}}function nst(r){return function(e){return r.apply(null,e)}}function ist(r){return Se.isObject(r)&&r.isAxiosError===!0}const ux={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ux).forEach(r=>{let[t,e]=r;ux[e]=t});function B4(r){const t=new sd(r),e=KP(sd.prototype.request,t);return Se.extend(e,sd.prototype,t,{allOwnKeys:!0}),Se.extend(e,t,null,{allOwnKeys:!0}),e.create=function(i){return B4(Hf(r,i))},e}const as=B4(qg);as.Axios=sd,as.CanceledError=$g,as.CancelToken=cx,as.isCancel=p4,as.VERSION=w4,as.toFormData=Xy,as.AxiosError=In,as.Cancel=as.CanceledError,as.all=function(t){return Promise.all(t)},as.spread=nst,as.isAxiosError=ist,as.mergeConfig=Hf,as.AxiosHeaders=dl,as.formToJSON=r=>d4(Se.isHTMLForm(r)?new FormData(r):r),as.getAdapter=_4.getAdapter,as.HttpStatusCode=ux,as.default=as;const sst="https://tilemaps.icgc.cat/cdn/configs/mapicgc-config.json",ost=5e3;class C4{static async getConfigICGC(){try{const t=await as.get(sst,{timeout:ost});return t.data?t.data:(console.log("Resposta sense dades:",t),id)}catch(t){return t.response?(console.error("Error de resposta:",t.response.data),console.error("Codi d'estat:",t.response.status)):t.request?console.error("No s'ha rebut resposta del servidor:",t.request):console.error("Error:",t.message),id}}}const ast={cobertesSol:{"fill-opacity":["interpolate",["exponential",.5],["zoom"],13.5,1,18,.4],"fill-outline-color":"rgba(0,0, 0, 0)","fill-color":["interpolate",["cubic-bezier",.5,1,1,1],["get","nivell_2"],0,"#ffffff",111,"#ffff00",112,"#ccff33",113,"#af5b15",114,"#808000",115,"#cdcd00",116,"#ffffcc",221,"#33cc33",222,"#66ff33",223,"#689018",224,"#967d5f",225,"#19e61e",226,"#b4ff9b",227,"#aaa500",228,"#c3c3a0",229,"#00ff9b",230,"#ff9632",231,"#282828",232,"#79797a",233,"#f5df78",234,"#3296ff",341,"#ff007d",342,"#ff53cd",343,"#ffa4e2",344,"#ffc8e2",345,"#ffb4b4",346,"#0f3700",347,"#730055",348,"#6200c4",349,"#4a9595",350,"#ff00f0",351,"#adaaca",352,"#ffe6e6",353,"#67629a",354,"#4a466e",355,"#2f2d46",461,"#6f6fff",462,"#0000dc",463,"#000064",464,"#185f94",465,"#12466d",466,"#000080"]}},lst="lines",Yy="labels";let od,Wg,Qi,Pn,cst=class{constructor(t){C4.getConfigICGC().then(e=>{od={...e.Styles},Qi={...e.Layers},Wg={...e.Terrains},Pn={...e.defaultOptions},this.initTheMap(t)}).catch(e=>{console.info("Configuracio per defecte",e),od={...id.Styles},Qi={...id.Layers},Wg={...id.Terrains},Pn={...id.defaultOptions},this.initTheMap(t)})}initTheMap(t){if(!t)t=Pn.mapOptions;else for(const e in Pn.mapOptions){let n=[Pn.mapOptions.center[0],Pn.mapOptions.center[1]];Pn.mapOptions.center=n,t.hasOwnProperty(e)||(t[e]=Pn.mapOptions[e])}t.maxPitch=85,t.maplibreLogo=!1,t.attributionControl=!1,this.map=new Ls.Map(t),this.map.options=t,this.map.addControl(new Ls.AttributionControl({compact:!0})),this.map.on("load",async()=>{const e=this.map.getStyle().name,n=this.map.options.style;if(window.document.querySelector(".maplibregl-compact-show")){var i=window.document.querySelector(".maplibregl-compact-show");i.classList.remove("maplibregl-compact-show")}this.map.addControl(new Knt({color:n.indexOf("orto")===-1,defaultOptions:Pn}),"bottom-left"),this._dealOrto3dStyle(e)})}addGeocoderICGC(t){try{t===void 0&&(t="top-right");let e={collapsed:!0,marker:!0,popup:!0,showResultMarkers:!0,maplibregl:Ls,showResultsWhileTyping:!0,minLength:2};const n={forwardGeocode:async s=>{const a=[];try{const o=Pn.geocoder.peliasUrl1+encodeURIComponent(s.query)+Pn.geocoder.peliasUrl2,p=await(await fetch(o)).json();for(const y of p.features){const b=y.geometry.coordinates,x={type:"Feature",geometry:{type:"Point",coordinates:b},place_name:y.properties.etiqueta,properties:y.properties,text:y.properties.etiqueta,place_type:["place"],center:b};a.push(x)}}catch(o){console.error(`Failed to forwardGeocode with error: ${o}`)}return{features:a}}};this.map.addControl(new qnt(n,e),t);let i=document.getElementsByClassName("maplibregl-ctrl-geocoder--input");i[0].attributes[2].nodeValue="Cerca...",i[0].addEventListener("input",function(s){s.target.value.length>3})}catch(e){console.error(`Error adding ICGC geocoder: ${e.message}`)}}async loadImage(t){try{return this.map.loadImage(t)}catch(e){console.error(`Error getting loadImage: ${e.message}`)}}getConfigStyles(){try{let t=[];for(const e of od)t.push(e.name);return t}catch(t){console.error(`Error retrieving base styles: ${t.message}`)}}getConfigWMSLayers(){try{let t=[];for(const e in Qi.WMS)Qi.WMS.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving WMS layers: ${t.message}`)}}getConfigOrtoLayers(){try{let t=[];for(const e in Qi.Orto)Qi.Orto.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving orto image layers: ${t.message}`)}}getConfigVectorLayers(){try{let t=[];for(const e in Qi.Vector)Qi.Vector.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving vector layers: ${t.message}`)}}getConfigVectorAdminLayers(){try{let t=[];for(const e in Qi.VectorAdmin)Qi.VectorAdmin.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving vectorAdmin layers: ${t.message}`)}}getConfigFGBAdminLayers(){try{let t=[];for(const e in Qi.FGBAdmin)Qi.FGBAdmin.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving FGBAdmin layers: ${t.message}`)}}async fetchData(t,e,n){try{(!n||n===void 0)&&(n={type:"line",layout:{visibility:"visible"},paint:{"line-color":"grey","line-width":2},layerPosition:"top"});let i=n.layerPosition;if(t.includes(".fgb"))this.addFGBLayerICGC(t,e,n);else{const a=await(await fetch(t)).json();let o=e,d=this._dealOrderLayer(i),p=a.features[0].geometry.type;p.includes("ine")&&(n!==void 0?this.map.addLayer({id:o,type:"line",source:{type:"geojson",data:a},layout:n.layout||{},paint:n.paint||{}},d):this.map.addLayer({id:o,type:"line",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"line-color":"black","line-width":2,"line-opacity":1}},d)),p.includes("olygon")&&(n!==void 0?this.map.addLayer({id:o,type:"fill",source:{type:"geojson",data:a},layout:n.layout,paint:n.paint},d):this.map.addLayer({id:o,type:"fill",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"fill-color":"blue","fill-opacity":.6}},d)),p.includes("oint")&&(n!==void 0?this.map.addLayer({id:o,type:"circle",source:{type:"geojson",data:a},layout:n.layout,paint:n.paint},d):this.map.addLayer({id:o,type:"circle",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"circle-color":"red","circle-opacity":.85}},d))}}catch(i){console.error(`Error fetching data: ${i.message}`)}}async fetchDataAndMenu(t,e,n,i){try{let s;i!==null?s=i.layerPosition:s=Yy;let a,o=document.getElementById("map");if(document.getElementById("menu-group")?a=document.getElementById("menu-group"):(a=document.createElement("nav"),a.id="menu-group",a.classList.add="filter-group",o.appendChild(a)),a!==null){let d="visible",p=this._dealOrderLayer(s),y;if(t.includes(".fgb")){let x=this._getKeyByUrlFGB(t);x===null&&(x="userFGB");const C=await fetch(t),P={type:"FeatureCollection",features:[]};for await(const k of US(C.body))P.features.push(k);y=P;let M=e;if(this.map.addSource(M,{type:"geojson",data:P}),t.includes("text"))i!==void 0?this.map.addLayer({id:e,type:"symbol",source:M,layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"symbol",source:M,layout:{"text-letter-spacing":.1,"text-size":{base:1.2,stops:[[8,0],[12,14],[15,15]]},"text-font":["FiraSans-Regular"],"text-field":["get","NOM_AC"],"text-transform":"none","text-max-width":25,visibility:d,"text-justify":"right","text-anchor":"top","text-allow-overlap":!1,"symbol-spacing":2,"text-line-height":1},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},p);else{let k=e+"Text";this.map.addLayer({id:k,type:"symbol",source:M,layout:{"text-letter-spacing":.1,"text-size":{base:1.2,stops:[[8,0],[12,14],[15,15]]},"text-font":["FiraSans-Regular"],"text-field":["get","NOM_AC"],"text-transform":"none","text-max-width":25,visibility:d,"text-justify":"right","text-anchor":"top","text-allow-overlap":!1,"symbol-spacing":2,"text-line-height":1},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},p)}}else y=await(await fetch(t)).json();if(n!=="all"){const x=document.createElement("div");x.id="titleDivMenu",x.textContent=e,a.appendChild(x);const C=document.createElement("div");C.id="titleDivMenuSub",C.textContent=`📂 ${n}`,a.appendChild(C)}let b;if(i.type?b=i.type:b=y.features[0].geometry.type,n==="all")b.includes("ine")&&(i!==void 0?this.map.addLayer({id:e,type:"line",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"line",source:{type:"geojson",data:y},layout:{visibility:"visible"},paint:{"line-color":"black","line-width":2,"line-opacity":1}},p)),b.includes("olygon")&&(i!==void 0?this.map.addLayer({id:e,type:"fill",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"fill",source:{type:"geojson",data:y},layout:{visibility:"visible"},paint:{"fill-color":"#0000FF","fill-opacity":0}},p)),b.includes("oint")&&(i!==void 0?this.map.addLayer({id:e,type:"circle",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"circle",source:{type:"geojson",data:y},layout:{visibility:"visible"},paint:{"circle-color":"red","circle-opacity":.85}},p)),b.includes("ymbol")&&(i!==void 0?this.map.addLayer({id:e,type:"symbol",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"symbol",source:{type:"geojson",data:y},layout:{visibility:"visible"},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},p)),this.addMenuItem(e);else{let x=n;const C={};y.features.forEach(P=>{const M=P.properties[x],k=M+"-userFieldFilter-"+e;M!==null&&(C[k]||(b.includes("ine")&&(i!==void 0?this.map.addLayer({id:k,type:"line",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint,filter:["==",`${x}`,M]},p):this.map.addLayer({id:k,type:"line",source:{type:"geojson",data:y},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"line-color":"black","line-width":2,"line-opacity":1}},p)),b.includes("olygon")&&(i!==void 0?this.map.addLayer({id:k,type:"fill",source:{type:"geojson",data:y},filter:["==",`${x}`,M],layout:i.layout,paint:i.paint},p):this.map.addLayer({id:k,type:"fill",source:{type:"geojson",data:y},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"fill-color":"blue","fill-opacity":.6}},p)),b.includes("oint")&&(i!==void 0?this.map.addLayer({id:k,type:"circle",source:{type:"geojson",data:y},filter:["==",`${x}`,M],layout:i.layout,paint:i.paint},p):this.map.addLayer({id:k,type:"circle",source:{type:"geojson",data:y},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"circle-color":"red","circle-opacity":.85}},p)),C[k]=!0,this.addMenuItem(k)))})}}}catch(s){console.error(`Error fetching data: ${s.message}`)}}on(t,e){setTimeout(()=>{try{this.map.on(t,e)}catch(n){console.error(`Error adding event ON listener: ${n.message}`)}},500)}setStyle(t,e){try{e!==void 0?this.map.setStyle(t,e):this.map.setStyle(t),this.map.on("styledata",()=>{if(window.document.querySelector(".maplibregl-compact-show")){var n=window.document.querySelector(".maplibregl-compact-show");n.classList.remove("maplibregl-compact-show")}this._dealOrto3dStyle(this.map.getStyle().name)})}catch(n){console.error(`Error setting style: ${n.message}`)}}addControl(t,e){try{e===void 0&&(e="top-right"),this.map.addControl(t,e)}catch(n){console.error(`Error adding control: ${n.message}`)}}setSky(t){try{t===void 0&&(this.map.options.style.includes("orto")&&(t={"sky-color":"#86bbd5","sky-horizon-blend":.3,"horizon-color":"#ffffff33","horizon-fog-blend":.1,"fog-ground-blend":.75,"fog-color":"#c5d6d6"}),this.map.options.style.includes("mapa_estandard_general")&&(t={"sky-color":"#a5f0f0","sky-horizon-blend":.3,"horizon-color":"#e1e3e3","horizon-fog-blend":.9,"fog-ground-blend":.85,"fog-color":"#c5d6d6"}),this.map.options.style.includes("fosc")&&(t={"sky-color":"#232423","sky-horizon-blend":.3,"horizon-color":"#969996","horizon-fog-blend":.9,"fog-ground-blend":.85,"fog-color":"#383838"})),this.map.setSky(t)}catch(e){console.error(`Error setting sky properties: ${e.message}`)}}addMouseCoordControl(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"bottom-left";try{this.map.addControl(new Jnt(t),e)}catch(n){console.error(`Error adding mouse coordinate control: ${n.message}`)}}addGeolocateControl(t,e){try{e===void 0&&(e="top-right"),t===void 0?this.map.addControl(new Ls.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!0}),e):this.map.addControl(new Ls.GeolocateControl(t),e)}catch(n){console.error(`Error adding geolocate control: ${n.message}`)}}addFullscreenControl(t,e){try{e===void 0&&(e="top-right"),t===void 0?this.map.addControl(new Ls.FullscreenControl({container:HTMLElement}),e):this.map.addControl(new Ls.FullscreenControl(t),e)}catch(n){console.error(`Error adding fullscreen control: ${n.message}`)}}addLayer(t,e){try{this.map.addLayer(t,e)}catch(n){console.error(`Error adding layer: ${n.message}`)}}addImage(t,e,n){try{this.map.addImage(t,e,n)}catch(i){console.error(`Error adding image: ${i.message}`)}return this}addSource(t,e){try{this.map.addSource(t,e)}catch(n){console.error(`Error adding source: ${n.message}`)}return this}addSprite(t,e,n){try{this.map.addSprite(t,e,n)}catch(i){console.error(`Error adding sprite: ${i.message}`)}return this}areTilesLoaded(){return this.map.areTilesLoaded()}cameraForBounds(t,e){return this.map.cameraForBounds(t,e)}easeTo(t,e){return this.map.easeTo(t,e),this}fitBounds(t,e,n){return this.map.fitBounds(t,e,n),this}fitScreenCoordinates(t,e,n,i,s){return this.map.fitScreenCoordinates(t,e,n,i,s),this}flyTo(t,e){return this.map.flyTo(t,e),this}getBearing(){return this.map.getBearing()}getBounds(){return this.map.getBounds()}getCameraTargetElevation(){return this.map.getCameraTargetElevation()}getCanvas(){return this.map.getCanvas()}getCanvasContainer(){return this.map.getCanvasContainer()}getCenter(){return this.map.getCenter()}getContainer(){return this.map.getContainer()}getFeatureState(t){return this.map.getFeatureState(t)}getFilter(t){return this.map.getFilter(t)}getGlyphs(){return this.map.getGlyphs()}getImage(t){return this.map.getImage(t)}getLayer(t){return this.map.getLayer(t)}getLayersOrder(){return this.map.getLayersOrder()}getLayoutProperty(t,e){return this.map.getLayoutProperty(t,e)}getLight(){return this.map.getLight()}getMaxBounds(){return this.map.getMaxBounds()}getMaxPitch(){return this.map.getMaxPitch()}getMaxZoom(){return this.map.getMaxZoom()}getMinPitch(){return this.map.getMinPitch()}getMinZoom(){return this.map.getMinZoom()}getPadding(){return this.map.getPadding()}getPaintProperty(t,e){return this.map.getPaintProperty(t,e)}getPitch(){return this.map.getPitch()}getPixelRatio(){return this.map.getPixelRatio()}getRenderWorldCopies(){return this.map.getRenderWorldCopies()}getSource(t){return this.map.getSource(t)}getSprite(){return this.map.getSprite()}getStyle(){return this.map.getStyle()}getTerrain(){return this.map.getTerrain()}getZoom(){return this.map.getZoom()}hasControl(t){return this.map.hasControl(t)}hasImage(t){return this.map.hasImage(t)}isMoving(){return this.map.isMoving()}isRotating(){return this.map.isRotating()}isSourceLoaded(t){return this.map.isSourceLoaded(t)}isStyleLoaded(){return this.map.isStyleLoaded()}isZooming(){return this.map.isZooming()}jumpTo(t,e){return this.map.jumpTo(t,e)}listImages(){return this.map.listImages()}listens(t){return this.map.listens(t)}loadImage(t){return this.map.loadImage(t)}loaded(){return this.map.loaded()}LngLatBounds(t,e){return new Ls.LngLatBounds(t,e)}addProtocol(t,e){return this.map.addProtocol(t,e)}moveLayer(t,e){return this.map.moveLayer(t,e)}panBy(t,e,n){return this.map.panBy(t,e,n)}panTo(t,e,n){return this.map.panTo(t,e,n)}project(t){return this.map.project(t)}queryRenderedFeatures(t,e){return this.map.queryRenderedFeatures(t,e)}querySourceFeatures(t,e){return this.map.querySourceFeatures(t,e)}queryTerrainElevation(t){return this.map.queryTerrainElevation(t)}redraw(){return this.map.redraw()}remove(){return this.map.remove()}removeControl(t){return this.map.removeControl(t)}removeFeatureState(t,e){return this.map.removeFeatureState(t,e)}removeImage(t){return this.map.removeImage(t)}removeLayer(t){try{this.map.removeLayer(t)}catch(e){console.error(`Error removing layer: ${e.message}`)}}removeSource(t){try{this.map.removeSource(t)}catch(e){console.error(`Error removing source: ${e.message}`)}}removeSprite(t){return this.map.removeSprite(t)}resetNorth(t,e){return this.map.resetNorth(t,e)}resetNorthPitch(t,e){return this.map.resetNorthPitch(t,e)}resize(t){return this.map.resize(t)}rotateTo(t,e,n){return this.map.rotateTo(t,e,n)}setBearing(t,e){return this.map.setBearing(t,e)}setCenter(t,e){return this.map.setCenter(t,e)}setEventedParent(t,e){return this.map.setEventedParent(t,e)}setFeatureState(t,e){return this.map.setFeatureState(t,e)}setFilter(t,e,n){return this.map.setFilter(t,e,n)}setGlyphs(t,e){return this.map.setGlyphs(t,e)}setLayerZoomRange(t,e,n){return this.map.setLayerZoomRange(t,e,n)}setLayoutProperty(t,e,n,i){return this.map.setLayoutProperty(t,e,n,i)}setLight(t,e){return this.map.setLight(t,e)}setMaxBounds(t){return this.map.setMaxBounds(t)}setMaxPitch(t){return this.map.setMaxPitch(t)}setMaxZoom(t){return this.map.setMaxZoom(t)}setMinPitch(t){return this.map.setMinPitch(t)}setMinZoom(t){return this.map.setMinZoom(t)}setPadding(t,e){return this.map.setPadding(t,e)}setPaintProperty(t,e,n,i){return this.map.setPaintProperty(t,e,n,i)}setPitch(t,e){return this.map.setPitch(t,e)}setPixelRatio(t){return this.map.setPixelRatio(t)}setRenderWorldCopies(t){return this.map.setRenderWorldCopies(t)}setSprite(t,e){return this.map.setSprite(t,e)}setTerrain(t){return this.map.setTerrain(t)}setTransformRequest(t){return this.map.setTransformRequest(t)}setZoom(t,e){return this.map.setZoom(t,e)}snapToNorth(t,e){return this.map.snapToNorth(t,e)}stop(){return this.map.stop()}triggerRepaint(){return this.map.triggerRepaint()}unproject(t){return this.map.unproject(t)}updateImage(t,e){return this.map.updateImage(t,e)}zoomIn(t,e){return this.map.zoomIn(t,e)}zoomOut(t,e){return this.map.zoomOut(t,e)}zoomTo(t,e,n){return this.map.zoomTo(t,e,n)}addLayerGeoJSON(t,e){try{let n=this._dealOrderLayer(e);this.map.addSource(`${t.id}`,{type:"geojson",data:t.data}),this.map.addLayer({id:`${t.id}-layerIcgcMap`,type:t.type,source:`${t.id}`,layout:t.layout,paint:t.paint},n)}catch(n){console.error(`Error adding GeoJSON layer: ${n.message}`)}}addLayerWMS(t,e,n){try{let i=this._dealOrderLayer(n.layerPosition);n?(this.map.addSource(`${e}`,{type:"raster",tiles:[t],tileSize:256},i),this.map.addLayer({id:e,type:"raster",source:e,layout:n.layout,paint:n.paint},i)):(this.map.addSource(`${e}`,{type:"raster",tiles:[t],tileSize:256},i),this.map.addLayer({id:e,type:"raster",source:e,paint:{}},i))}catch(i){console.error(`Error adding WMS layer: ${i.message}`)}}addLogo(t){try{let e=document.getElementById("map"),n;n=document.createElement("div"),n.id="logos",e.appendChild(n);const i=document.createElement("img");i.src=t.url,i.style.height=t.height;const s=document.getElementById("logos"),a=document.createElement("a");a.id=t.id,a.href=t.href,a.target="_blank",a.style.position="relative",a.style.bottom="1px",a.appendChild(i),s.appendChild(a)}catch(e){console.error(`Error adding logo: ${e.message}`)}}addBasemapsICGC(t){try{const e=a=>{this.map.setStyle(a)};let n=document.getElementById("map"),i;i=document.createElement("div"),i.id="basemap-group",i.classList.add="filter-group",n.appendChild(i);const s=document.getElementById("basemap-group");for(const a of t)for(const o of Object.keys(Pn.baseStyles)){const d=Pn.baseStyles[o];if(a===d.url){const p=document.createElement("div");p.className="basemap-item",p.title=d.key,p.style.backgroundImage=`url('${d.image}')`,s.appendChild(p),p.addEventListener("click",()=>e(d.url))}}}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addBasemaps(t){try{const e=a=>{map.setStyle(a.url)};let n=document.getElementById("map"),i;i=document.createElement("div"),i.id="basemap-group",i.classList.add="basemap-group",n.appendChild(i);const s=document.getElementById("basemap-group");t.forEach(a=>{const o=document.createElement("div");o.className="basemap-item",o.title=a.label,o.style.backgroundImage=`url('${a.image}')`,s.appendChild(o),o.addEventListener("click",()=>e(a))})}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addFeatureQuery(t,e,n){try{let i;this.map.on("mouseenter",t,()=>{this.map.getCanvas().style.cursor="pointer"}),this.map.on("mouseleave",t,()=>{this.map.getCanvas().style.cursor=""}),this.map.on("click",s=>{let a=this.map.queryRenderedFeatures(s.point);if(a&&a[0].source.includes(t)){let o=[s.lngLat.lng,s.lngLat.lat];if(e!==void 0&&e.length>0&&e!=="all"){if(e!==null){let d="";e.forEach(p=>{let y=a[0].properties[p];d=d+`

${y}

`}),i=d,this.addPopup(o,i,n)}}else{let d="";for(const p in a[0].properties)d+=""+p+":"+a[0].properties[p]+"
";i=d,this.addPopup(o,i,n)}}})}catch(i){console.error(`Error adding feature query: ${i.message}`)}}addScaleControl(t,e){try{var n=new Ls.ScaleControl(t);this.map.addControl(n,e)}catch(i){console.error(`Error adding scale: ${i.message}`)}}addExportControl(t,e){try{typeof t=="string"&&(e=t,t=void 0),t===void 0&&(t={PageSize:Zh.A4,PageOrientation:Ng.Landscape,Format:Vu.PNG,DPI:x2[300],Crosshair:!0,PrintableArea:!0,Local:"ca"},e="top-right"),this.map.addControl(new rnt(t),e)}catch(n){console.error(`Error adding export control: ${n.message}`)}}addMarker(t){try{let e,n;return t.text===void 0?e=new Ls.Marker(t.options).setLngLat(t.coord).addTo(this.map):(n=new Ls.Popup({offset:t.textOffset}).setHTML(t.text),e=new Ls.Marker(t.options).setLngLat(t.coord).setPopup(n).addTo(this.map)),e}catch(e){return console.error(`Error adding marker: ${e.message}`),null}}addPopup(t,e,n){try{return n.image===void 0?new Ls.Popup().setLngLat(t).setHTML(` +`+s):n.stack=s}throw n}}_request(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=Hf(this.defaults,e);const{transitional:n,paramsSerializer:i,headers:s}=e;n!==void 0&&lx.assertOptions(n,{silentJSONParsing:$A.transitional($A.boolean),forcedJSONParsing:$A.transitional($A.boolean),clarifyTimeoutError:$A.transitional($A.boolean)},!1),i!=null&&(Se.isFunction(i)?e.paramsSerializer={serialize:i}:lx.assertOptions(i,{encode:$A.function,serialize:$A.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let a=s&&Se.merge(s.common,s[e.method]);s&&Se.forEach(["delete","get","head","post","put","patch","common"],P=>{delete s[P]}),e.headers=dl.concat(a,s);const o=[];let d=!0;this.interceptors.request.forEach(function(M){typeof M.runWhen=="function"&&M.runWhen(e)===!1||(d=d&&M.synchronous,o.unshift(M.fulfilled,M.rejected))});const p=[];this.interceptors.response.forEach(function(M){p.push(M.fulfilled,M.rejected)});let y,b=0,x;if(!d){const P=[v4.bind(this),void 0];for(P.unshift.apply(P,o),P.push.apply(P,p),x=P.length,y=Promise.resolve(e);b{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const a=new Promise(o=>{n.subscribe(o),s=o}).then(i);return a.cancel=function(){n.unsubscribe(s)},a},t(function(s,a,o){n.reason||(n.reason=new $g(s,a,o),e(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);e!==-1&&this._listeners.splice(e,1)}static source(){let t;return{token:new cx(function(i){t=i}),cancel:t}}}function nst(r){return function(e){return r.apply(null,e)}}function ist(r){return Se.isObject(r)&&r.isAxiosError===!0}const ux={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ux).forEach(r=>{let[t,e]=r;ux[e]=t});function B4(r){const t=new sd(r),e=KP(sd.prototype.request,t);return Se.extend(e,sd.prototype,t,{allOwnKeys:!0}),Se.extend(e,t,null,{allOwnKeys:!0}),e.create=function(i){return B4(Hf(r,i))},e}const as=B4(qg);as.Axios=sd,as.CanceledError=$g,as.CancelToken=cx,as.isCancel=p4,as.VERSION=w4,as.toFormData=Xy,as.AxiosError=In,as.Cancel=as.CanceledError,as.all=function(t){return Promise.all(t)},as.spread=nst,as.isAxiosError=ist,as.mergeConfig=Hf,as.AxiosHeaders=dl,as.formToJSON=r=>d4(Se.isHTMLForm(r)?new FormData(r):r),as.getAdapter=_4.getAdapter,as.HttpStatusCode=ux,as.default=as;const sst="https://tilemaps.icgc.cat/cdn/configs/mapicgc-config.json",ost=5e3;class C4{static async getConfigICGC(){try{const t=await as.get(sst,{timeout:ost});return t.data?t.data:(console.log("Resposta sense dades:",t),id)}catch(t){return t.response?(console.error("Error de resposta:",t.response.data),console.error("Codi d'estat:",t.response.status)):t.request?console.error("No s'ha rebut resposta del servidor:",t.request):console.error("Error:",t.message),id}}}const ast={cobertesSol:{"fill-opacity":["interpolate",["exponential",.5],["zoom"],13.5,1,18,.4],"fill-outline-color":"rgba(0,0, 0, 0)","fill-color":["interpolate",["cubic-bezier",.5,1,1,1],["get","nivell_2"],0,"#ffffff",111,"#ffff00",112,"#ccff33",113,"#af5b15",114,"#808000",115,"#cdcd00",116,"#ffffcc",221,"#33cc33",222,"#66ff33",223,"#689018",224,"#967d5f",225,"#19e61e",226,"#b4ff9b",227,"#aaa500",228,"#c3c3a0",229,"#00ff9b",230,"#ff9632",231,"#282828",232,"#79797a",233,"#f5df78",234,"#3296ff",341,"#ff007d",342,"#ff53cd",343,"#ffa4e2",344,"#ffc8e2",345,"#ffb4b4",346,"#0f3700",347,"#730055",348,"#6200c4",349,"#4a9595",350,"#ff00f0",351,"#adaaca",352,"#ffe6e6",353,"#67629a",354,"#4a466e",355,"#2f2d46",461,"#6f6fff",462,"#0000dc",463,"#000064",464,"#185f94",465,"#12466d",466,"#000080"]}},lst="lines",Yy="labels";let od,Wg,Qi,Pn,cst=class{constructor(t){C4.getConfigICGC().then(e=>{od={...e.Styles},Qi={...e.Layers},Wg={...e.Terrains},Pn={...e.defaultOptions},this.initTheMap(t)}).catch(e=>{console.info("Configuracio per defecte",e),od={...id.Styles},Qi={...id.Layers},Wg={...id.Terrains},Pn={...id.defaultOptions},this.initTheMap(t)})}initTheMap(t){if(!t)t=Pn.mapOptions;else for(const e in Pn.mapOptions){let n=[Pn.mapOptions.center[0],Pn.mapOptions.center[1]];Pn.mapOptions.center=n,t.hasOwnProperty(e)||(t[e]=Pn.mapOptions[e])}t.maxPitch=85,t.maplibreLogo=!1,t.attributionControl=!1,this.map=new Ls.Map(t),this.map.options=t,this.map.addControl(new Ls.AttributionControl({compact:!0})),this.map.on("load",async()=>{const e=this.map.getStyle().name,n=this.map.options.style;if(window.document.querySelector(".maplibregl-compact-show")){var i=window.document.querySelector(".maplibregl-compact-show");i.classList.remove("maplibregl-compact-show")}this.map.addControl(new Knt({color:n.indexOf("orto")===-1,defaultOptions:Pn}),"bottom-left"),this._dealOrto3dStyle(e)})}addGeocoderICGC(t){try{t===void 0&&(t="top-right");let e={collapsed:!0,marker:!0,popup:!0,showResultMarkers:!0,maplibregl:Ls,showResultsWhileTyping:!0,minLength:2};const n={forwardGeocode:async s=>{const a=[];try{const o=Pn.geocoder.peliasUrl1+encodeURIComponent(s.query)+Pn.geocoder.peliasUrl2,p=await(await fetch(o)).json();for(const y of p.features){const b=y.geometry.coordinates,x={type:"Feature",geometry:{type:"Point",coordinates:b},place_name:y.properties.etiqueta,properties:y.properties,text:y.properties.etiqueta,place_type:["place"],center:b};a.push(x)}}catch(o){console.error(`Failed to forwardGeocode with error: ${o}`)}return{features:a}}};this.map.addControl(new qnt(n,e),t);let i=document.getElementsByClassName("maplibregl-ctrl-geocoder--input");i[0].attributes[2].nodeValue="Cerca...",i[0].addEventListener("input",function(s){s.target.value.length>3})}catch(e){console.error(`Error adding ICGC geocoder: ${e.message}`)}}async loadImage(t){try{return this.map.loadImage(t)}catch(e){console.error(`Error getting loadImage: ${e.message}`)}}getConfigStyles(){try{let t=[];for(const e of od)t.push(e.name);return t}catch(t){console.error(`Error retrieving base styles: ${t.message}`)}}getConfigWMSLayers(){try{let t=[];for(const e in Qi.WMS)Qi.WMS.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving WMS layers: ${t.message}`)}}getConfigOrtoLayers(){try{let t=[];for(const e in Qi.Orto)Qi.Orto.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving orto image layers: ${t.message}`)}}getConfigVectorLayers(){try{let t=[];for(const e in Qi.Vector)Qi.Vector.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving vector layers: ${t.message}`)}}getConfigVectorAdminLayers(){try{let t=[];for(const e in Qi.VectorAdmin)Qi.VectorAdmin.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving vectorAdmin layers: ${t.message}`)}}getConfigFGBAdminLayers(){try{let t=[];for(const e in Qi.FGBAdmin)Qi.FGBAdmin.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving FGBAdmin layers: ${t.message}`)}}async fetchData(t,e,n){try{(!n||n===void 0)&&(n={type:"line",layout:{visibility:"visible"},paint:{"line-color":"grey","line-width":2},layerPosition:"top"});let i=n.layerPosition;if(t.includes(".fgb"))this.addFGBLayerICGC(t,e,n);else{const a=await(await fetch(t)).json();let o=e,d=this._dealOrderLayer(i),p=a.features[0].geometry.type;p.includes("ine")&&(n!==void 0?this.map.addLayer({id:o,type:"line",source:{type:"geojson",data:a},layout:n.layout||{},paint:n.paint||{}},d):this.map.addLayer({id:o,type:"line",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"line-color":"black","line-width":2,"line-opacity":1}},d)),p.includes("olygon")&&(n!==void 0?this.map.addLayer({id:o,type:"fill",source:{type:"geojson",data:a},layout:n.layout,paint:n.paint},d):this.map.addLayer({id:o,type:"fill",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"fill-color":"blue","fill-opacity":.6}},d)),p.includes("oint")&&(n!==void 0?this.map.addLayer({id:o,type:"circle",source:{type:"geojson",data:a},layout:n.layout,paint:n.paint},d):this.map.addLayer({id:o,type:"circle",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"circle-color":"red","circle-opacity":.85}},d))}}catch(i){console.error(`Error fetching data: ${i.message}`)}}async fetchDataAndMenu(t,e,n,i){try{let s;i!==null?s=i.layerPosition:s=Yy;let a,o=document.getElementById("map");if(document.getElementById("menu-group")?a=document.getElementById("menu-group"):(a=document.createElement("nav"),a.id="menu-group",a.classList.add="filter-group",o.appendChild(a)),a!==null){let d="visible",p=this._dealOrderLayer(s),y;if(t.includes(".fgb")){let x=this._getKeyByUrlFGB(t);x===null&&(x="userFGB");const C=await fetch(t),P={type:"FeatureCollection",features:[]};for await(const k of US(C.body))P.features.push(k);y=P;let M=e;if(this.map.addSource(M,{type:"geojson",data:P}),t.includes("text"))i!==void 0?this.map.addLayer({id:e,type:"symbol",source:M,layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"symbol",source:M,layout:{"text-letter-spacing":.1,"text-size":{base:1.2,stops:[[8,0],[12,14],[15,15]]},"text-font":["FiraSans-Regular"],"text-field":["get","NOM_AC"],"text-transform":"none","text-max-width":25,visibility:d,"text-justify":"right","text-anchor":"top","text-allow-overlap":!1,"symbol-spacing":2,"text-line-height":1},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},p);else{let k=e+"Text";this.map.addLayer({id:k,type:"symbol",source:M,layout:{"text-letter-spacing":.1,"text-size":{base:1.2,stops:[[8,0],[12,14],[15,15]]},"text-font":["FiraSans-Regular"],"text-field":["get","NOM_AC"],"text-transform":"none","text-max-width":25,visibility:d,"text-justify":"right","text-anchor":"top","text-allow-overlap":!1,"symbol-spacing":2,"text-line-height":1},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},p)}}else y=await(await fetch(t)).json();if(n!=="all"){const x=document.createElement("div");x.id="titleDivMenu",x.textContent=e,a.appendChild(x);const C=document.createElement("div");C.id="titleDivMenuSub",C.textContent=`📂 ${n}`,a.appendChild(C)}let b;if(i.type?b=i.type:b=y.features[0].geometry.type,n==="all")b.includes("ine")&&(i!==void 0?this.map.addLayer({id:e,type:"line",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"line",source:{type:"geojson",data:y},layout:{visibility:"visible"},paint:{"line-color":"black","line-width":2,"line-opacity":1}},p)),b.includes("olygon")&&(i!==void 0?this.map.addLayer({id:e,type:"fill",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"fill",source:{type:"geojson",data:y},layout:{visibility:"visible"},paint:{"fill-color":"#0000FF","fill-opacity":0}},p)),b.includes("oint")&&(i!==void 0?this.map.addLayer({id:e,type:"circle",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"circle",source:{type:"geojson",data:y},layout:{visibility:"visible"},paint:{"circle-color":"red","circle-opacity":.85}},p)),b.includes("ymbol")&&(i!==void 0?this.map.addLayer({id:e,type:"symbol",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"symbol",source:{type:"geojson",data:y},layout:{visibility:"visible"},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},p)),this.addMenuItem(e);else{let x=n;const C={};y.features.forEach(P=>{const M=P.properties[x],k=M+"-userFieldFilter-"+e;M!==null&&(C[k]||(b.includes("ine")&&(i!==void 0?this.map.addLayer({id:k,type:"line",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint,filter:["==",`${x}`,M]},p):this.map.addLayer({id:k,type:"line",source:{type:"geojson",data:y},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"line-color":"black","line-width":2,"line-opacity":1}},p)),b.includes("olygon")&&(i!==void 0?this.map.addLayer({id:k,type:"fill",source:{type:"geojson",data:y},filter:["==",`${x}`,M],layout:i.layout,paint:i.paint},p):this.map.addLayer({id:k,type:"fill",source:{type:"geojson",data:y},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"fill-color":"blue","fill-opacity":.6}},p)),b.includes("oint")&&(i!==void 0?this.map.addLayer({id:k,type:"circle",source:{type:"geojson",data:y},filter:["==",`${x}`,M],layout:i.layout,paint:i.paint},p):this.map.addLayer({id:k,type:"circle",source:{type:"geojson",data:y},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"circle-color":"red","circle-opacity":.85}},p)),C[k]=!0,this.addMenuItem(k)))})}}}catch(s){console.error(`Error fetching data: ${s.message}`)}}on(t,e){setTimeout(()=>{try{return this.map.on(t,e)}catch(n){console.error(`Error adding event ON listener: ${n.message}`)}},100)}setStyle(t,e){try{e!==void 0?this.map.setStyle(t,e):this.map.setStyle(t),this.map.on("styledata",()=>{if(window.document.querySelector(".maplibregl-compact-show")){var n=window.document.querySelector(".maplibregl-compact-show");n.classList.remove("maplibregl-compact-show")}this._dealOrto3dStyle(this.map.getStyle().name)})}catch(n){console.error(`Error setting style: ${n.message}`)}}addControl(t,e){try{e===void 0&&(e="top-right"),this.map.addControl(t,e)}catch(n){console.error(`Error adding control: ${n.message}`)}}setSky(t){try{t===void 0&&(this.map.options.style.includes("orto")&&(t={"sky-color":"#86bbd5","sky-horizon-blend":.3,"horizon-color":"#ffffff33","horizon-fog-blend":.1,"fog-ground-blend":.75,"fog-color":"#c5d6d6"}),this.map.options.style.includes("mapa_estandard_general")&&(t={"sky-color":"#a5f0f0","sky-horizon-blend":.3,"horizon-color":"#e1e3e3","horizon-fog-blend":.9,"fog-ground-blend":.85,"fog-color":"#c5d6d6"}),this.map.options.style.includes("fosc")&&(t={"sky-color":"#232423","sky-horizon-blend":.3,"horizon-color":"#969996","horizon-fog-blend":.9,"fog-ground-blend":.85,"fog-color":"#383838"})),this.map.setSky(t)}catch(e){console.error(`Error setting sky properties: ${e.message}`)}}addMouseCoordControl(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"bottom-left";try{this.map.addControl(new Jnt(t),e)}catch(n){console.error(`Error adding mouse coordinate control: ${n.message}`)}}addGeolocateControl(t,e){try{e===void 0&&(e="top-right"),t===void 0?this.map.addControl(new Ls.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!0}),e):this.map.addControl(new Ls.GeolocateControl(t),e)}catch(n){console.error(`Error adding geolocate control: ${n.message}`)}}addFullscreenControl(t,e){try{e===void 0&&(e="top-right"),t===void 0?this.map.addControl(new Ls.FullscreenControl({container:HTMLElement}),e):this.map.addControl(new Ls.FullscreenControl(t),e)}catch(n){console.error(`Error adding fullscreen control: ${n.message}`)}}addLayer(t,e){try{this.map.addLayer(t,e)}catch(n){console.error(`Error adding layer: ${n.message}`)}}addImage(t,e,n){try{this.map.addImage(t,e,n)}catch(i){console.error(`Error adding image: ${i.message}`)}return this}addSource(t,e){try{this.map.addSource(t,e)}catch(n){console.error(`Error adding source: ${n.message}`)}return this}addSprite(t,e,n){try{this.map.addSprite(t,e,n)}catch(i){console.error(`Error adding sprite: ${i.message}`)}return this}areTilesLoaded(){return this.map.areTilesLoaded()}cameraForBounds(t,e){return this.map.cameraForBounds(t,e)}easeTo(t,e){return this.map.easeTo(t,e),this}fitBounds(t,e,n){return this.map.fitBounds(t,e,n),this}fitScreenCoordinates(t,e,n,i,s){return this.map.fitScreenCoordinates(t,e,n,i,s),this}flyTo(t,e){return this.map.flyTo(t,e),this}getBearing(){return this.map.getBearing()}getBounds(){return this.map.getBounds()}getCameraTargetElevation(){return this.map.getCameraTargetElevation()}getCanvas(){return this.map.getCanvas()}getCanvasContainer(){return this.map.getCanvasContainer()}getCenter(){return this.map.getCenter()}getContainer(){return this.map.getContainer()}getFeatureState(t){return this.map.getFeatureState(t)}getFilter(t){return this.map.getFilter(t)}getGlyphs(){return this.map.getGlyphs()}getImage(t){return this.map.getImage(t)}getLayer(t){return this.map.getLayer(t)}getLayersOrder(){return this.map.getLayersOrder()}getLayoutProperty(t,e){return this.map.getLayoutProperty(t,e)}getLight(){return this.map.getLight()}getMaxBounds(){return this.map.getMaxBounds()}getMaxPitch(){return this.map.getMaxPitch()}getMaxZoom(){return this.map.getMaxZoom()}getMinPitch(){return this.map.getMinPitch()}getMinZoom(){return this.map.getMinZoom()}getPadding(){return this.map.getPadding()}getPaintProperty(t,e){return this.map.getPaintProperty(t,e)}getPitch(){return this.map.getPitch()}getPixelRatio(){return this.map.getPixelRatio()}getRenderWorldCopies(){return this.map.getRenderWorldCopies()}getSource(t){return this.map.getSource(t)}getSprite(){return this.map.getSprite()}getStyle(){return this.map.getStyle()}getTerrain(){return this.map.getTerrain()}getZoom(){return this.map.getZoom()}hasControl(t){return this.map.hasControl(t)}hasImage(t){return this.map.hasImage(t)}isMoving(){return this.map.isMoving()}isRotating(){return this.map.isRotating()}isSourceLoaded(t){return this.map.isSourceLoaded(t)}isStyleLoaded(){return this.map.isStyleLoaded()}isZooming(){return this.map.isZooming()}jumpTo(t,e){return this.map.jumpTo(t,e)}listImages(){return this.map.listImages()}listens(t){return this.map.listens(t)}loadImage(t){return this.map.loadImage(t)}loaded(){return this.map.loaded()}LngLatBounds(t,e){return new Ls.LngLatBounds(t,e)}addProtocol(t,e){return this.map.addProtocol(t,e)}moveLayer(t,e){return this.map.moveLayer(t,e)}panBy(t,e,n){return this.map.panBy(t,e,n)}panTo(t,e,n){return this.map.panTo(t,e,n)}project(t){return this.map.project(t)}queryRenderedFeatures(t,e){return this.map.queryRenderedFeatures(t,e)}querySourceFeatures(t,e){return this.map.querySourceFeatures(t,e)}queryTerrainElevation(t){return this.map.queryTerrainElevation(t)}redraw(){return this.map.redraw()}remove(){return this.map.remove()}removeControl(t){return this.map.removeControl(t)}removeFeatureState(t,e){return this.map.removeFeatureState(t,e)}removeImage(t){return this.map.removeImage(t)}removeLayer(t){try{this.map.removeLayer(t)}catch(e){console.error(`Error removing layer: ${e.message}`)}}removeSource(t){try{this.map.removeSource(t)}catch(e){console.error(`Error removing source: ${e.message}`)}}removeSprite(t){return this.map.removeSprite(t)}resetNorth(t,e){return this.map.resetNorth(t,e)}resetNorthPitch(t,e){return this.map.resetNorthPitch(t,e)}resize(t){return this.map.resize(t)}rotateTo(t,e,n){return this.map.rotateTo(t,e,n)}setBearing(t,e){return this.map.setBearing(t,e)}setCenter(t,e){return this.map.setCenter(t,e)}setEventedParent(t,e){return this.map.setEventedParent(t,e)}setFeatureState(t,e){return this.map.setFeatureState(t,e)}setFilter(t,e,n){return this.map.setFilter(t,e,n)}setGlyphs(t,e){return this.map.setGlyphs(t,e)}setLayerZoomRange(t,e,n){return this.map.setLayerZoomRange(t,e,n)}setLayoutProperty(t,e,n,i){return this.map.setLayoutProperty(t,e,n,i)}setLight(t,e){return this.map.setLight(t,e)}setMaxBounds(t){return this.map.setMaxBounds(t)}setMaxPitch(t){return this.map.setMaxPitch(t)}setMaxZoom(t){return this.map.setMaxZoom(t)}setMinPitch(t){return this.map.setMinPitch(t)}setMinZoom(t){return this.map.setMinZoom(t)}setPadding(t,e){return this.map.setPadding(t,e)}setPaintProperty(t,e,n,i){return this.map.setPaintProperty(t,e,n,i)}setPitch(t,e){return this.map.setPitch(t,e)}setPixelRatio(t){return this.map.setPixelRatio(t)}setRenderWorldCopies(t){return this.map.setRenderWorldCopies(t)}setSprite(t,e){return this.map.setSprite(t,e)}setTerrain(t){return this.map.setTerrain(t)}setTransformRequest(t){return this.map.setTransformRequest(t)}setZoom(t,e){return this.map.setZoom(t,e)}snapToNorth(t,e){return this.map.snapToNorth(t,e)}stop(){return this.map.stop()}triggerRepaint(){return this.map.triggerRepaint()}unproject(t){return this.map.unproject(t)}updateImage(t,e){return this.map.updateImage(t,e)}zoomIn(t,e){return this.map.zoomIn(t,e)}zoomOut(t,e){return this.map.zoomOut(t,e)}zoomTo(t,e,n){return this.map.zoomTo(t,e,n)}addLayerGeoJSON(t,e){try{let n=this._dealOrderLayer(e);this.map.addSource(`${t.id}`,{type:"geojson",data:t.data}),this.map.addLayer({id:`${t.id}-layerIcgcMap`,type:t.type,source:`${t.id}`,layout:t.layout,paint:t.paint},n)}catch(n){console.error(`Error adding GeoJSON layer: ${n.message}`)}}addLayerWMS(t,e,n){try{let i=this._dealOrderLayer(n.layerPosition);n?(this.map.addSource(`${e}`,{type:"raster",tiles:[t],tileSize:256},i),this.map.addLayer({id:e,type:"raster",source:e,layout:n.layout,paint:n.paint},i)):(this.map.addSource(`${e}`,{type:"raster",tiles:[t],tileSize:256},i),this.map.addLayer({id:e,type:"raster",source:e,paint:{}},i))}catch(i){console.error(`Error adding WMS layer: ${i.message}`)}}addLogo(t){try{let e=document.getElementById("map"),n;n=document.createElement("div"),n.id="logos",e.appendChild(n);const i=document.createElement("img");i.src=t.url,i.style.height=t.height;const s=document.getElementById("logos"),a=document.createElement("a");a.id=t.id,a.href=t.href,a.target="_blank",a.style.position="relative",a.style.bottom="1px",a.appendChild(i),s.appendChild(a)}catch(e){console.error(`Error adding logo: ${e.message}`)}}addBasemapsICGC(t){try{const e=a=>{this.map.setStyle(a)};let n=document.getElementById("map"),i;i=document.createElement("div"),i.id="basemap-group",i.classList.add="filter-group",n.appendChild(i);const s=document.getElementById("basemap-group");for(const a of t)for(const o of Object.keys(Pn.baseStyles)){const d=Pn.baseStyles[o];if(a===d.url){const p=document.createElement("div");p.className="basemap-item",p.title=d.key,p.style.backgroundImage=`url('${d.image}')`,s.appendChild(p),p.addEventListener("click",()=>e(d.url))}}}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addBasemaps(t){try{const e=a=>{map.setStyle(a.url)};let n=document.getElementById("map"),i;i=document.createElement("div"),i.id="basemap-group",i.classList.add="basemap-group",n.appendChild(i);const s=document.getElementById("basemap-group");t.forEach(a=>{const o=document.createElement("div");o.className="basemap-item",o.title=a.label,o.style.backgroundImage=`url('${a.image}')`,s.appendChild(o),o.addEventListener("click",()=>e(a))})}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addFeatureQuery(t,e,n){try{let i;this.map.on("mouseenter",t,()=>{this.map.getCanvas().style.cursor="pointer"}),this.map.on("mouseleave",t,()=>{this.map.getCanvas().style.cursor=""}),this.map.on("click",s=>{let a=this.map.queryRenderedFeatures(s.point);if(a&&a[0].source.includes(t)){let o=[s.lngLat.lng,s.lngLat.lat];if(e!==void 0&&e.length>0&&e!=="all"){if(e!==null){let d="";e.forEach(p=>{let y=a[0].properties[p];d=d+`

${y}

`}),i=d,this.addPopup(o,i,n)}}else{let d="";for(const p in a[0].properties)d+=""+p+":"+a[0].properties[p]+"
";i=d,this.addPopup(o,i,n)}}})}catch(i){console.error(`Error adding feature query: ${i.message}`)}}addScaleControl(t,e){try{var n=new Ls.ScaleControl(t);this.map.addControl(n,e)}catch(i){console.error(`Error adding scale: ${i.message}`)}}addExportControl(t,e){try{typeof t=="string"&&(e=t,t=void 0),t===void 0&&(t={PageSize:Zh.A4,PageOrientation:Ng.Landscape,Format:Vu.PNG,DPI:x2[300],Crosshair:!0,PrintableArea:!0,Local:"ca"},e="top-right"),this.map.addControl(new rnt(t),e)}catch(n){console.error(`Error adding export control: ${n.message}`)}}addMarker(t){try{let e,n;return t.text===void 0?e=new Ls.Marker(t.options).setLngLat(t.coord).addTo(this.map):(n=new Ls.Popup({offset:t.textOffset}).setHTML(t.text),e=new Ls.Marker(t.options).setLngLat(t.coord).setPopup(n).addTo(this.map)),e}catch(e){return console.error(`Error adding marker: ${e.message}`),null}}addPopup(t,e,n){try{return n.image===void 0?new Ls.Popup().setLngLat(t).setHTML(`
${n.title} diff --git a/dist/mapicgc-gl.mjs b/dist/mapicgc-gl.mjs index 7ef913c..ec35ce5 100644 --- a/dist/mapicgc-gl.mjs +++ b/dist/mapicgc-gl.mjs @@ -1,4 +1,4 @@ -import { C as p, a as s, M as r } from "./index-ChqpbeXL.mjs"; +import { C as p, a as s, M as r } from "./index-Cx8g3h7b.mjs"; export { p as CompareMaps, s as Config, diff --git a/dist/mapicgc-gl.umd.js b/dist/mapicgc-gl.umd.js index 5553dba..214fc03 100644 --- a/dist/mapicgc-gl.umd.js +++ b/dist/mapicgc-gl.umd.js @@ -2579,7 +2579,7 @@ end`};t.events.push(["putFont",function(s){(function(a){var o=a.font,d=a.out,p=a `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t){const e=new this(t);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;se.set(a)),e}static accessor(t){const n=(this[f4]=this[f4]={accessors:{}}).accessors,i=this.prototype;function s(a){const o=Kg(a);n[o]||(Kit(i,a),n[o]=!0)}return Se.isArray(t)?t.forEach(s):s(t),this}}dl.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Se.reduceDescriptors(dl.prototype,(r,t)=>{let{value:e}=r,n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[n]=i}}}),Se.freezeMethods(dl);function ix(r,t){const e=this||qg,n=t||e,i=dl.from(n.headers);let s=n.data;return Se.forEach(r,function(o){s=o.call(e,s,i.normalize(),t?t.status:void 0)}),i.normalize(),s}function p4(r){return!!(r&&r.__CANCEL__)}function $g(r,t,e){In.call(this,r??"canceled",In.ERR_CANCELED,t,e),this.name="CanceledError"}Se.inherits($g,In,{__CANCEL__:!0});function $it(r,t,e){const n=e.config.validateStatus;!e.status||!n||n(e.status)?r(e):t(new In("Request failed with status code "+e.status,[In.ERR_BAD_REQUEST,In.ERR_BAD_RESPONSE][Math.floor(e.status/100)-4],e.config,e.request,e))}const Wit=Yc.hasStandardBrowserEnv?{write(r,t,e,n,i,s){const a=[r+"="+encodeURIComponent(t)];Se.isNumber(e)&&a.push("expires="+new Date(e).toGMTString()),Se.isString(n)&&a.push("path="+n),Se.isString(i)&&a.push("domain="+i),s===!0&&a.push("secure"),document.cookie=a.join("; ")},read(r){const t=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(r){this.write(r,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Xit(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function Jit(r,t){return t?r.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):r}function g4(r,t){return r&&!Xit(t)?Jit(r,t):t}const Yit=Yc.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),e=document.createElement("a");let n;function i(s){let a=s;return t&&(e.setAttribute("href",a),a=e.href),e.setAttribute("href",a),{href:e.href,protocol:e.protocol?e.protocol.replace(/:$/,""):"",host:e.host,search:e.search?e.search.replace(/^\?/,""):"",hash:e.hash?e.hash.replace(/^#/,""):"",hostname:e.hostname,port:e.port,pathname:e.pathname.charAt(0)==="/"?e.pathname:"/"+e.pathname}}return n=i(window.location.href),function(a){const o=Se.isString(a)?i(a):a;return o.protocol===n.protocol&&o.host===n.host}}():function(){return function(){return!0}}();function Zit(r){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return t&&t[1]||""}function tst(r,t){r=r||10;const e=new Array(r),n=new Array(r);let i=0,s=0,a;return t=t!==void 0?t:1e3,function(d){const p=Date.now(),y=n[s];a||(a=p),e[i]=d,n[i]=p;let b=s,x=0;for(;b!==i;)x+=e[b++],b=b%r;if(i=(i+1)%r,i===s&&(s=(s+1)%r),p-a{const s=i.loaded,a=i.lengthComputable?i.total:void 0,o=s-e,d=n(o),p=s<=a;e=s;const y={loaded:s,total:a,progress:a?s/a:void 0,bytes:o,rate:d||void 0,estimated:d&&a&&p?(a-s)/d:void 0,event:i};y[t?"download":"upload"]=!0,r(y)}}const sx={http:Lit,xhr:typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(e,n){let i=r.data;const s=dl.from(r.headers).normalize();let{responseType:a,withXSRFToken:o}=r,d;function p(){r.cancelToken&&r.cancelToken.unsubscribe(d),r.signal&&r.signal.removeEventListener("abort",d)}let y;if(Se.isFormData(i)){if(Yc.hasStandardBrowserEnv||Yc.hasStandardBrowserWebWorkerEnv)s.setContentType(!1);else if((y=s.getContentType())!==!1){const[M,...k]=y?y.split(";").map(z=>z.trim()).filter(Boolean):[];s.setContentType([M||"multipart/form-data",...k].join("; "))}}let b=new XMLHttpRequest;if(r.auth){const M=r.auth.username||"",k=r.auth.password?unescape(encodeURIComponent(r.auth.password)):"";s.set("Authorization","Basic "+btoa(M+":"+k))}const x=g4(r.baseURL,r.url);b.open(r.method.toUpperCase(),c4(x,r.params,r.paramsSerializer),!0),b.timeout=r.timeout;function C(){if(!b)return;const M=dl.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),z={data:!a||a==="text"||a==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:M,config:r,request:b};$it(function($){e($),p()},function($){n($),p()},z),b=null}if("onloadend"in b?b.onloadend=C:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(C)},b.onabort=function(){b&&(n(new In("Request aborted",In.ECONNABORTED,r,b)),b=null)},b.onerror=function(){n(new In("Network Error",In.ERR_NETWORK,r,b)),b=null},b.ontimeout=function(){let k=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const z=r.transitional||A4;r.timeoutErrorMessage&&(k=r.timeoutErrorMessage),n(new In(k,z.clarifyTimeoutError?In.ETIMEDOUT:In.ECONNABORTED,r,b)),b=null},Yc.hasStandardBrowserEnv&&(o&&Se.isFunction(o)&&(o=o(r)),o||o!==!1&&Yit(x))){const M=r.xsrfHeaderName&&r.xsrfCookieName&&Wit.read(r.xsrfCookieName);M&&s.set(r.xsrfHeaderName,M)}i===void 0&&s.setContentType(null),"setRequestHeader"in b&&Se.forEach(s.toJSON(),function(k,z){b.setRequestHeader(z,k)}),Se.isUndefined(r.withCredentials)||(b.withCredentials=!!r.withCredentials),a&&a!=="json"&&(b.responseType=r.responseType),typeof r.onDownloadProgress=="function"&&b.addEventListener("progress",m4(r.onDownloadProgress,!0)),typeof r.onUploadProgress=="function"&&b.upload&&b.upload.addEventListener("progress",m4(r.onUploadProgress)),(r.cancelToken||r.signal)&&(d=M=>{b&&(n(!M||M.type?new $g(null,r,b):M),b.abort(),b=null)},r.cancelToken&&r.cancelToken.subscribe(d),r.signal&&(r.signal.aborted?d():r.signal.addEventListener("abort",d)));const P=Zit(x);if(P&&Yc.protocols.indexOf(P)===-1){n(new In("Unsupported protocol "+P+":",In.ERR_BAD_REQUEST,r));return}b.send(i||null)})}};Se.forEach(sx,(r,t)=>{if(r){try{Object.defineProperty(r,"name",{value:t})}catch{}Object.defineProperty(r,"adapterName",{value:t})}});const y4=r=>`- ${r}`,est=r=>Se.isFunction(r)||r===null||r===!1,_4={getAdapter:r=>{r=Se.isArray(r)?r:[r];const{length:t}=r;let e,n;const i={};for(let s=0;s{let[d,p]=o;return`adapter ${d} `+(p===!1?"is not supported by the environment":"is not available in the build")});let a=t?s.length>1?`since : `+s.map(y4).join(` `):" "+y4(s[0]):"as no adapter specified";throw new In("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return n},adapters:sx};function ox(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new $g(null,r)}function v4(r){return ox(r),r.headers=dl.from(r.headers),r.data=ix.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),_4.getAdapter(r.adapter||qg.adapter)(r).then(function(n){return ox(r),n.data=ix.call(r,r.transformResponse,n),n.headers=dl.from(n.headers),n},function(n){return p4(n)||(ox(r),n&&n.response&&(n.response.data=ix.call(r,r.transformResponse,n.response),n.response.headers=dl.from(n.response.headers))),Promise.reject(n)})}const b4=r=>r instanceof dl?{...r}:r;function Hf(r,t){t=t||{};const e={};function n(p,y,b){return Se.isPlainObject(p)&&Se.isPlainObject(y)?Se.merge.call({caseless:b},p,y):Se.isPlainObject(y)?Se.merge({},y):Se.isArray(y)?y.slice():y}function i(p,y,b){if(Se.isUndefined(y)){if(!Se.isUndefined(p))return n(void 0,p,b)}else return n(p,y,b)}function s(p,y){if(!Se.isUndefined(y))return n(void 0,y)}function a(p,y){if(Se.isUndefined(y)){if(!Se.isUndefined(p))return n(void 0,p)}else return n(void 0,y)}function o(p,y,b){if(b in t)return n(p,y);if(b in r)return n(void 0,p)}const d={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:o,headers:(p,y)=>i(b4(p),b4(y),!0)};return Se.forEach(Object.keys(Object.assign({},r,t)),function(y){const b=d[y]||i,x=b(r[y],t[y],y);Se.isUndefined(x)&&b!==o||(e[y]=x)}),e}const w4="1.6.8",ax={};["object","boolean","number","function","string","symbol"].forEach((r,t)=>{ax[r]=function(n){return typeof n===r||"a"+(t<1?"n ":" ")+r}});const x4={};ax.transitional=function(t,e,n){function i(s,a){return"[Axios v"+w4+"] Transitional option '"+s+"'"+a+(n?". "+n:"")}return(s,a,o)=>{if(t===!1)throw new In(i(a," has been removed"+(e?" in "+e:"")),In.ERR_DEPRECATED);return e&&!x4[a]&&(x4[a]=!0,console.warn(i(a," has been deprecated since v"+e+" and will be removed in the near future"))),t?t(s,a,o):!0}};function rst(r,t,e){if(typeof r!="object")throw new In("options must be an object",In.ERR_BAD_OPTION_VALUE);const n=Object.keys(r);let i=n.length;for(;i-- >0;){const s=n[i],a=t[s];if(a){const o=r[s],d=o===void 0||a(o,s,r);if(d!==!0)throw new In("option "+s+" must be "+d,In.ERR_BAD_OPTION_VALUE);continue}if(e!==!0)throw new In("Unknown option "+s,In.ERR_BAD_OPTION)}}const lx={assertOptions:rst,validators:ax},$A=lx.validators;class sd{constructor(t){this.defaults=t,this.interceptors={request:new u4,response:new u4}}async request(t,e){try{return await this._request(t,e)}catch(n){if(n instanceof Error){let i;Error.captureStackTrace?Error.captureStackTrace(i={}):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=` -`+s):n.stack=s}throw n}}_request(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=Hf(this.defaults,e);const{transitional:n,paramsSerializer:i,headers:s}=e;n!==void 0&&lx.assertOptions(n,{silentJSONParsing:$A.transitional($A.boolean),forcedJSONParsing:$A.transitional($A.boolean),clarifyTimeoutError:$A.transitional($A.boolean)},!1),i!=null&&(Se.isFunction(i)?e.paramsSerializer={serialize:i}:lx.assertOptions(i,{encode:$A.function,serialize:$A.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let a=s&&Se.merge(s.common,s[e.method]);s&&Se.forEach(["delete","get","head","post","put","patch","common"],P=>{delete s[P]}),e.headers=dl.concat(a,s);const o=[];let d=!0;this.interceptors.request.forEach(function(M){typeof M.runWhen=="function"&&M.runWhen(e)===!1||(d=d&&M.synchronous,o.unshift(M.fulfilled,M.rejected))});const p=[];this.interceptors.response.forEach(function(M){p.push(M.fulfilled,M.rejected)});let y,b=0,x;if(!d){const P=[v4.bind(this),void 0];for(P.unshift.apply(P,o),P.push.apply(P,p),x=P.length,y=Promise.resolve(e);b{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const a=new Promise(o=>{n.subscribe(o),s=o}).then(i);return a.cancel=function(){n.unsubscribe(s)},a},t(function(s,a,o){n.reason||(n.reason=new $g(s,a,o),e(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);e!==-1&&this._listeners.splice(e,1)}static source(){let t;return{token:new cx(function(i){t=i}),cancel:t}}}function nst(r){return function(e){return r.apply(null,e)}}function ist(r){return Se.isObject(r)&&r.isAxiosError===!0}const ux={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ux).forEach(r=>{let[t,e]=r;ux[e]=t});function B4(r){const t=new sd(r),e=KP(sd.prototype.request,t);return Se.extend(e,sd.prototype,t,{allOwnKeys:!0}),Se.extend(e,t,null,{allOwnKeys:!0}),e.create=function(i){return B4(Hf(r,i))},e}const as=B4(qg);as.Axios=sd,as.CanceledError=$g,as.CancelToken=cx,as.isCancel=p4,as.VERSION=w4,as.toFormData=Xy,as.AxiosError=In,as.Cancel=as.CanceledError,as.all=function(t){return Promise.all(t)},as.spread=nst,as.isAxiosError=ist,as.mergeConfig=Hf,as.AxiosHeaders=dl,as.formToJSON=r=>d4(Se.isHTMLForm(r)?new FormData(r):r),as.getAdapter=_4.getAdapter,as.HttpStatusCode=ux,as.default=as;const sst="https://tilemaps.icgc.cat/cdn/configs/mapicgc-config.json",ost=5e3;class C4{static async getConfigICGC(){try{const t=await as.get(sst,{timeout:ost});return t.data?t.data:(console.log("Resposta sense dades:",t),id)}catch(t){return t.response?(console.error("Error de resposta:",t.response.data),console.error("Codi d'estat:",t.response.status)):t.request?console.error("No s'ha rebut resposta del servidor:",t.request):console.error("Error:",t.message),id}}}const ast={cobertesSol:{"fill-opacity":["interpolate",["exponential",.5],["zoom"],13.5,1,18,.4],"fill-outline-color":"rgba(0,0, 0, 0)","fill-color":["interpolate",["cubic-bezier",.5,1,1,1],["get","nivell_2"],0,"#ffffff",111,"#ffff00",112,"#ccff33",113,"#af5b15",114,"#808000",115,"#cdcd00",116,"#ffffcc",221,"#33cc33",222,"#66ff33",223,"#689018",224,"#967d5f",225,"#19e61e",226,"#b4ff9b",227,"#aaa500",228,"#c3c3a0",229,"#00ff9b",230,"#ff9632",231,"#282828",232,"#79797a",233,"#f5df78",234,"#3296ff",341,"#ff007d",342,"#ff53cd",343,"#ffa4e2",344,"#ffc8e2",345,"#ffb4b4",346,"#0f3700",347,"#730055",348,"#6200c4",349,"#4a9595",350,"#ff00f0",351,"#adaaca",352,"#ffe6e6",353,"#67629a",354,"#4a466e",355,"#2f2d46",461,"#6f6fff",462,"#0000dc",463,"#000064",464,"#185f94",465,"#12466d",466,"#000080"]}},lst="lines",Yy="labels";let od,Wg,Qi,Pn,cst=class{constructor(t){C4.getConfigICGC().then(e=>{od={...e.Styles},Qi={...e.Layers},Wg={...e.Terrains},Pn={...e.defaultOptions},this.initTheMap(t)}).catch(e=>{console.info("Configuracio per defecte",e),od={...id.Styles},Qi={...id.Layers},Wg={...id.Terrains},Pn={...id.defaultOptions},this.initTheMap(t)})}initTheMap(t){if(!t)t=Pn.mapOptions;else for(const e in Pn.mapOptions){let n=[Pn.mapOptions.center[0],Pn.mapOptions.center[1]];Pn.mapOptions.center=n,t.hasOwnProperty(e)||(t[e]=Pn.mapOptions[e])}t.maxPitch=85,t.maplibreLogo=!1,t.attributionControl=!1,this.map=new Ls.Map(t),this.map.options=t,this.map.addControl(new Ls.AttributionControl({compact:!0})),this.map.on("load",async()=>{const e=this.map.getStyle().name,n=this.map.options.style;if(window.document.querySelector(".maplibregl-compact-show")){var i=window.document.querySelector(".maplibregl-compact-show");i.classList.remove("maplibregl-compact-show")}this.map.addControl(new Knt({color:n.indexOf("orto")===-1,defaultOptions:Pn}),"bottom-left"),this._dealOrto3dStyle(e)})}addGeocoderICGC(t){try{t===void 0&&(t="top-right");let e={collapsed:!0,marker:!0,popup:!0,showResultMarkers:!0,maplibregl:Ls,showResultsWhileTyping:!0,minLength:2};const n={forwardGeocode:async s=>{const a=[];try{const o=Pn.geocoder.peliasUrl1+encodeURIComponent(s.query)+Pn.geocoder.peliasUrl2,p=await(await fetch(o)).json();for(const y of p.features){const b=y.geometry.coordinates,x={type:"Feature",geometry:{type:"Point",coordinates:b},place_name:y.properties.etiqueta,properties:y.properties,text:y.properties.etiqueta,place_type:["place"],center:b};a.push(x)}}catch(o){console.error(`Failed to forwardGeocode with error: ${o}`)}return{features:a}}};this.map.addControl(new qnt(n,e),t);let i=document.getElementsByClassName("maplibregl-ctrl-geocoder--input");i[0].attributes[2].nodeValue="Cerca...",i[0].addEventListener("input",function(s){s.target.value.length>3})}catch(e){console.error(`Error adding ICGC geocoder: ${e.message}`)}}async loadImage(t){try{return this.map.loadImage(t)}catch(e){console.error(`Error getting loadImage: ${e.message}`)}}getConfigStyles(){try{let t=[];for(const e of od)t.push(e.name);return t}catch(t){console.error(`Error retrieving base styles: ${t.message}`)}}getConfigWMSLayers(){try{let t=[];for(const e in Qi.WMS)Qi.WMS.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving WMS layers: ${t.message}`)}}getConfigOrtoLayers(){try{let t=[];for(const e in Qi.Orto)Qi.Orto.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving orto image layers: ${t.message}`)}}getConfigVectorLayers(){try{let t=[];for(const e in Qi.Vector)Qi.Vector.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving vector layers: ${t.message}`)}}getConfigVectorAdminLayers(){try{let t=[];for(const e in Qi.VectorAdmin)Qi.VectorAdmin.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving vectorAdmin layers: ${t.message}`)}}getConfigFGBAdminLayers(){try{let t=[];for(const e in Qi.FGBAdmin)Qi.FGBAdmin.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving FGBAdmin layers: ${t.message}`)}}async fetchData(t,e,n){try{(!n||n===void 0)&&(n={type:"line",layout:{visibility:"visible"},paint:{"line-color":"grey","line-width":2},layerPosition:"top"});let i=n.layerPosition;if(t.includes(".fgb"))this.addFGBLayerICGC(t,e,n);else{const a=await(await fetch(t)).json();let o=e,d=this._dealOrderLayer(i),p=a.features[0].geometry.type;p.includes("ine")&&(n!==void 0?this.map.addLayer({id:o,type:"line",source:{type:"geojson",data:a},layout:n.layout||{},paint:n.paint||{}},d):this.map.addLayer({id:o,type:"line",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"line-color":"black","line-width":2,"line-opacity":1}},d)),p.includes("olygon")&&(n!==void 0?this.map.addLayer({id:o,type:"fill",source:{type:"geojson",data:a},layout:n.layout,paint:n.paint},d):this.map.addLayer({id:o,type:"fill",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"fill-color":"blue","fill-opacity":.6}},d)),p.includes("oint")&&(n!==void 0?this.map.addLayer({id:o,type:"circle",source:{type:"geojson",data:a},layout:n.layout,paint:n.paint},d):this.map.addLayer({id:o,type:"circle",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"circle-color":"red","circle-opacity":.85}},d))}}catch(i){console.error(`Error fetching data: ${i.message}`)}}async fetchDataAndMenu(t,e,n,i){try{let s;i!==null?s=i.layerPosition:s=Yy;let a,o=document.getElementById("map");if(document.getElementById("menu-group")?a=document.getElementById("menu-group"):(a=document.createElement("nav"),a.id="menu-group",a.classList.add="filter-group",o.appendChild(a)),a!==null){let d="visible",p=this._dealOrderLayer(s),y;if(t.includes(".fgb")){let x=this._getKeyByUrlFGB(t);x===null&&(x="userFGB");const C=await fetch(t),P={type:"FeatureCollection",features:[]};for await(const k of US(C.body))P.features.push(k);y=P;let M=e;if(this.map.addSource(M,{type:"geojson",data:P}),t.includes("text"))i!==void 0?this.map.addLayer({id:e,type:"symbol",source:M,layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"symbol",source:M,layout:{"text-letter-spacing":.1,"text-size":{base:1.2,stops:[[8,0],[12,14],[15,15]]},"text-font":["FiraSans-Regular"],"text-field":["get","NOM_AC"],"text-transform":"none","text-max-width":25,visibility:d,"text-justify":"right","text-anchor":"top","text-allow-overlap":!1,"symbol-spacing":2,"text-line-height":1},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},p);else{let k=e+"Text";this.map.addLayer({id:k,type:"symbol",source:M,layout:{"text-letter-spacing":.1,"text-size":{base:1.2,stops:[[8,0],[12,14],[15,15]]},"text-font":["FiraSans-Regular"],"text-field":["get","NOM_AC"],"text-transform":"none","text-max-width":25,visibility:d,"text-justify":"right","text-anchor":"top","text-allow-overlap":!1,"symbol-spacing":2,"text-line-height":1},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},p)}}else y=await(await fetch(t)).json();if(n!=="all"){const x=document.createElement("div");x.id="titleDivMenu",x.textContent=e,a.appendChild(x);const C=document.createElement("div");C.id="titleDivMenuSub",C.textContent=`📂 ${n}`,a.appendChild(C)}let b;if(i.type?b=i.type:b=y.features[0].geometry.type,n==="all")b.includes("ine")&&(i!==void 0?this.map.addLayer({id:e,type:"line",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"line",source:{type:"geojson",data:y},layout:{visibility:"visible"},paint:{"line-color":"black","line-width":2,"line-opacity":1}},p)),b.includes("olygon")&&(i!==void 0?this.map.addLayer({id:e,type:"fill",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"fill",source:{type:"geojson",data:y},layout:{visibility:"visible"},paint:{"fill-color":"#0000FF","fill-opacity":0}},p)),b.includes("oint")&&(i!==void 0?this.map.addLayer({id:e,type:"circle",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"circle",source:{type:"geojson",data:y},layout:{visibility:"visible"},paint:{"circle-color":"red","circle-opacity":.85}},p)),b.includes("ymbol")&&(i!==void 0?this.map.addLayer({id:e,type:"symbol",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"symbol",source:{type:"geojson",data:y},layout:{visibility:"visible"},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},p)),this.addMenuItem(e);else{let x=n;const C={};y.features.forEach(P=>{const M=P.properties[x],k=M+"-userFieldFilter-"+e;M!==null&&(C[k]||(b.includes("ine")&&(i!==void 0?this.map.addLayer({id:k,type:"line",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint,filter:["==",`${x}`,M]},p):this.map.addLayer({id:k,type:"line",source:{type:"geojson",data:y},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"line-color":"black","line-width":2,"line-opacity":1}},p)),b.includes("olygon")&&(i!==void 0?this.map.addLayer({id:k,type:"fill",source:{type:"geojson",data:y},filter:["==",`${x}`,M],layout:i.layout,paint:i.paint},p):this.map.addLayer({id:k,type:"fill",source:{type:"geojson",data:y},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"fill-color":"blue","fill-opacity":.6}},p)),b.includes("oint")&&(i!==void 0?this.map.addLayer({id:k,type:"circle",source:{type:"geojson",data:y},filter:["==",`${x}`,M],layout:i.layout,paint:i.paint},p):this.map.addLayer({id:k,type:"circle",source:{type:"geojson",data:y},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"circle-color":"red","circle-opacity":.85}},p)),C[k]=!0,this.addMenuItem(k)))})}}}catch(s){console.error(`Error fetching data: ${s.message}`)}}on(t,e){setTimeout(()=>{try{this.map.on(t,e)}catch(n){console.error(`Error adding event ON listener: ${n.message}`)}},500)}setStyle(t,e){try{e!==void 0?this.map.setStyle(t,e):this.map.setStyle(t),this.map.on("styledata",()=>{if(window.document.querySelector(".maplibregl-compact-show")){var n=window.document.querySelector(".maplibregl-compact-show");n.classList.remove("maplibregl-compact-show")}this._dealOrto3dStyle(this.map.getStyle().name)})}catch(n){console.error(`Error setting style: ${n.message}`)}}addControl(t,e){try{e===void 0&&(e="top-right"),this.map.addControl(t,e)}catch(n){console.error(`Error adding control: ${n.message}`)}}setSky(t){try{t===void 0&&(this.map.options.style.includes("orto")&&(t={"sky-color":"#86bbd5","sky-horizon-blend":.3,"horizon-color":"#ffffff33","horizon-fog-blend":.1,"fog-ground-blend":.75,"fog-color":"#c5d6d6"}),this.map.options.style.includes("mapa_estandard_general")&&(t={"sky-color":"#a5f0f0","sky-horizon-blend":.3,"horizon-color":"#e1e3e3","horizon-fog-blend":.9,"fog-ground-blend":.85,"fog-color":"#c5d6d6"}),this.map.options.style.includes("fosc")&&(t={"sky-color":"#232423","sky-horizon-blend":.3,"horizon-color":"#969996","horizon-fog-blend":.9,"fog-ground-blend":.85,"fog-color":"#383838"})),this.map.setSky(t)}catch(e){console.error(`Error setting sky properties: ${e.message}`)}}addMouseCoordControl(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"bottom-left";try{this.map.addControl(new Jnt(t),e)}catch(n){console.error(`Error adding mouse coordinate control: ${n.message}`)}}addGeolocateControl(t,e){try{e===void 0&&(e="top-right"),t===void 0?this.map.addControl(new Ls.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!0}),e):this.map.addControl(new Ls.GeolocateControl(t),e)}catch(n){console.error(`Error adding geolocate control: ${n.message}`)}}addFullscreenControl(t,e){try{e===void 0&&(e="top-right"),t===void 0?this.map.addControl(new Ls.FullscreenControl({container:HTMLElement}),e):this.map.addControl(new Ls.FullscreenControl(t),e)}catch(n){console.error(`Error adding fullscreen control: ${n.message}`)}}addLayer(t,e){try{this.map.addLayer(t,e)}catch(n){console.error(`Error adding layer: ${n.message}`)}}addImage(t,e,n){try{this.map.addImage(t,e,n)}catch(i){console.error(`Error adding image: ${i.message}`)}return this}addSource(t,e){try{this.map.addSource(t,e)}catch(n){console.error(`Error adding source: ${n.message}`)}return this}addSprite(t,e,n){try{this.map.addSprite(t,e,n)}catch(i){console.error(`Error adding sprite: ${i.message}`)}return this}areTilesLoaded(){return this.map.areTilesLoaded()}cameraForBounds(t,e){return this.map.cameraForBounds(t,e)}easeTo(t,e){return this.map.easeTo(t,e),this}fitBounds(t,e,n){return this.map.fitBounds(t,e,n),this}fitScreenCoordinates(t,e,n,i,s){return this.map.fitScreenCoordinates(t,e,n,i,s),this}flyTo(t,e){return this.map.flyTo(t,e),this}getBearing(){return this.map.getBearing()}getBounds(){return this.map.getBounds()}getCameraTargetElevation(){return this.map.getCameraTargetElevation()}getCanvas(){return this.map.getCanvas()}getCanvasContainer(){return this.map.getCanvasContainer()}getCenter(){return this.map.getCenter()}getContainer(){return this.map.getContainer()}getFeatureState(t){return this.map.getFeatureState(t)}getFilter(t){return this.map.getFilter(t)}getGlyphs(){return this.map.getGlyphs()}getImage(t){return this.map.getImage(t)}getLayer(t){return this.map.getLayer(t)}getLayersOrder(){return this.map.getLayersOrder()}getLayoutProperty(t,e){return this.map.getLayoutProperty(t,e)}getLight(){return this.map.getLight()}getMaxBounds(){return this.map.getMaxBounds()}getMaxPitch(){return this.map.getMaxPitch()}getMaxZoom(){return this.map.getMaxZoom()}getMinPitch(){return this.map.getMinPitch()}getMinZoom(){return this.map.getMinZoom()}getPadding(){return this.map.getPadding()}getPaintProperty(t,e){return this.map.getPaintProperty(t,e)}getPitch(){return this.map.getPitch()}getPixelRatio(){return this.map.getPixelRatio()}getRenderWorldCopies(){return this.map.getRenderWorldCopies()}getSource(t){return this.map.getSource(t)}getSprite(){return this.map.getSprite()}getStyle(){return this.map.getStyle()}getTerrain(){return this.map.getTerrain()}getZoom(){return this.map.getZoom()}hasControl(t){return this.map.hasControl(t)}hasImage(t){return this.map.hasImage(t)}isMoving(){return this.map.isMoving()}isRotating(){return this.map.isRotating()}isSourceLoaded(t){return this.map.isSourceLoaded(t)}isStyleLoaded(){return this.map.isStyleLoaded()}isZooming(){return this.map.isZooming()}jumpTo(t,e){return this.map.jumpTo(t,e)}listImages(){return this.map.listImages()}listens(t){return this.map.listens(t)}loadImage(t){return this.map.loadImage(t)}loaded(){return this.map.loaded()}LngLatBounds(t,e){return new Ls.LngLatBounds(t,e)}addProtocol(t,e){return this.map.addProtocol(t,e)}moveLayer(t,e){return this.map.moveLayer(t,e)}panBy(t,e,n){return this.map.panBy(t,e,n)}panTo(t,e,n){return this.map.panTo(t,e,n)}project(t){return this.map.project(t)}queryRenderedFeatures(t,e){return this.map.queryRenderedFeatures(t,e)}querySourceFeatures(t,e){return this.map.querySourceFeatures(t,e)}queryTerrainElevation(t){return this.map.queryTerrainElevation(t)}redraw(){return this.map.redraw()}remove(){return this.map.remove()}removeControl(t){return this.map.removeControl(t)}removeFeatureState(t,e){return this.map.removeFeatureState(t,e)}removeImage(t){return this.map.removeImage(t)}removeLayer(t){try{this.map.removeLayer(t)}catch(e){console.error(`Error removing layer: ${e.message}`)}}removeSource(t){try{this.map.removeSource(t)}catch(e){console.error(`Error removing source: ${e.message}`)}}removeSprite(t){return this.map.removeSprite(t)}resetNorth(t,e){return this.map.resetNorth(t,e)}resetNorthPitch(t,e){return this.map.resetNorthPitch(t,e)}resize(t){return this.map.resize(t)}rotateTo(t,e,n){return this.map.rotateTo(t,e,n)}setBearing(t,e){return this.map.setBearing(t,e)}setCenter(t,e){return this.map.setCenter(t,e)}setEventedParent(t,e){return this.map.setEventedParent(t,e)}setFeatureState(t,e){return this.map.setFeatureState(t,e)}setFilter(t,e,n){return this.map.setFilter(t,e,n)}setGlyphs(t,e){return this.map.setGlyphs(t,e)}setLayerZoomRange(t,e,n){return this.map.setLayerZoomRange(t,e,n)}setLayoutProperty(t,e,n,i){return this.map.setLayoutProperty(t,e,n,i)}setLight(t,e){return this.map.setLight(t,e)}setMaxBounds(t){return this.map.setMaxBounds(t)}setMaxPitch(t){return this.map.setMaxPitch(t)}setMaxZoom(t){return this.map.setMaxZoom(t)}setMinPitch(t){return this.map.setMinPitch(t)}setMinZoom(t){return this.map.setMinZoom(t)}setPadding(t,e){return this.map.setPadding(t,e)}setPaintProperty(t,e,n,i){return this.map.setPaintProperty(t,e,n,i)}setPitch(t,e){return this.map.setPitch(t,e)}setPixelRatio(t){return this.map.setPixelRatio(t)}setRenderWorldCopies(t){return this.map.setRenderWorldCopies(t)}setSprite(t,e){return this.map.setSprite(t,e)}setTerrain(t){return this.map.setTerrain(t)}setTransformRequest(t){return this.map.setTransformRequest(t)}setZoom(t,e){return this.map.setZoom(t,e)}snapToNorth(t,e){return this.map.snapToNorth(t,e)}stop(){return this.map.stop()}triggerRepaint(){return this.map.triggerRepaint()}unproject(t){return this.map.unproject(t)}updateImage(t,e){return this.map.updateImage(t,e)}zoomIn(t,e){return this.map.zoomIn(t,e)}zoomOut(t,e){return this.map.zoomOut(t,e)}zoomTo(t,e,n){return this.map.zoomTo(t,e,n)}addLayerGeoJSON(t,e){try{let n=this._dealOrderLayer(e);this.map.addSource(`${t.id}`,{type:"geojson",data:t.data}),this.map.addLayer({id:`${t.id}-layerIcgcMap`,type:t.type,source:`${t.id}`,layout:t.layout,paint:t.paint},n)}catch(n){console.error(`Error adding GeoJSON layer: ${n.message}`)}}addLayerWMS(t,e,n){try{let i=this._dealOrderLayer(n.layerPosition);n?(this.map.addSource(`${e}`,{type:"raster",tiles:[t],tileSize:256},i),this.map.addLayer({id:e,type:"raster",source:e,layout:n.layout,paint:n.paint},i)):(this.map.addSource(`${e}`,{type:"raster",tiles:[t],tileSize:256},i),this.map.addLayer({id:e,type:"raster",source:e,paint:{}},i))}catch(i){console.error(`Error adding WMS layer: ${i.message}`)}}addLogo(t){try{let e=document.getElementById("map"),n;n=document.createElement("div"),n.id="logos",e.appendChild(n);const i=document.createElement("img");i.src=t.url,i.style.height=t.height;const s=document.getElementById("logos"),a=document.createElement("a");a.id=t.id,a.href=t.href,a.target="_blank",a.style.position="relative",a.style.bottom="1px",a.appendChild(i),s.appendChild(a)}catch(e){console.error(`Error adding logo: ${e.message}`)}}addBasemapsICGC(t){try{const e=a=>{this.map.setStyle(a)};let n=document.getElementById("map"),i;i=document.createElement("div"),i.id="basemap-group",i.classList.add="filter-group",n.appendChild(i);const s=document.getElementById("basemap-group");for(const a of t)for(const o of Object.keys(Pn.baseStyles)){const d=Pn.baseStyles[o];if(a===d.url){const p=document.createElement("div");p.className="basemap-item",p.title=d.key,p.style.backgroundImage=`url('${d.image}')`,s.appendChild(p),p.addEventListener("click",()=>e(d.url))}}}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addBasemaps(t){try{const e=a=>{map.setStyle(a.url)};let n=document.getElementById("map"),i;i=document.createElement("div"),i.id="basemap-group",i.classList.add="basemap-group",n.appendChild(i);const s=document.getElementById("basemap-group");t.forEach(a=>{const o=document.createElement("div");o.className="basemap-item",o.title=a.label,o.style.backgroundImage=`url('${a.image}')`,s.appendChild(o),o.addEventListener("click",()=>e(a))})}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addFeatureQuery(t,e,n){try{let i;this.map.on("mouseenter",t,()=>{this.map.getCanvas().style.cursor="pointer"}),this.map.on("mouseleave",t,()=>{this.map.getCanvas().style.cursor=""}),this.map.on("click",s=>{let a=this.map.queryRenderedFeatures(s.point);if(a&&a[0].source.includes(t)){let o=[s.lngLat.lng,s.lngLat.lat];if(e!==void 0&&e.length>0&&e!=="all"){if(e!==null){let d="";e.forEach(p=>{let y=a[0].properties[p];d=d+`

${y}

`}),i=d,this.addPopup(o,i,n)}}else{let d="";for(const p in a[0].properties)d+=""+p+":"+a[0].properties[p]+"
";i=d,this.addPopup(o,i,n)}}})}catch(i){console.error(`Error adding feature query: ${i.message}`)}}addScaleControl(t,e){try{var n=new Ls.ScaleControl(t);this.map.addControl(n,e)}catch(i){console.error(`Error adding scale: ${i.message}`)}}addExportControl(t,e){try{typeof t=="string"&&(e=t,t=void 0),t===void 0&&(t={PageSize:Zh.A4,PageOrientation:Ng.Landscape,Format:Vu.PNG,DPI:x2[300],Crosshair:!0,PrintableArea:!0,Local:"ca"},e="top-right"),this.map.addControl(new rnt(t),e)}catch(n){console.error(`Error adding export control: ${n.message}`)}}addMarker(t){try{let e,n;return t.text===void 0?e=new Ls.Marker(t.options).setLngLat(t.coord).addTo(this.map):(n=new Ls.Popup({offset:t.textOffset}).setHTML(t.text),e=new Ls.Marker(t.options).setLngLat(t.coord).setPopup(n).addTo(this.map)),e}catch(e){return console.error(`Error adding marker: ${e.message}`),null}}addPopup(t,e,n){try{return n.image===void 0?new Ls.Popup().setLngLat(t).setHTML(` +`+s):n.stack=s}throw n}}_request(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=Hf(this.defaults,e);const{transitional:n,paramsSerializer:i,headers:s}=e;n!==void 0&&lx.assertOptions(n,{silentJSONParsing:$A.transitional($A.boolean),forcedJSONParsing:$A.transitional($A.boolean),clarifyTimeoutError:$A.transitional($A.boolean)},!1),i!=null&&(Se.isFunction(i)?e.paramsSerializer={serialize:i}:lx.assertOptions(i,{encode:$A.function,serialize:$A.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let a=s&&Se.merge(s.common,s[e.method]);s&&Se.forEach(["delete","get","head","post","put","patch","common"],P=>{delete s[P]}),e.headers=dl.concat(a,s);const o=[];let d=!0;this.interceptors.request.forEach(function(M){typeof M.runWhen=="function"&&M.runWhen(e)===!1||(d=d&&M.synchronous,o.unshift(M.fulfilled,M.rejected))});const p=[];this.interceptors.response.forEach(function(M){p.push(M.fulfilled,M.rejected)});let y,b=0,x;if(!d){const P=[v4.bind(this),void 0];for(P.unshift.apply(P,o),P.push.apply(P,p),x=P.length,y=Promise.resolve(e);b{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const a=new Promise(o=>{n.subscribe(o),s=o}).then(i);return a.cancel=function(){n.unsubscribe(s)},a},t(function(s,a,o){n.reason||(n.reason=new $g(s,a,o),e(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);e!==-1&&this._listeners.splice(e,1)}static source(){let t;return{token:new cx(function(i){t=i}),cancel:t}}}function nst(r){return function(e){return r.apply(null,e)}}function ist(r){return Se.isObject(r)&&r.isAxiosError===!0}const ux={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ux).forEach(r=>{let[t,e]=r;ux[e]=t});function B4(r){const t=new sd(r),e=KP(sd.prototype.request,t);return Se.extend(e,sd.prototype,t,{allOwnKeys:!0}),Se.extend(e,t,null,{allOwnKeys:!0}),e.create=function(i){return B4(Hf(r,i))},e}const as=B4(qg);as.Axios=sd,as.CanceledError=$g,as.CancelToken=cx,as.isCancel=p4,as.VERSION=w4,as.toFormData=Xy,as.AxiosError=In,as.Cancel=as.CanceledError,as.all=function(t){return Promise.all(t)},as.spread=nst,as.isAxiosError=ist,as.mergeConfig=Hf,as.AxiosHeaders=dl,as.formToJSON=r=>d4(Se.isHTMLForm(r)?new FormData(r):r),as.getAdapter=_4.getAdapter,as.HttpStatusCode=ux,as.default=as;const sst="https://tilemaps.icgc.cat/cdn/configs/mapicgc-config.json",ost=5e3;class C4{static async getConfigICGC(){try{const t=await as.get(sst,{timeout:ost});return t.data?t.data:(console.log("Resposta sense dades:",t),id)}catch(t){return t.response?(console.error("Error de resposta:",t.response.data),console.error("Codi d'estat:",t.response.status)):t.request?console.error("No s'ha rebut resposta del servidor:",t.request):console.error("Error:",t.message),id}}}const ast={cobertesSol:{"fill-opacity":["interpolate",["exponential",.5],["zoom"],13.5,1,18,.4],"fill-outline-color":"rgba(0,0, 0, 0)","fill-color":["interpolate",["cubic-bezier",.5,1,1,1],["get","nivell_2"],0,"#ffffff",111,"#ffff00",112,"#ccff33",113,"#af5b15",114,"#808000",115,"#cdcd00",116,"#ffffcc",221,"#33cc33",222,"#66ff33",223,"#689018",224,"#967d5f",225,"#19e61e",226,"#b4ff9b",227,"#aaa500",228,"#c3c3a0",229,"#00ff9b",230,"#ff9632",231,"#282828",232,"#79797a",233,"#f5df78",234,"#3296ff",341,"#ff007d",342,"#ff53cd",343,"#ffa4e2",344,"#ffc8e2",345,"#ffb4b4",346,"#0f3700",347,"#730055",348,"#6200c4",349,"#4a9595",350,"#ff00f0",351,"#adaaca",352,"#ffe6e6",353,"#67629a",354,"#4a466e",355,"#2f2d46",461,"#6f6fff",462,"#0000dc",463,"#000064",464,"#185f94",465,"#12466d",466,"#000080"]}},lst="lines",Yy="labels";let od,Wg,Qi,Pn,cst=class{constructor(t){C4.getConfigICGC().then(e=>{od={...e.Styles},Qi={...e.Layers},Wg={...e.Terrains},Pn={...e.defaultOptions},this.initTheMap(t)}).catch(e=>{console.info("Configuracio per defecte",e),od={...id.Styles},Qi={...id.Layers},Wg={...id.Terrains},Pn={...id.defaultOptions},this.initTheMap(t)})}initTheMap(t){if(!t)t=Pn.mapOptions;else for(const e in Pn.mapOptions){let n=[Pn.mapOptions.center[0],Pn.mapOptions.center[1]];Pn.mapOptions.center=n,t.hasOwnProperty(e)||(t[e]=Pn.mapOptions[e])}t.maxPitch=85,t.maplibreLogo=!1,t.attributionControl=!1,this.map=new Ls.Map(t),this.map.options=t,this.map.addControl(new Ls.AttributionControl({compact:!0})),this.map.on("load",async()=>{const e=this.map.getStyle().name,n=this.map.options.style;if(window.document.querySelector(".maplibregl-compact-show")){var i=window.document.querySelector(".maplibregl-compact-show");i.classList.remove("maplibregl-compact-show")}this.map.addControl(new Knt({color:n.indexOf("orto")===-1,defaultOptions:Pn}),"bottom-left"),this._dealOrto3dStyle(e)})}addGeocoderICGC(t){try{t===void 0&&(t="top-right");let e={collapsed:!0,marker:!0,popup:!0,showResultMarkers:!0,maplibregl:Ls,showResultsWhileTyping:!0,minLength:2};const n={forwardGeocode:async s=>{const a=[];try{const o=Pn.geocoder.peliasUrl1+encodeURIComponent(s.query)+Pn.geocoder.peliasUrl2,p=await(await fetch(o)).json();for(const y of p.features){const b=y.geometry.coordinates,x={type:"Feature",geometry:{type:"Point",coordinates:b},place_name:y.properties.etiqueta,properties:y.properties,text:y.properties.etiqueta,place_type:["place"],center:b};a.push(x)}}catch(o){console.error(`Failed to forwardGeocode with error: ${o}`)}return{features:a}}};this.map.addControl(new qnt(n,e),t);let i=document.getElementsByClassName("maplibregl-ctrl-geocoder--input");i[0].attributes[2].nodeValue="Cerca...",i[0].addEventListener("input",function(s){s.target.value.length>3})}catch(e){console.error(`Error adding ICGC geocoder: ${e.message}`)}}async loadImage(t){try{return this.map.loadImage(t)}catch(e){console.error(`Error getting loadImage: ${e.message}`)}}getConfigStyles(){try{let t=[];for(const e of od)t.push(e.name);return t}catch(t){console.error(`Error retrieving base styles: ${t.message}`)}}getConfigWMSLayers(){try{let t=[];for(const e in Qi.WMS)Qi.WMS.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving WMS layers: ${t.message}`)}}getConfigOrtoLayers(){try{let t=[];for(const e in Qi.Orto)Qi.Orto.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving orto image layers: ${t.message}`)}}getConfigVectorLayers(){try{let t=[];for(const e in Qi.Vector)Qi.Vector.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving vector layers: ${t.message}`)}}getConfigVectorAdminLayers(){try{let t=[];for(const e in Qi.VectorAdmin)Qi.VectorAdmin.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving vectorAdmin layers: ${t.message}`)}}getConfigFGBAdminLayers(){try{let t=[];for(const e in Qi.FGBAdmin)Qi.FGBAdmin.hasOwnProperty(e)&&t.push(e);return t}catch(t){console.error(`Error retrieving FGBAdmin layers: ${t.message}`)}}async fetchData(t,e,n){try{(!n||n===void 0)&&(n={type:"line",layout:{visibility:"visible"},paint:{"line-color":"grey","line-width":2},layerPosition:"top"});let i=n.layerPosition;if(t.includes(".fgb"))this.addFGBLayerICGC(t,e,n);else{const a=await(await fetch(t)).json();let o=e,d=this._dealOrderLayer(i),p=a.features[0].geometry.type;p.includes("ine")&&(n!==void 0?this.map.addLayer({id:o,type:"line",source:{type:"geojson",data:a},layout:n.layout||{},paint:n.paint||{}},d):this.map.addLayer({id:o,type:"line",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"line-color":"black","line-width":2,"line-opacity":1}},d)),p.includes("olygon")&&(n!==void 0?this.map.addLayer({id:o,type:"fill",source:{type:"geojson",data:a},layout:n.layout,paint:n.paint},d):this.map.addLayer({id:o,type:"fill",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"fill-color":"blue","fill-opacity":.6}},d)),p.includes("oint")&&(n!==void 0?this.map.addLayer({id:o,type:"circle",source:{type:"geojson",data:a},layout:n.layout,paint:n.paint},d):this.map.addLayer({id:o,type:"circle",source:{type:"geojson",data:a},layout:{visibility:"visible"},paint:{"circle-color":"red","circle-opacity":.85}},d))}}catch(i){console.error(`Error fetching data: ${i.message}`)}}async fetchDataAndMenu(t,e,n,i){try{let s;i!==null?s=i.layerPosition:s=Yy;let a,o=document.getElementById("map");if(document.getElementById("menu-group")?a=document.getElementById("menu-group"):(a=document.createElement("nav"),a.id="menu-group",a.classList.add="filter-group",o.appendChild(a)),a!==null){let d="visible",p=this._dealOrderLayer(s),y;if(t.includes(".fgb")){let x=this._getKeyByUrlFGB(t);x===null&&(x="userFGB");const C=await fetch(t),P={type:"FeatureCollection",features:[]};for await(const k of US(C.body))P.features.push(k);y=P;let M=e;if(this.map.addSource(M,{type:"geojson",data:P}),t.includes("text"))i!==void 0?this.map.addLayer({id:e,type:"symbol",source:M,layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"symbol",source:M,layout:{"text-letter-spacing":.1,"text-size":{base:1.2,stops:[[8,0],[12,14],[15,15]]},"text-font":["FiraSans-Regular"],"text-field":["get","NOM_AC"],"text-transform":"none","text-max-width":25,visibility:d,"text-justify":"right","text-anchor":"top","text-allow-overlap":!1,"symbol-spacing":2,"text-line-height":1},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},p);else{let k=e+"Text";this.map.addLayer({id:k,type:"symbol",source:M,layout:{"text-letter-spacing":.1,"text-size":{base:1.2,stops:[[8,0],[12,14],[15,15]]},"text-font":["FiraSans-Regular"],"text-field":["get","NOM_AC"],"text-transform":"none","text-max-width":25,visibility:d,"text-justify":"right","text-anchor":"top","text-allow-overlap":!1,"symbol-spacing":2,"text-line-height":1},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},p)}}else y=await(await fetch(t)).json();if(n!=="all"){const x=document.createElement("div");x.id="titleDivMenu",x.textContent=e,a.appendChild(x);const C=document.createElement("div");C.id="titleDivMenuSub",C.textContent=`📂 ${n}`,a.appendChild(C)}let b;if(i.type?b=i.type:b=y.features[0].geometry.type,n==="all")b.includes("ine")&&(i!==void 0?this.map.addLayer({id:e,type:"line",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"line",source:{type:"geojson",data:y},layout:{visibility:"visible"},paint:{"line-color":"black","line-width":2,"line-opacity":1}},p)),b.includes("olygon")&&(i!==void 0?this.map.addLayer({id:e,type:"fill",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"fill",source:{type:"geojson",data:y},layout:{visibility:"visible"},paint:{"fill-color":"#0000FF","fill-opacity":0}},p)),b.includes("oint")&&(i!==void 0?this.map.addLayer({id:e,type:"circle",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"circle",source:{type:"geojson",data:y},layout:{visibility:"visible"},paint:{"circle-color":"red","circle-opacity":.85}},p)),b.includes("ymbol")&&(i!==void 0?this.map.addLayer({id:e,type:"symbol",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint},p):this.map.addLayer({id:e,type:"symbol",source:{type:"geojson",data:y},layout:{visibility:"visible"},paint:{"text-halo-blur":.5,"text-color":"rgba(90, 7, 7, 1)","text-halo-width":2,"text-halo-color":"rgba(255, 255, 255,0.8)"}},p)),this.addMenuItem(e);else{let x=n;const C={};y.features.forEach(P=>{const M=P.properties[x],k=M+"-userFieldFilter-"+e;M!==null&&(C[k]||(b.includes("ine")&&(i!==void 0?this.map.addLayer({id:k,type:"line",source:{type:"geojson",data:y},layout:i.layout,paint:i.paint,filter:["==",`${x}`,M]},p):this.map.addLayer({id:k,type:"line",source:{type:"geojson",data:y},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"line-color":"black","line-width":2,"line-opacity":1}},p)),b.includes("olygon")&&(i!==void 0?this.map.addLayer({id:k,type:"fill",source:{type:"geojson",data:y},filter:["==",`${x}`,M],layout:i.layout,paint:i.paint},p):this.map.addLayer({id:k,type:"fill",source:{type:"geojson",data:y},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"fill-color":"blue","fill-opacity":.6}},p)),b.includes("oint")&&(i!==void 0?this.map.addLayer({id:k,type:"circle",source:{type:"geojson",data:y},filter:["==",`${x}`,M],layout:i.layout,paint:i.paint},p):this.map.addLayer({id:k,type:"circle",source:{type:"geojson",data:y},layout:{visibility:"visible"},filter:["==",`${x}`,M],paint:{"circle-color":"red","circle-opacity":.85}},p)),C[k]=!0,this.addMenuItem(k)))})}}}catch(s){console.error(`Error fetching data: ${s.message}`)}}on(t,e){setTimeout(()=>{try{return this.map.on(t,e)}catch(n){console.error(`Error adding event ON listener: ${n.message}`)}},100)}setStyle(t,e){try{e!==void 0?this.map.setStyle(t,e):this.map.setStyle(t),this.map.on("styledata",()=>{if(window.document.querySelector(".maplibregl-compact-show")){var n=window.document.querySelector(".maplibregl-compact-show");n.classList.remove("maplibregl-compact-show")}this._dealOrto3dStyle(this.map.getStyle().name)})}catch(n){console.error(`Error setting style: ${n.message}`)}}addControl(t,e){try{e===void 0&&(e="top-right"),this.map.addControl(t,e)}catch(n){console.error(`Error adding control: ${n.message}`)}}setSky(t){try{t===void 0&&(this.map.options.style.includes("orto")&&(t={"sky-color":"#86bbd5","sky-horizon-blend":.3,"horizon-color":"#ffffff33","horizon-fog-blend":.1,"fog-ground-blend":.75,"fog-color":"#c5d6d6"}),this.map.options.style.includes("mapa_estandard_general")&&(t={"sky-color":"#a5f0f0","sky-horizon-blend":.3,"horizon-color":"#e1e3e3","horizon-fog-blend":.9,"fog-ground-blend":.85,"fog-color":"#c5d6d6"}),this.map.options.style.includes("fosc")&&(t={"sky-color":"#232423","sky-horizon-blend":.3,"horizon-color":"#969996","horizon-fog-blend":.9,"fog-ground-blend":.85,"fog-color":"#383838"})),this.map.setSky(t)}catch(e){console.error(`Error setting sky properties: ${e.message}`)}}addMouseCoordControl(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"bottom-left";try{this.map.addControl(new Jnt(t),e)}catch(n){console.error(`Error adding mouse coordinate control: ${n.message}`)}}addGeolocateControl(t,e){try{e===void 0&&(e="top-right"),t===void 0?this.map.addControl(new Ls.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!0}),e):this.map.addControl(new Ls.GeolocateControl(t),e)}catch(n){console.error(`Error adding geolocate control: ${n.message}`)}}addFullscreenControl(t,e){try{e===void 0&&(e="top-right"),t===void 0?this.map.addControl(new Ls.FullscreenControl({container:HTMLElement}),e):this.map.addControl(new Ls.FullscreenControl(t),e)}catch(n){console.error(`Error adding fullscreen control: ${n.message}`)}}addLayer(t,e){try{this.map.addLayer(t,e)}catch(n){console.error(`Error adding layer: ${n.message}`)}}addImage(t,e,n){try{this.map.addImage(t,e,n)}catch(i){console.error(`Error adding image: ${i.message}`)}return this}addSource(t,e){try{this.map.addSource(t,e)}catch(n){console.error(`Error adding source: ${n.message}`)}return this}addSprite(t,e,n){try{this.map.addSprite(t,e,n)}catch(i){console.error(`Error adding sprite: ${i.message}`)}return this}areTilesLoaded(){return this.map.areTilesLoaded()}cameraForBounds(t,e){return this.map.cameraForBounds(t,e)}easeTo(t,e){return this.map.easeTo(t,e),this}fitBounds(t,e,n){return this.map.fitBounds(t,e,n),this}fitScreenCoordinates(t,e,n,i,s){return this.map.fitScreenCoordinates(t,e,n,i,s),this}flyTo(t,e){return this.map.flyTo(t,e),this}getBearing(){return this.map.getBearing()}getBounds(){return this.map.getBounds()}getCameraTargetElevation(){return this.map.getCameraTargetElevation()}getCanvas(){return this.map.getCanvas()}getCanvasContainer(){return this.map.getCanvasContainer()}getCenter(){return this.map.getCenter()}getContainer(){return this.map.getContainer()}getFeatureState(t){return this.map.getFeatureState(t)}getFilter(t){return this.map.getFilter(t)}getGlyphs(){return this.map.getGlyphs()}getImage(t){return this.map.getImage(t)}getLayer(t){return this.map.getLayer(t)}getLayersOrder(){return this.map.getLayersOrder()}getLayoutProperty(t,e){return this.map.getLayoutProperty(t,e)}getLight(){return this.map.getLight()}getMaxBounds(){return this.map.getMaxBounds()}getMaxPitch(){return this.map.getMaxPitch()}getMaxZoom(){return this.map.getMaxZoom()}getMinPitch(){return this.map.getMinPitch()}getMinZoom(){return this.map.getMinZoom()}getPadding(){return this.map.getPadding()}getPaintProperty(t,e){return this.map.getPaintProperty(t,e)}getPitch(){return this.map.getPitch()}getPixelRatio(){return this.map.getPixelRatio()}getRenderWorldCopies(){return this.map.getRenderWorldCopies()}getSource(t){return this.map.getSource(t)}getSprite(){return this.map.getSprite()}getStyle(){return this.map.getStyle()}getTerrain(){return this.map.getTerrain()}getZoom(){return this.map.getZoom()}hasControl(t){return this.map.hasControl(t)}hasImage(t){return this.map.hasImage(t)}isMoving(){return this.map.isMoving()}isRotating(){return this.map.isRotating()}isSourceLoaded(t){return this.map.isSourceLoaded(t)}isStyleLoaded(){return this.map.isStyleLoaded()}isZooming(){return this.map.isZooming()}jumpTo(t,e){return this.map.jumpTo(t,e)}listImages(){return this.map.listImages()}listens(t){return this.map.listens(t)}loadImage(t){return this.map.loadImage(t)}loaded(){return this.map.loaded()}LngLatBounds(t,e){return new Ls.LngLatBounds(t,e)}addProtocol(t,e){return this.map.addProtocol(t,e)}moveLayer(t,e){return this.map.moveLayer(t,e)}panBy(t,e,n){return this.map.panBy(t,e,n)}panTo(t,e,n){return this.map.panTo(t,e,n)}project(t){return this.map.project(t)}queryRenderedFeatures(t,e){return this.map.queryRenderedFeatures(t,e)}querySourceFeatures(t,e){return this.map.querySourceFeatures(t,e)}queryTerrainElevation(t){return this.map.queryTerrainElevation(t)}redraw(){return this.map.redraw()}remove(){return this.map.remove()}removeControl(t){return this.map.removeControl(t)}removeFeatureState(t,e){return this.map.removeFeatureState(t,e)}removeImage(t){return this.map.removeImage(t)}removeLayer(t){try{this.map.removeLayer(t)}catch(e){console.error(`Error removing layer: ${e.message}`)}}removeSource(t){try{this.map.removeSource(t)}catch(e){console.error(`Error removing source: ${e.message}`)}}removeSprite(t){return this.map.removeSprite(t)}resetNorth(t,e){return this.map.resetNorth(t,e)}resetNorthPitch(t,e){return this.map.resetNorthPitch(t,e)}resize(t){return this.map.resize(t)}rotateTo(t,e,n){return this.map.rotateTo(t,e,n)}setBearing(t,e){return this.map.setBearing(t,e)}setCenter(t,e){return this.map.setCenter(t,e)}setEventedParent(t,e){return this.map.setEventedParent(t,e)}setFeatureState(t,e){return this.map.setFeatureState(t,e)}setFilter(t,e,n){return this.map.setFilter(t,e,n)}setGlyphs(t,e){return this.map.setGlyphs(t,e)}setLayerZoomRange(t,e,n){return this.map.setLayerZoomRange(t,e,n)}setLayoutProperty(t,e,n,i){return this.map.setLayoutProperty(t,e,n,i)}setLight(t,e){return this.map.setLight(t,e)}setMaxBounds(t){return this.map.setMaxBounds(t)}setMaxPitch(t){return this.map.setMaxPitch(t)}setMaxZoom(t){return this.map.setMaxZoom(t)}setMinPitch(t){return this.map.setMinPitch(t)}setMinZoom(t){return this.map.setMinZoom(t)}setPadding(t,e){return this.map.setPadding(t,e)}setPaintProperty(t,e,n,i){return this.map.setPaintProperty(t,e,n,i)}setPitch(t,e){return this.map.setPitch(t,e)}setPixelRatio(t){return this.map.setPixelRatio(t)}setRenderWorldCopies(t){return this.map.setRenderWorldCopies(t)}setSprite(t,e){return this.map.setSprite(t,e)}setTerrain(t){return this.map.setTerrain(t)}setTransformRequest(t){return this.map.setTransformRequest(t)}setZoom(t,e){return this.map.setZoom(t,e)}snapToNorth(t,e){return this.map.snapToNorth(t,e)}stop(){return this.map.stop()}triggerRepaint(){return this.map.triggerRepaint()}unproject(t){return this.map.unproject(t)}updateImage(t,e){return this.map.updateImage(t,e)}zoomIn(t,e){return this.map.zoomIn(t,e)}zoomOut(t,e){return this.map.zoomOut(t,e)}zoomTo(t,e,n){return this.map.zoomTo(t,e,n)}addLayerGeoJSON(t,e){try{let n=this._dealOrderLayer(e);this.map.addSource(`${t.id}`,{type:"geojson",data:t.data}),this.map.addLayer({id:`${t.id}-layerIcgcMap`,type:t.type,source:`${t.id}`,layout:t.layout,paint:t.paint},n)}catch(n){console.error(`Error adding GeoJSON layer: ${n.message}`)}}addLayerWMS(t,e,n){try{let i=this._dealOrderLayer(n.layerPosition);n?(this.map.addSource(`${e}`,{type:"raster",tiles:[t],tileSize:256},i),this.map.addLayer({id:e,type:"raster",source:e,layout:n.layout,paint:n.paint},i)):(this.map.addSource(`${e}`,{type:"raster",tiles:[t],tileSize:256},i),this.map.addLayer({id:e,type:"raster",source:e,paint:{}},i))}catch(i){console.error(`Error adding WMS layer: ${i.message}`)}}addLogo(t){try{let e=document.getElementById("map"),n;n=document.createElement("div"),n.id="logos",e.appendChild(n);const i=document.createElement("img");i.src=t.url,i.style.height=t.height;const s=document.getElementById("logos"),a=document.createElement("a");a.id=t.id,a.href=t.href,a.target="_blank",a.style.position="relative",a.style.bottom="1px",a.appendChild(i),s.appendChild(a)}catch(e){console.error(`Error adding logo: ${e.message}`)}}addBasemapsICGC(t){try{const e=a=>{this.map.setStyle(a)};let n=document.getElementById("map"),i;i=document.createElement("div"),i.id="basemap-group",i.classList.add="filter-group",n.appendChild(i);const s=document.getElementById("basemap-group");for(const a of t)for(const o of Object.keys(Pn.baseStyles)){const d=Pn.baseStyles[o];if(a===d.url){const p=document.createElement("div");p.className="basemap-item",p.title=d.key,p.style.backgroundImage=`url('${d.image}')`,s.appendChild(p),p.addEventListener("click",()=>e(d.url))}}}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addBasemaps(t){try{const e=a=>{map.setStyle(a.url)};let n=document.getElementById("map"),i;i=document.createElement("div"),i.id="basemap-group",i.classList.add="basemap-group",n.appendChild(i);const s=document.getElementById("basemap-group");t.forEach(a=>{const o=document.createElement("div");o.className="basemap-item",o.title=a.label,o.style.backgroundImage=`url('${a.image}')`,s.appendChild(o),o.addEventListener("click",()=>e(a))})}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addFeatureQuery(t,e,n){try{let i;this.map.on("mouseenter",t,()=>{this.map.getCanvas().style.cursor="pointer"}),this.map.on("mouseleave",t,()=>{this.map.getCanvas().style.cursor=""}),this.map.on("click",s=>{let a=this.map.queryRenderedFeatures(s.point);if(a&&a[0].source.includes(t)){let o=[s.lngLat.lng,s.lngLat.lat];if(e!==void 0&&e.length>0&&e!=="all"){if(e!==null){let d="";e.forEach(p=>{let y=a[0].properties[p];d=d+`

${y}

`}),i=d,this.addPopup(o,i,n)}}else{let d="";for(const p in a[0].properties)d+=""+p+":"+a[0].properties[p]+"
";i=d,this.addPopup(o,i,n)}}})}catch(i){console.error(`Error adding feature query: ${i.message}`)}}addScaleControl(t,e){try{var n=new Ls.ScaleControl(t);this.map.addControl(n,e)}catch(i){console.error(`Error adding scale: ${i.message}`)}}addExportControl(t,e){try{typeof t=="string"&&(e=t,t=void 0),t===void 0&&(t={PageSize:Zh.A4,PageOrientation:Ng.Landscape,Format:Vu.PNG,DPI:x2[300],Crosshair:!0,PrintableArea:!0,Local:"ca"},e="top-right"),this.map.addControl(new rnt(t),e)}catch(n){console.error(`Error adding export control: ${n.message}`)}}addMarker(t){try{let e,n;return t.text===void 0?e=new Ls.Marker(t.options).setLngLat(t.coord).addTo(this.map):(n=new Ls.Popup({offset:t.textOffset}).setHTML(t.text),e=new Ls.Marker(t.options).setLngLat(t.coord).setPopup(n).addTo(this.map)),e}catch(e){return console.error(`Error adding marker: ${e.message}`),null}}addPopup(t,e,n){try{return n.image===void 0?new Ls.Popup().setLngLat(t).setHTML(`
${n.title} diff --git a/package.json b/package.json index ec6d041..c291960 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mapicgc-gl-js", "homepage": "https://openicgc.github.io/mapicgc-doc/", - "version": "0.0.86", + "version": "0.0.87", "description": "mapicgc-gl-js library", "author": "Institut Cartogràfic i Geològic de Catalunya", "license": "BSD-3-Clause", diff --git a/src/map/Map.js b/src/map/Map.js index 22a50a9..0e0ac2a 100644 --- a/src/map/Map.js +++ b/src/map/Map.js @@ -868,11 +868,11 @@ export default class Map { on(type, func) { setTimeout(() => { try { - this.map.on(type, func); + return this.map.on(type, func); } catch (error) { console.error(`Error adding event ON listener: ${error.message}`); } - }, 500); + }, 100); } /** diff --git a/test/exemples/addControl.html b/test/exemples/addControl.html index 91c62be..a7931ea 100644 --- a/test/exemples/addControl.html +++ b/test/exemples/addControl.html @@ -41,6 +41,7 @@ pitch: 0, }); map.on("load", () => { + console.log('map', map) // mapicgc-gl-js library: map.addGeolocateControl( {