mapicgc-gl-js 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mapicgc-gl.js +2 -2
- package/dist/mapicgc-gl.mjs +15 -7
- package/package.json +1 -1
- package/src/map/Map.js +32 -3
- package/test/exemples/addBasemap.html +1 -1
- package/test/exemples/addCompare.html +1 -1
- package/test/exemples/addControl.html +1 -1
- package/test/exemples/addFeatureQuery.html +1 -1
- package/test/exemples/addGeocoderICGC.html +1 -1
- package/test/exemples/addICGCTerrain.html +1 -1
- package/test/exemples/addICGCTerrainCustomStyle.html +1 -1
- package/test/exemples/addImageLayerICGC.html +1 -1
- package/test/exemples/addLayerGeojson.html +1 -1
- package/test/exemples/addLayerTree.html +1 -1
- package/test/exemples/addLogo.html +1 -1
- package/test/exemples/addMapStyle.html +1 -1
- package/test/exemples/addMarker.html +1 -1
- package/test/exemples/addMouseCoordinateControl.html +1 -1
- package/test/exemples/addReliefStyle.html +1 -1
- package/test/exemples/addVectorLayerICGC.html +1 -1
- package/test/exemples/advancedExemple.html +1 -1
- package/test/exemples/fetchData.html +1 -1
- package/test/exemples/fetchDataAndMenu.html +1 -1
- package/test/exemples/styleOrto3D.html +1 -1
package/dist/mapicgc-gl.js
CHANGED
|
@@ -3818,7 +3818,7 @@ end`};t.events.push([`putFont`,function(t){(function(t){var n=t.font,i=t.out,a=t
|
|
|
3818
3818
|
`)}getSetCookie(){return this.get(`set-cookie`)||[]}get[Symbol.toStringTag](){return`AxiosHeaders`}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){let n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){let t=(this[o6]=this[o6]={accessors:{}}).accessors,n=this.prototype;function r(e){let r=s6(e);t[r]||(p6(n,e),t[r]=!0)}return $.isArray(e)?e.forEach(r):r(e),this}};m6.accessor([`Content-Type`,`Content-Length`,`Accept`,`Accept-Encoding`,`User-Agent`,`Authorization`]),$.reduceDescriptors(m6.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),$.freezeMethods(m6);function h6(e,t){let n=this||r6,r=t||n,i=m6.from(r.headers),a=r.data;return $.forEach(e,function(e){a=e.call(n,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function g6(e){return!!(e&&e.__CANCEL__)}var _6=class extends A3{constructor(e,t,n){super(e??`canceled`,A3.ERR_CANCELED,t,n),this.name=`CanceledError`,this.__CANCEL__=!0}};function v6(e,t,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new A3(`Request failed with status code `+n.status,[A3.ERR_BAD_REQUEST,A3.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function y6(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||``}function b6(e,t){e||=10;let n=Array(e),r=Array(e),i=0,a=0,o;return t=t===void 0?1e3:t,function(s){let c=Date.now(),l=r[a];o||=c,n[i]=s,r[i]=c;let u=a,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),c-o<t)return;let f=l&&c-l;return f?Math.round(d*1e3/f):void 0}}function x6(e,t){let n=0,r=1e3/t,i,a,o=(t,r=Date.now())=>{n=r,i=null,a&&=(clearTimeout(a),null),e(...t)};return[(...e)=>{let t=Date.now(),s=t-n;s>=r?o(e,t):(i=e,a||=setTimeout(()=>{a=null,o(i)},r-s))},()=>i&&o(i)]}var S6=(e,t,n=3)=>{let r=0,i=b6(50,250);return x6(n=>{let a=n.loaded,o=n.lengthComputable?n.total:void 0,s=a-r,c=i(s),l=a<=o;r=a,e({loaded:a,total:o,progress:o?a/o:void 0,bytes:s,rate:c||void 0,estimated:c&&o&&l?(o-a)/c:void 0,event:n,lengthComputable:o!=null,[t?`download`:`upload`]:!0})},n)},C6=(e,t)=>{let n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},w6=e=>(...t)=>$.asap(()=>e(...t)),T6=Z3.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Z3.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Z3.origin),Z3.navigator&&/(msie|trident)/i.test(Z3.navigator.userAgent)):()=>!0,E6=Z3.hasStandardBrowserEnv?{write(e,t,n,r,i,a,o){if(typeof document>`u`)return;let s=[`${e}=${encodeURIComponent(t)}`];$.isNumber(n)&&s.push(`expires=${new Date(n).toUTCString()}`),$.isString(r)&&s.push(`path=${r}`),$.isString(i)&&s.push(`domain=${i}`),a===!0&&s.push(`secure`),$.isString(o)&&s.push(`SameSite=${o}`),document.cookie=s.join(`; `)},read(e){if(typeof document>`u`)return null;let t=document.cookie.match(RegExp(`(?:^|; )`+e+`=([^;]*)`));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,``,Date.now()-864e5,`/`)}}:{write(){},read(){return null},remove(){}};function D6(e){return typeof e==`string`?/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e):!1}function O6(e,t){return t?e.replace(/\/?\/$/,``)+`/`+t.replace(/^\/+/,``):e}function k6(e,t,n){let r=!D6(t);return e&&(r||n==0)?O6(e,t):t}var A6=e=>e instanceof m6?{...e}:e;function j6(e,t){t||={};let n={};function r(e,t,n,r){return $.isPlainObject(e)&&$.isPlainObject(t)?$.merge.call({caseless:r},e,t):$.isPlainObject(t)?$.merge({},t):$.isArray(t)?t.slice():t}function i(e,t,n,i){if(!$.isUndefined(t))return r(e,t,n,i);if(!$.isUndefined(e))return r(void 0,e,n,i)}function a(e,t){if(!$.isUndefined(t))return r(void 0,t)}function o(e,t){if(!$.isUndefined(t))return r(void 0,t);if(!$.isUndefined(e))return r(void 0,e)}function s(n,i,a){if(a in t)return r(n,i);if(a in e)return r(void 0,n)}let c={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:s,headers:(e,t,n)=>i(A6(e),A6(t),n,!0)};return $.forEach(Object.keys({...e,...t}),function(r){if(r===`__proto__`||r===`constructor`||r===`prototype`)return;let a=$.hasOwnProp(c,r)?c[r]:i,o=a(e[r],t[r],r);$.isUndefined(o)&&a!==s||(n[r]=o)}),n}var M6=e=>{let t=j6({},e),{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:s}=t;if(t.headers=o=m6.from(o),t.url=V3(k6(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),s&&o.set(`Authorization`,`Basic `+btoa((s.username||``)+`:`+(s.password?unescape(encodeURIComponent(s.password)):``))),$.isFormData(n)){if(Z3.hasStandardBrowserEnv||Z3.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if($.isFunction(n.getHeaders)){let e=n.getHeaders(),t=[`content-type`,`content-length`];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&o.set(e,n)})}}if(Z3.hasStandardBrowserEnv&&(r&&$.isFunction(r)&&(r=r(t)),r||r!==!1&&T6(t.url))){let e=i&&a&&E6.read(a);e&&o.set(i,e)}return t},N6=typeof XMLHttpRequest<`u`&&function(e){return new Promise(function(t,n){let r=M6(e),i=r.data,a=m6.from(r.headers).normalize(),{responseType:o,onUploadProgress:s,onDownloadProgress:c}=r,l,u,d,f,p;function m(){f&&f(),p&&p(),r.cancelToken&&r.cancelToken.unsubscribe(l),r.signal&&r.signal.removeEventListener(`abort`,l)}let h=new XMLHttpRequest;h.open(r.method.toUpperCase(),r.url,!0),h.timeout=r.timeout;function g(){if(!h)return;let r=m6.from(`getAllResponseHeaders`in h&&h.getAllResponseHeaders());v6(function(e){t(e),m()},function(e){n(e),m()},{data:!o||o===`text`||o===`json`?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:r,config:e,request:h}),h=null}`onloadend`in h?h.onloadend=g:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf(`file:`)===0)||setTimeout(g)},h.onabort=function(){h&&=(n(new A3(`Request aborted`,A3.ECONNABORTED,e,h)),null)},h.onerror=function(t){let r=new A3(t&&t.message?t.message:`Network Error`,A3.ERR_NETWORK,e,h);r.event=t||null,n(r),h=null},h.ontimeout=function(){let t=r.timeout?`timeout of `+r.timeout+`ms exceeded`:`timeout exceeded`,i=r.transitional||U3;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new A3(t,i.clarifyTimeoutError?A3.ETIMEDOUT:A3.ECONNABORTED,e,h)),h=null},i===void 0&&a.setContentType(null),`setRequestHeader`in h&&$.forEach(a.toJSON(),function(e,t){h.setRequestHeader(t,e)}),$.isUndefined(r.withCredentials)||(h.withCredentials=!!r.withCredentials),o&&o!==`json`&&(h.responseType=r.responseType),c&&([d,p]=S6(c,!0),h.addEventListener(`progress`,d)),s&&h.upload&&([u,f]=S6(s),h.upload.addEventListener(`progress`,u),h.upload.addEventListener(`loadend`,f)),(r.cancelToken||r.signal)&&(l=t=>{h&&=(n(!t||t.type?new _6(null,e,h):t),h.abort(),null)},r.cancelToken&&r.cancelToken.subscribe(l),r.signal&&(r.signal.aborted?l():r.signal.addEventListener(`abort`,l)));let _=y6(r.url);if(_&&Z3.protocols.indexOf(_)===-1){n(new A3(`Unsupported protocol `+_+`:`,A3.ERR_BAD_REQUEST,e));return}h.send(i||null)})},P6=(e,t)=>{let{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n=new AbortController,r,i=function(e){if(!r){r=!0,o();let t=e instanceof Error?e:this.reason;n.abort(t instanceof A3?t:new _6(t instanceof Error?t.message:t))}},a=t&&setTimeout(()=>{a=null,i(new A3(`timeout of ${t}ms exceeded`,A3.ETIMEDOUT))},t),o=()=>{e&&=(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener(`abort`,i)}),null)};e.forEach(e=>e.addEventListener(`abort`,i));let{signal:s}=n;return s.unsubscribe=()=>$.asap(o),s}},F6=function*(e,t){let n=e.byteLength;if(!t||n<t){yield e;return}let r=0,i;for(;r<n;)i=r+t,yield e.slice(r,i),r=i},I6=async function*(e,t){for await(let n of L6(e))yield*F6(n,t)},L6=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},R6=(e,t,n,r)=>{let i=I6(e,t),a=0,o,s=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{let{done:t,value:r}=await i.next();if(t){s(),e.close();return}let o=r.byteLength;n&&n(a+=o),e.enqueue(new Uint8Array(r))}catch(e){throw s(e),e}},cancel(e){return s(e),i.return()}},{highWaterMark:2})},z6=64*1024,{isFunction:B6}=$,V6=(({Request:e,Response:t})=>({Request:e,Response:t}))($.global),{ReadableStream:H6,TextEncoder:U6}=$.global,W6=(e,...t)=>{try{return!!e(...t)}catch{return!1}},G6=e=>{e=$.merge.call({skipUndefined:!0},V6,e);let{fetch:t,Request:n,Response:r}=e,i=t?B6(t):typeof fetch==`function`,a=B6(n),o=B6(r);if(!i)return!1;let s=i&&B6(H6),c=i&&(typeof U6==`function`?(e=>t=>e.encode(t))(new U6):async e=>new Uint8Array(await new n(e).arrayBuffer())),l=a&&s&&W6(()=>{let e=!1,t=new H6,r=new n(Z3.origin,{body:t,method:`POST`,get duplex(){return e=!0,`half`}}).headers.has(`Content-Type`);return t.cancel(),e&&!r}),u=o&&s&&W6(()=>$.isReadableStream(new r(``).body)),d={stream:u&&(e=>e.body)};i&&[`text`,`arrayBuffer`,`blob`,`formData`,`stream`].forEach(e=>{!d[e]&&(d[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new A3(`Response type '${e}' is not supported`,A3.ERR_NOT_SUPPORT,n)})});let f=async e=>{if(e==null)return 0;if($.isBlob(e))return e.size;if($.isSpecCompliantForm(e))return(await new n(Z3.origin,{method:`POST`,body:e}).arrayBuffer()).byteLength;if($.isArrayBufferView(e)||$.isArrayBuffer(e))return e.byteLength;if($.isURLSearchParams(e)&&(e+=``),$.isString(e))return(await c(e)).byteLength},p=async(e,t)=>$.toFiniteNumber(e.getContentLength())??f(t);return async e=>{let{url:i,method:o,data:s,signal:c,cancelToken:f,timeout:m,onDownloadProgress:h,onUploadProgress:g,responseType:_,headers:v,withCredentials:y=`same-origin`,fetchOptions:b}=M6(e),x=t||fetch;_=_?(_+``).toLowerCase():`text`;let S=P6([c,f&&f.toAbortSignal()],m),C=null,w=S&&S.unsubscribe&&(()=>{S.unsubscribe()}),T;try{if(g&&l&&o!==`get`&&o!==`head`&&(T=await p(v,s))!==0){let e=new n(i,{method:`POST`,body:s,duplex:`half`}),t;if($.isFormData(s)&&(t=e.headers.get(`content-type`))&&v.setContentType(t),e.body){let[t,n]=C6(T,S6(w6(g)));s=R6(e.body,z6,t,n)}}$.isString(y)||(y=y?`include`:`omit`);let t=a&&`credentials`in n.prototype,c={...b,signal:S,method:o.toUpperCase(),headers:v.normalize().toJSON(),body:s,duplex:`half`,credentials:t?y:void 0};C=a&&new n(i,c);let f=await(a?x(C,b):x(i,c)),m=u&&(_===`stream`||_===`response`);if(u&&(h||m&&w)){let e={};[`status`,`statusText`,`headers`].forEach(t=>{e[t]=f[t]});let t=$.toFiniteNumber(f.headers.get(`content-length`)),[n,i]=h&&C6(t,S6(w6(h),!0))||[];f=new r(R6(f.body,z6,n,()=>{i&&i(),w&&w()}),e)}_||=`text`;let E=await d[$.findKey(d,_)||`text`](f,e);return!m&&w&&w(),await new Promise((t,n)=>{v6(t,n,{data:E,headers:m6.from(f.headers),status:f.status,statusText:f.statusText,config:e,request:C})})}catch(t){throw w&&w(),t&&t.name===`TypeError`&&/Load failed|fetch/i.test(t.message)?Object.assign(new A3(`Network Error`,A3.ERR_NETWORK,e,C,t&&t.response),{cause:t.cause||t}):A3.from(t,t&&t.code,e,C,t&&t.response)}}},K6=new Map,q6=e=>{let t=e&&e.env||{},{fetch:n,Request:r,Response:i}=t,a=[r,i,n],o=a.length,s,c,l=K6;for(;o--;)s=a[o],c=l.get(s),c===void 0&&l.set(s,c=o?new Map:G6(t)),l=c;return c};q6();var J6={http:null,xhr:N6,fetch:{get:q6}};$.forEach(J6,(e,t)=>{if(e){try{Object.defineProperty(e,`name`,{value:t})}catch{}Object.defineProperty(e,`adapterName`,{value:t})}});var Y6=e=>`- ${e}`,X6=e=>$.isFunction(e)||e===null||e===!1;function Z6(e,t){e=$.isArray(e)?e:[e];let{length:n}=e,r,i,a={};for(let o=0;o<n;o++){r=e[o];let n;if(i=r,!X6(r)&&(i=J6[(n=String(r)).toLowerCase()],i===void 0))throw new A3(`Unknown adapter '${n}'`);if(i&&($.isFunction(i)||(i=i.get(t))))break;a[n||`#`+o]=i}if(!i){let e=Object.entries(a).map(([e,t])=>`adapter ${e} `+(t===!1?`is not supported by the environment`:`is not available in the build`));throw new A3(`There is no suitable adapter to dispatch the request `+(n?e.length>1?`since :
|
|
3819
3819
|
`+e.map(Y6).join(`
|
|
3820
3820
|
`):` `+Y6(e[0]):`as no adapter specified`),`ERR_NOT_SUPPORT`)}return i}var Q6={getAdapter:Z6,adapters:J6};function $6(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new _6(null,e)}function e8(e){return $6(e),e.headers=m6.from(e.headers),e.data=h6.call(e,e.transformRequest),[`post`,`put`,`patch`].indexOf(e.method)!==-1&&e.headers.setContentType(`application/x-www-form-urlencoded`,!1),Q6.getAdapter(e.adapter||r6.adapter,e)(e).then(function(t){return $6(e),t.data=h6.call(e,e.transformResponse,t),t.headers=m6.from(t.headers),t},function(t){return g6(t)||($6(e),t&&t.response&&(t.response.data=h6.call(e,e.transformResponse,t.response),t.response.headers=m6.from(t.response.headers))),Promise.reject(t)})}var t8=`1.14.0`,n8={};[`object`,`boolean`,`number`,`function`,`string`,`symbol`].forEach((e,t)=>{n8[e]=function(n){return typeof n===e||`a`+(t<1?`n `:` `)+e}});var r8={};n8.transitional=function(e,t,n){function r(e,t){return`[Axios v`+t8+`] Transitional option '`+e+`'`+t+(n?`. `+n:``)}return(n,i,a)=>{if(e===!1)throw new A3(r(i,` has been removed`+(t?` in `+t:``)),A3.ERR_DEPRECATED);return t&&!r8[i]&&(r8[i]=!0,console.warn(r(i,` has been deprecated since v`+t+` and will be removed in the near future`))),e?e(n,i,a):!0}},n8.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function i8(e,t,n){if(typeof e!=`object`)throw new A3(`options must be an object`,A3.ERR_BAD_OPTION_VALUE);let r=Object.keys(e),i=r.length;for(;i-- >0;){let a=r[i],o=t[a];if(o){let t=e[a],n=t===void 0||o(t,a,e);if(n!==!0)throw new A3(`option `+a+` must be `+n,A3.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new A3(`Unknown option `+a,A3.ERR_BAD_OPTION)}}var a8={assertOptions:i8,validators:n8},o8=a8.validators,s8=class{constructor(e){this.defaults=e||{},this.interceptors={request:new H3,response:new H3}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=Error();let n=t.stack?t.stack.replace(/^.+\n/,``):``;try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,``))&&(e.stack+=`
|
|
3821
|
-
`+n):e.stack=n}catch{}}throw e}}_request(e,t){typeof e==`string`?(t||={},t.url=e):t=e||{},t=j6(this.defaults,t);let{transitional:n,paramsSerializer:r,headers:i}=t;n!==void 0&&a8.assertOptions(n,{silentJSONParsing:o8.transitional(o8.boolean),forcedJSONParsing:o8.transitional(o8.boolean),clarifyTimeoutError:o8.transitional(o8.boolean),legacyInterceptorReqResOrdering:o8.transitional(o8.boolean)},!1),r!=null&&($.isFunction(r)?t.paramsSerializer={serialize:r}:a8.assertOptions(r,{encode:o8.function,serialize:o8.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls===void 0?t.allowAbsoluteUrls=!0:t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls),a8.assertOptions(t,{baseUrl:o8.spelling(`baseURL`),withXsrfToken:o8.spelling(`withXSRFToken`)},!0),t.method=(t.method||this.defaults.method||`get`).toLowerCase();let a=i&&$.merge(i.common,i[t.method]);i&&$.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`common`],e=>{delete i[e]}),t.headers=m6.concat(a,i);let o=[],s=!0;this.interceptors.request.forEach(function(e){if(typeof e.runWhen==`function`&&e.runWhen(t)===!1)return;s&&=e.synchronous;let n=t.transitional||U3;n&&n.legacyInterceptorReqResOrdering?o.unshift(e.fulfilled,e.rejected):o.push(e.fulfilled,e.rejected)});let c=[];this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,u=0,d;if(!s){let e=[e8.bind(this),void 0];for(e.unshift(...o),e.push(...c),d=e.length,l=Promise.resolve(t);u<d;)l=l.then(e[u++],e[u++]);return l}d=o.length;let f=t;for(;u<d;){let e=o[u++],t=o[u++];try{f=e(f)}catch(e){t.call(this,e);break}}try{l=e8.call(this,f)}catch(e){return Promise.reject(e)}for(u=0,d=c.length;u<d;)l=l.then(c[u++],c[u++]);return l}getUri(e){return e=j6(this.defaults,e),V3(k6(e.baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};$.forEach([`delete`,`get`,`head`,`options`],function(e){s8.prototype[e]=function(t,n){return this.request(j6(n||{},{method:e,url:t,data:(n||{}).data}))}}),$.forEach([`post`,`put`,`patch`],function(e){function t(t){return function(n,r,i){return this.request(j6(i||{},{method:e,headers:t?{"Content-Type":`multipart/form-data`}:{},url:n,data:r}))}}s8.prototype[e]=t(),s8.prototype[e+`Form`]=t(!0)});var c8=class e{constructor(e){if(typeof e!=`function`)throw TypeError(`executor must be a function.`);let t;this.promise=new Promise(function(e){t=e});let n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t,r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new _6(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}};function l8(e){return function(t){return e.apply(null,t)}}function u8(e){return $.isObject(e)&&e.isAxiosError===!0}var d8={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(d8).forEach(([e,t])=>{d8[t]=e});function f8(e){let t=new s8(e),n=y4(s8.prototype.request,t);return $.extend(n,s8.prototype,t,{allOwnKeys:!0}),$.extend(n,t,null,{allOwnKeys:!0}),n.create=function(t){return f8(j6(e,t))},n}var p8=f8(r6);p8.Axios=s8,p8.CanceledError=_6,p8.CancelToken=c8,p8.isCancel=g6,p8.VERSION=t8,p8.toFormData=I3,p8.AxiosError=A3,p8.Cancel=p8.CanceledError,p8.all=function(e){return Promise.all(e)},p8.spread=l8,p8.isAxiosError=u8,p8.mergeConfig=j6,p8.AxiosHeaders=m6,p8.formToJSON=e=>t6($.isHTMLForm(e)?new FormData(e):e),p8.getAdapter=Q6.getAdapter,p8.HttpStatusCode=d8,p8.default=p8;var m8=`https://eines.icgc.cat/recursos/mapicgc-gl-js/mapicgc-config.json`,h8=5e3,g8=class{static async getConfigICGC(){try{let e=await p8.get(m8,{timeout:h8});return e.data?e.data:(console.log(`Resposta sense dades:`,e),m4)}catch(e){return e.response?(console.error(`Error de resposta:`,e.response.data),console.error(`Codi d'estat:`,e.response.status)):e.request?console.error(`No s'ha rebut resposta del servidor:`,e.request):console.error(`Error:`,e.message),m4}}},_8={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`]}},v8=`lines`,y8=`labels`,b8,x8,S8,C8,w8,T8=class{constructor(e){g8.getConfigICGC().then(t=>{x8={...t.Styles},C8={...t.Layers},S8={...t.Terrains},w8={...t.defaultOptions},this.initTheMap(e)}).catch(t=>{console.info(`Configuracio per defecte`,t),x8={...m4.Styles},C8={...m4.Layers},S8={...m4.Terrains},w8={...m4.defaultOptions},this.initTheMap(e)})}initTheMap(e){if(!e)e=w8.mapOptions;else for(let t in w8.mapOptions){let n=[w8.mapOptions.center[0],w8.mapOptions.center[1]];w8.mapOptions.center=n,e.hasOwnProperty(t)||(e[t]=w8.mapOptions[t])}e.maxPitch=85,e.maplibreLogo=!1,e.attributionControl=!1;let t=e.style===`RELIEF`||typeof e.style==`object`&&e.style.hasOwnProperty(`colorRelief`),n=typeof e.style==`string`&&e.style.includes(`https://geoserveis.icgc.cat/servei/catalunya/mapa-base/wmts/`);if(t){let t=typeof e.style==`object`?e.style:{},n=t.source||{type:`raster-dem`,tiles:[S8.ICGC5M],tileSize:512,maxzoom:20},r=t.colorRelief||[`interpolate`,[`linear`],[`elevation`],-50,`rgb(30, 70, 130)`,0,`rgb(120, 180, 210)`,5,`rgb(170, 220, 170)`,100,`rgb(180, 210, 140)`,300,`rgb(220, 220, 130)`,500,`rgb(245, 220, 110)`,800,`rgb(250, 200, 100)`,1100,`rgb(245, 170, 90)`,1400,`rgb(230, 140, 80)`,1700,`rgb(210, 130, 90)`,2e3,`rgb(190, 130, 110)`,2400,`rgb(180, 150, 130)`,2800,`rgb(200, 190, 180)`,3200,`rgb(235, 235, 235)`,3600,`rgb(255, 255, 255)`];this.map=new f.default.Map({container:e.container,center:e.center,zoom:e.zoom,pitch:e.pitch||0,bearing:e.bearing||0,hash:e.hash||!1,maxZoom:e.maxZoom||18,maxPitch:e.maxPitch||85,renderWorldCopies:!1,style:{version:8,sources:{terrainSource:n},layers:[{id:`color-relief`,type:`color-relief`,source:`terrainSource`,paint:{"color-relief-color":r}}]}})}else n?(this.map=new f.default.Map({container:e.container,center:e.center,zoom:e.zoom,pitch:e.pitch||0,hash:e.hash||!1,style:{version:8,sources:{},layers:[]}}),this.map.on(`load`,()=>{this.map.addSource(`raster-source`,{type:`raster`,tiles:[e.style],tileSize:256}),this.map.addLayer({id:`raster-layer`,type:`raster`,source:`raster-source`})})):this.map=new f.default.Map(e);this.map.on(`load`,()=>{if(this.addAttributionControl(),!n&&!t){let t=this.map.getStyle().name,n=e.style;this.map.addControl(new h4({color:n.indexOf(`orto`)===-1,defaultOptions:w8}),`bottom-left`),this._dealOrto3dStyle(t)}})}addGeocoderICGC(e={},t=`top-right`){try{e={collapsed:!0,marker:!0,zoom:16,popup:!0,showResultMarkers:!0,maplibregl:f.default,showResultsWhileTyping:!0,minLength:2,...e},this.map.addControl(new p4({forwardGeocode:async e=>{let t=[];try{let n=w8.geocoder.peliasUrl1+encodeURIComponent(e.query)+w8.geocoder.peliasUrl2,r=await(await fetch(n)).json();for(let e of r.features){let n=e.geometry.coordinates,r={type:`Feature`,geometry:{type:`Point`,coordinates:n},place_name:e.properties.etiqueta,properties:e.properties,text:e.properties.etiqueta,place_type:[`place`],center:n};t.push(r)}}catch(e){console.error(`Failed to forwardGeocode with error: ${e}`)}return{features:t}}},e),t);let n=document.getElementsByClassName(`maplibregl-ctrl-geocoder--input`);n[0].attributes[2].nodeValue=`Cerca...`,n[0].addEventListener(`input`,function(e){e.target.value.length})}catch(e){console.error(`Error adding ICGC geocoder: ${e.message}`)}}async loadImage(e){try{return this.map.loadImage(e)}catch(e){console.error(`Error getting loadImage: ${e.message}`)}}getConfigStyles(){try{let e=[];for(let t of x8)e.push(t.name);return e}catch(e){console.error(`Error retrieving base styles: ${e.message}`)}}getConfigWMSLayers(){try{let e=[];for(let t in C8.WMS)C8.WMS.hasOwnProperty(t)&&e.push(t);return e}catch(e){console.error(`Error retrieving WMS layers: ${e.message}`)}}getConfigOrtoLayers(){try{let e=[];for(let t in C8.Orto)C8.Orto.hasOwnProperty(t)&&e.push(t);return e}catch(e){console.error(`Error retrieving orto image layers: ${e.message}`)}}getConfigVectorLayers(){try{let e=[];for(let t in C8.Vector)C8.Vector.hasOwnProperty(t)&&e.push(t);return e}catch(e){console.error(`Error retrieving vector layers: ${e.message}`)}}getConfigVectorAdminLayers(){try{let e=[];for(let t in C8.VectorAdmin)C8.VectorAdmin.hasOwnProperty(t)&&e.push(t);return e}catch(e){console.error(`Error retrieving vectorAdmin layers: ${e.message}`)}}getConfigFGBAdminLayers(){try{let e=[];for(let t in C8.FGBAdmin)C8.FGBAdmin.hasOwnProperty(t)&&e.push(t);return e}catch(e){console.error(`Error retrieving FGBAdmin layers: ${e.message}`)}}async fetchData(e,t,n){try{(!n||n===void 0)&&(n={type:`line`,layout:{visibility:`visible`},paint:{"line-color":`grey`,"line-width":2},layerPosition:`top`});let r=n.layerPosition;if(e.includes(`.fgb`))this.addFGBLayerICGC(e,t,n);else{let i=await(await fetch(e)).json(),a=t,o=this._dealOrderLayer(r),s=i.features[0].geometry.type;s.includes(`ine`)&&(n===void 0?this.map.addLayer({id:a,type:`line`,source:{type:`geojson`,data:i},layout:{visibility:`visible`},paint:{"line-color":`black`,"line-width":2,"line-opacity":1}},o):this.map.addLayer({id:a,type:`line`,source:{type:`geojson`,data:i},layout:n.layout||{},paint:n.paint||{}},o)),s.includes(`olygon`)&&(n===void 0?this.map.addLayer({id:a,type:`fill`,source:{type:`geojson`,data:i},layout:{visibility:`visible`},paint:{"fill-color":`blue`,"fill-opacity":.6}},o):this.map.addLayer({id:a,type:`fill`,source:{type:`geojson`,data:i},layout:n.layout,paint:n.paint},o)),s.includes(`oint`)&&(n===void 0?this.map.addLayer({id:a,type:`circle`,source:{type:`geojson`,data:i},layout:{visibility:`visible`},paint:{"circle-color":`red`,"circle-opacity":.85}},o):this.map.addLayer({id:a,type:`circle`,source:{type:`geojson`,data:i},layout:n.layout,paint:n.paint},o))}}catch(e){console.error(`Error fetching data: ${e.message}`)}}async fetchDataAndMenu(e,t,n,r){try{let i;i=r===null?y8:r.layerPosition;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 o=`visible`,s=this._dealOrderLayer(i),c;if(e.includes(`.fgb`)){let n=this._getKeyByUrlFGB(e);n===null&&(n=`userFGB`);let i=await fetch(e),a={type:`FeatureCollection`,features:[]};for await(let e of qe(i.body))a.features.push(e);c=a;let l=t;if(this.map.addSource(l,{type:`geojson`,data:a}),e.includes(`text`))r===void 0?this.map.addLayer({id:t,type:`symbol`,source:l,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:o,"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)`}},s):this.map.addLayer({id:t,type:`symbol`,source:l,layout:r.layout,paint:r.paint},s);else{let e=t+`Text`;this.map.addLayer({id:e,type:`symbol`,source:l,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:o,"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)`}},s)}}else c=await(await fetch(e)).json();if(n!==`all`){let e=document.createElement(`div`);e.id=`titleDivMenu`,e.textContent=t,a.appendChild(e);let r=document.createElement(`div`);r.id=`titleDivMenuSub`,r.textContent=`📂 ${n}`,a.appendChild(r)}let l;if(l=r.type?r.type:c.features[0].geometry.type,n===`all`)l.includes(`ine`)&&(r===void 0?this.map.addLayer({id:t,type:`line`,source:{type:`geojson`,data:c},layout:{visibility:`visible`},paint:{"line-color":`black`,"line-width":2,"line-opacity":1}},s):this.map.addLayer({id:t,type:`line`,source:{type:`geojson`,data:c},layout:r.layout,paint:r.paint},s)),l.includes(`olygon`)&&(r===void 0?this.map.addLayer({id:t,type:`fill`,source:{type:`geojson`,data:c},layout:{visibility:`visible`},paint:{"fill-color":`#0000FF`,"fill-opacity":0}},s):this.map.addLayer({id:t,type:`fill`,source:{type:`geojson`,data:c},layout:r.layout,paint:r.paint},s)),l.includes(`oint`)&&(r===void 0?this.map.addLayer({id:t,type:`circle`,source:{type:`geojson`,data:c},layout:{visibility:`visible`},paint:{"circle-color":`red`,"circle-opacity":.85}},s):this.map.addLayer({id:t,type:`circle`,source:{type:`geojson`,data:c},layout:r.layout,paint:r.paint},s)),l.includes(`ymbol`)&&(r===void 0?this.map.addLayer({id:t,type:`symbol`,source:{type:`geojson`,data:c},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)`}},s):this.map.addLayer({id:t,type:`symbol`,source:{type:`geojson`,data:c},layout:r.layout,paint:r.paint},s)),this.addMenuItem(t);else{let e=n,i={};c.features.forEach(n=>{let a=n.properties[e],o=a+`-userFieldFilter-`+t;a!==null&&(i[o]||(l.includes(`ine`)&&(r===void 0?this.map.addLayer({id:o,type:`line`,source:{type:`geojson`,data:c},layout:{visibility:`visible`},filter:[`==`,`${e}`,a],paint:{"line-color":`black`,"line-width":2,"line-opacity":1}},s):this.map.addLayer({id:o,type:`line`,source:{type:`geojson`,data:c},layout:r.layout,paint:r.paint,filter:[`==`,`${e}`,a]},s)),l.includes(`olygon`)&&(r===void 0?this.map.addLayer({id:o,type:`fill`,source:{type:`geojson`,data:c},layout:{visibility:`visible`},filter:[`==`,`${e}`,a],paint:{"fill-color":`blue`,"fill-opacity":.6}},s):this.map.addLayer({id:o,type:`fill`,source:{type:`geojson`,data:c},filter:[`==`,`${e}`,a],layout:r.layout,paint:r.paint},s)),l.includes(`oint`)&&(r===void 0?this.map.addLayer({id:o,type:`circle`,source:{type:`geojson`,data:c},layout:{visibility:`visible`},filter:[`==`,`${e}`,a],paint:{"circle-color":`red`,"circle-opacity":.85}},s):this.map.addLayer({id:o,type:`circle`,source:{type:`geojson`,data:c},filter:[`==`,`${e}`,a],layout:r.layout,paint:r.paint},s)),i[o]=!0,this.addMenuItem(o)))})}}}catch(e){console.error(`Error fetching data: ${e.message}`)}}on(e,t){setTimeout(()=>{try{return this.map.on(e,t)}catch(e){console.error(`Error adding event ON listener: ${e.message}`)}},100)}setStyle(e,t){try{t===void 0?this.map.setStyle(e):this.map.setStyle(e,t),this.map.on(`styledata`,()=>{window.document.querySelector(`.maplibregl-compact-show`)&&window.document.querySelector(`.maplibregl-compact-show`).classList.remove(`maplibregl-compact-show`),this._dealOrto3dStyle(this.map.getStyle().name)})}catch(e){console.error(`Error setting style: ${e.message}`)}}addControl(e,t){try{t===void 0&&(t=`top-right`),this.map.addControl(e,t)}catch(e){console.error(`Error adding control: ${e.message}`)}}setSky(e){try{e===void 0&&(e=this.map.style.stylesheet.id.includes(`orto`)?{"sky-color":`#86bbd5`,"sky-horizon-blend":.3,"horizon-color":`#ffffff33`,"horizon-fog-blend":.1,"fog-ground-blend":.75,"fog-color":`#c5d6d6`}:this.map.style.stylesheet.id.includes(`mapa_estandard_general`)||this.map.style.stylesheet.id.includes(`icgc_mapa_vissir`)?{"sky-color":`#a5f0f0`,"sky-horizon-blend":.3,"horizon-color":`#e1e3e3`,"horizon-fog-blend":.9,"fog-ground-blend":.85,"fog-color":`#c5d6d6`}:this.map.style.stylesheet.id.includes(`fosc`)?{"sky-color":`#232423`,"sky-horizon-blend":.3,"horizon-color":`#969996`,"horizon-fog-blend":.9,"fog-ground-blend":.85,"fog-color":`#383838`}:{"sky-color":`#86bbd5`,"sky-horizon-blend":.3,"horizon-color":`#ffffff33`,"horizon-fog-blend":.1,"fog-ground-blend":.75,"fog-color":`#c5d6d6`}),this.map.setSky(e)}catch(e){console.error(`Error setting sky properties: ${e.message}`)}}addMouseCoordControl(e,t=`bottom-left`){try{this.map.addControl(new v4(e),t)}catch(e){console.error(`Error adding mouse coordinate control: ${e.message}`)}}addGeolocateControl(e,t){try{t===void 0&&(t=`top-right`),e===void 0?this.map.addControl(new f.default.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!0}),t):this.map.addControl(new f.default.GeolocateControl(e),t)}catch(e){console.error(`Error adding geolocate control: ${e.message}`)}}addFullscreenControl(e,t){try{t===void 0&&(t=`top-right`),e===void 0?this.map.addControl(new f.default.FullscreenControl({container:HTMLElement}),t):this.map.addControl(new f.default.FullscreenControl(e),t)}catch(e){console.error(`Error adding fullscreen control: ${e.message}`)}}addLayer(e,t){try{this.map.addLayer(e,t)}catch(e){console.error(`Error adding layer: ${e.message}`)}}addImage(e,t,n){try{this.map.addImage(e,t,n)}catch(e){console.error(`Error adding image: ${e.message}`)}return this}addSource(e,t){try{this.map.addSource(e,t)}catch(e){console.error(`Error adding source: ${e.message}`)}return this}addSprite(e,t,n){try{this.map.addSprite(e,t,n)}catch(e){console.error(`Error adding sprite: ${e.message}`)}return this}areTilesLoaded(){return this.map.areTilesLoaded()}cameraForBounds(e,t){return this.map.cameraForBounds(e,t)}easeTo(e,t){return this.map.easeTo(e,t),this}fitBounds(e,t,n){return this.map.fitBounds(e,t,n),this}fitScreenCoordinates(e,t,n,r,i){return this.map.fitScreenCoordinates(e,t,n,r,i),this}flyTo(e,t){return this.map.flyTo(e,t),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(e){return this.map.getFeatureState(e)}getFilter(e){return this.map.getFilter(e)}getGlyphs(){return this.map.getGlyphs()}getImage(e){return this.map.getImage(e)}getLayer(e){return this.map.getLayer(e)}getLayersOrder(){return this.map.getLayersOrder()}getLayoutProperty(e,t){return this.map.getLayoutProperty(e,t)}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(e,t){return this.map.getPaintProperty(e,t)}getPitch(){return this.map.getPitch()}getPixelRatio(){return this.map.getPixelRatio()}getRenderWorldCopies(){return this.map.getRenderWorldCopies()}getSource(e){return this.map.getSource(e)}getSprite(){return this.map.getSprite()}getStyle(){return this.map.getStyle()}getTerrain(){return this.map.getTerrain()}getZoom(){return this.map.getZoom()}hasControl(e){return this.map.hasControl(e)}hasImage(e){return this.map.hasImage(e)}isMoving(){return this.map.isMoving()}isRotating(){return this.map.isRotating()}isSourceLoaded(e){return this.map.isSourceLoaded(e)}isStyleLoaded(){return this.map.isStyleLoaded()}isZooming(){return this.map.isZooming()}jumpTo(e,t){return this.map.jumpTo(e,t)}listImages(){return this.map.listImages()}listens(e){return this.map.listens(e)}loadImage(e){return this.map.loadImage(e)}loaded(){return this.map.loaded()}LngLatBounds(e,t){return new f.default.LngLatBounds(e,t)}addProtocol(e,t){return this.map.addProtocol(e,t)}moveLayer(e,t){return this.map.moveLayer(e,t)}panBy(e,t,n){return this.map.panBy(e,t,n)}panTo(e,t,n){return this.map.panTo(e,t,n)}project(e){return this.map.project(e)}queryRenderedFeatures(e,t){return this.map.queryRenderedFeatures(e,t)}querySourceFeatures(e,t){return this.map.querySourceFeatures(e,t)}queryTerrainElevation(e){return this.map.queryTerrainElevation(e)}redraw(){return this.map.redraw()}remove(){return this.map.remove()}removeControl(e){return this.map.removeControl(e)}removeFeatureState(e,t){return this.map.removeFeatureState(e,t)}removeImage(e){return this.map.removeImage(e)}removeLayer(e){try{this.map.removeLayer(e)}catch(e){console.error(`Error removing layer: ${e.message}`)}}removeSource(e){try{this.map.removeSource(e)}catch(e){console.error(`Error removing source: ${e.message}`)}}removeSprite(e){return this.map.removeSprite(e)}resetNorth(e,t){return this.map.resetNorth(e,t)}resetNorthPitch(e,t){return this.map.resetNorthPitch(e,t)}resize(e){return this.map.resize(e)}rotateTo(e,t,n){return this.map.rotateTo(e,t,n)}setBearing(e,t){return this.map.setBearing(e,t)}setCenter(e,t){return this.map.setCenter(e,t)}setEventedParent(e,t){return this.map.setEventedParent(e,t)}setFeatureState(e,t){return this.map.setFeatureState(e,t)}setFilter(e,t,n){return this.map.setFilter(e,t,n)}setGlyphs(e,t){return this.map.setGlyphs(e,t)}setLayerZoomRange(e,t,n){return this.map.setLayerZoomRange(e,t,n)}setLayoutProperty(e,t,n,r){return this.map.setLayoutProperty(e,t,n,r)}setLight(e,t){return this.map.setLight(e,t)}setMaxBounds(e){return this.map.setMaxBounds(e)}setMaxPitch(e){return this.map.setMaxPitch(e)}setMaxZoom(e){return this.map.setMaxZoom(e)}setMinPitch(e){return this.map.setMinPitch(e)}setMinZoom(e){return this.map.setMinZoom(e)}setPadding(e,t){return this.map.setPadding(e,t)}setPaintProperty(e,t,n,r){return this.map.setPaintProperty(e,t,n,r)}setPitch(e,t){return this.map.setPitch(e,t)}setPixelRatio(e){return this.map.setPixelRatio(e)}setRenderWorldCopies(e){return this.map.setRenderWorldCopies(e)}setSprite(e,t){return this.map.setSprite(e,t)}setTerrain(e){return this.map.setTerrain(e)}setTransformRequest(e){return this.map.setTransformRequest(e)}setZoom(e,t){return this.map.setZoom(e,t)}snapToNorth(e,t){return this.map.snapToNorth(e,t)}stop(){return this.map.stop()}triggerRepaint(){return this.map.triggerRepaint()}unproject(e){return this.map.unproject(e)}updateImage(e,t){return this.map.updateImage(e,t)}zoomIn(e,t){return this.map.zoomIn(e,t)}zoomOut(e,t){return this.map.zoomOut(e,t)}zoomTo(e,t,n){return this.map.zoomTo(e,t,n)}addLayerGeoJSON(e,t){try{let n=this._dealOrderLayer(t);this.map.addSource(`${e.id}`,{type:`geojson`,data:e.data}),this.map.addLayer({id:`${e.id}-layerIcgcMap`,type:e.type,source:`${e.id}`,layout:e.layout,paint:e.paint},n)}catch(e){console.error(`Error adding GeoJSON layer: ${e.message}`)}}addLayerWMS(e,t,n){try{let r=this._dealOrderLayer(n.layerPosition);n?(this.map.addSource(`${t}`,{type:`raster`,tiles:[e],tileSize:256},r),this.map.addLayer({id:t,type:`raster`,source:t,layout:n.layout,paint:n.paint},r)):(this.map.addSource(`${t}`,{type:`raster`,tiles:[e],tileSize:256},r),this.map.addLayer({id:t,type:`raster`,source:t,paint:{}},r))}catch(e){console.error(`Error adding WMS layer: ${e.message}`)}}addLogo(e){try{let t=document.getElementById(`map`),n;n=document.createElement(`div`),n.id=`logos`,t.appendChild(n);let r=document.createElement(`img`);r.src=e.url,r.style.height=e.height;let i=document.getElementById(`logos`),a=document.createElement(`a`);a.id=e.id,a.href=e.href,a.target=`_blank`,a.style.position=`relative`,a.style.bottom=`1px`,a.appendChild(r),i.appendChild(a)}catch(e){console.error(`Error adding logo: ${e.message}`)}}addBasemapsICGC(e){try{let t=e=>{this.map.setStyle(e)},n=document.getElementById(`map`),r;r=document.createElement(`div`),r.id=`basemap-group`,r.classList.add=`filter-group`,n.appendChild(r);let i=document.getElementById(`basemap-group`);for(let n of e)for(let e of Object.keys(w8.baseStyles)){let r=w8.baseStyles[e];if(n===r.url){let e=document.createElement(`div`);e.className=`basemap-item`,e.title=r.key,e.style.backgroundImage=`url('${r.image}')`,i.appendChild(e),e.addEventListener(`click`,()=>t(r.url))}}}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addBasemaps(e){try{let t=e=>{map.setStyle(e.url)},n=document.getElementById(`map`),r;r=document.createElement(`div`),r.id=`basemap-group`,r.classList.add=`basemap-group`,n.appendChild(r);let i=document.getElementById(`basemap-group`);e.forEach(e=>{let n=document.createElement(`div`);n.className=`basemap-item`,n.title=e.label,n.style.backgroundImage=`url('${e.image}')`,i.appendChild(n),n.addEventListener(`click`,()=>t(e))})}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addFeatureQuery(e,t,n){try{let r;this.map.on(`mouseenter`,e,()=>{this.map.getCanvas().style.cursor=`pointer`}),this.map.on(`mouseleave`,e,()=>{this.map.getCanvas().style.cursor=``}),this.map.on(`click`,i=>{let a=this.map.queryRenderedFeatures(i.point);if(a&&a[0].source.includes(e)){let e=[i.lngLat.lng,i.lngLat.lat];if(t!==void 0&&t.length>0&&t!==`all`){if(t!==null){let i=``;t.forEach(e=>{let t=a[0].properties[e];i+=`<h4>${t}</h4>`}),r=i,this.addPopup(e,r,n)}}else{let t=``;for(let e in a[0].properties)t+=`<b>`+e+`</b>:`+a[0].properties[e]+`<br>`;r=t,this.addPopup(e,r,n)}}})}catch(e){console.error(`Error adding feature query: ${e.message}`)}}addScaleControl(e,t){try{var n=new f.default.ScaleControl(e);this.map.addControl(n,t)}catch(e){console.error(`Error adding scale: ${e.message}`)}}addExportControl(e,t){try{typeof e==`string`&&(t=e,e=void 0),e===void 0&&(e={PageSize:oq.A4,PageOrientation:aq.Landscape,Format:iq.PNG,DPI:rq[300],Crosshair:!0,PrintableArea:!0,Local:`ca`},t=`top-right`),this.map.addControl(new A2(e),t)}catch(e){console.error(`Error adding export control: ${e.message}`)}}addMarker(e){try{let t,n;return e.text===void 0?t=new f.default.Marker(e.options).setLngLat(e.coord).addTo(this.map):(n=new f.default.Popup({offset:e.textOffset}).setHTML(e.text),t=new f.default.Marker(e.options).setLngLat(e.coord).setPopup(n).addTo(this.map)),t}catch(e){return console.error(`Error adding marker: ${e.message}`),null}}addPopup(e,t,n){try{return n.image===void 0?new f.default.Popup().setLngLat(e).setHTML(`
|
|
3821
|
+
`+n):e.stack=n}catch{}}throw e}}_request(e,t){typeof e==`string`?(t||={},t.url=e):t=e||{},t=j6(this.defaults,t);let{transitional:n,paramsSerializer:r,headers:i}=t;n!==void 0&&a8.assertOptions(n,{silentJSONParsing:o8.transitional(o8.boolean),forcedJSONParsing:o8.transitional(o8.boolean),clarifyTimeoutError:o8.transitional(o8.boolean),legacyInterceptorReqResOrdering:o8.transitional(o8.boolean)},!1),r!=null&&($.isFunction(r)?t.paramsSerializer={serialize:r}:a8.assertOptions(r,{encode:o8.function,serialize:o8.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls===void 0?t.allowAbsoluteUrls=!0:t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls),a8.assertOptions(t,{baseUrl:o8.spelling(`baseURL`),withXsrfToken:o8.spelling(`withXSRFToken`)},!0),t.method=(t.method||this.defaults.method||`get`).toLowerCase();let a=i&&$.merge(i.common,i[t.method]);i&&$.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`common`],e=>{delete i[e]}),t.headers=m6.concat(a,i);let o=[],s=!0;this.interceptors.request.forEach(function(e){if(typeof e.runWhen==`function`&&e.runWhen(t)===!1)return;s&&=e.synchronous;let n=t.transitional||U3;n&&n.legacyInterceptorReqResOrdering?o.unshift(e.fulfilled,e.rejected):o.push(e.fulfilled,e.rejected)});let c=[];this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,u=0,d;if(!s){let e=[e8.bind(this),void 0];for(e.unshift(...o),e.push(...c),d=e.length,l=Promise.resolve(t);u<d;)l=l.then(e[u++],e[u++]);return l}d=o.length;let f=t;for(;u<d;){let e=o[u++],t=o[u++];try{f=e(f)}catch(e){t.call(this,e);break}}try{l=e8.call(this,f)}catch(e){return Promise.reject(e)}for(u=0,d=c.length;u<d;)l=l.then(c[u++],c[u++]);return l}getUri(e){return e=j6(this.defaults,e),V3(k6(e.baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};$.forEach([`delete`,`get`,`head`,`options`],function(e){s8.prototype[e]=function(t,n){return this.request(j6(n||{},{method:e,url:t,data:(n||{}).data}))}}),$.forEach([`post`,`put`,`patch`],function(e){function t(t){return function(n,r,i){return this.request(j6(i||{},{method:e,headers:t?{"Content-Type":`multipart/form-data`}:{},url:n,data:r}))}}s8.prototype[e]=t(),s8.prototype[e+`Form`]=t(!0)});var c8=class e{constructor(e){if(typeof e!=`function`)throw TypeError(`executor must be a function.`);let t;this.promise=new Promise(function(e){t=e});let n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t,r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new _6(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}};function l8(e){return function(t){return e.apply(null,t)}}function u8(e){return $.isObject(e)&&e.isAxiosError===!0}var d8={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(d8).forEach(([e,t])=>{d8[t]=e});function f8(e){let t=new s8(e),n=y4(s8.prototype.request,t);return $.extend(n,s8.prototype,t,{allOwnKeys:!0}),$.extend(n,t,null,{allOwnKeys:!0}),n.create=function(t){return f8(j6(e,t))},n}var p8=f8(r6);p8.Axios=s8,p8.CanceledError=_6,p8.CancelToken=c8,p8.isCancel=g6,p8.VERSION=t8,p8.toFormData=I3,p8.AxiosError=A3,p8.Cancel=p8.CanceledError,p8.all=function(e){return Promise.all(e)},p8.spread=l8,p8.isAxiosError=u8,p8.mergeConfig=j6,p8.AxiosHeaders=m6,p8.formToJSON=e=>t6($.isHTMLForm(e)?new FormData(e):e),p8.getAdapter=Q6.getAdapter,p8.HttpStatusCode=d8,p8.default=p8;var m8=`https://eines.icgc.cat/recursos/mapicgc-gl-js/mapicgc-config.json`,h8=5e3,g8=class{static async getConfigICGC(){try{let e=await p8.get(m8,{timeout:h8});return e.data?e.data:(console.log(`Resposta sense dades:`,e),m4)}catch(e){return e.response?(console.error(`Error de resposta:`,e.response.data),console.error(`Codi d'estat:`,e.response.status)):e.request?console.error(`No s'ha rebut resposta del servidor:`,e.request):console.error(`Error:`,e.message),m4}}},_8={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`]}},v8=`lines`,y8=`labels`,b8,x8,S8,C8,w8,T8=class{constructor(e){g8.getConfigICGC().then(t=>{x8={...t.Styles},C8={...t.Layers},S8={...t.Terrains},w8={...t.defaultOptions},this.initTheMap(e)}).catch(t=>{console.info(`Configuracio per defecte`,t),x8={...m4.Styles},C8={...m4.Layers},S8={...m4.Terrains},w8={...m4.defaultOptions},this.initTheMap(e)})}initTheMap(e){if(!e)e=w8.mapOptions;else for(let t in w8.mapOptions){let n=[w8.mapOptions.center[0],w8.mapOptions.center[1]];w8.mapOptions.center=n,e.hasOwnProperty(t)||(e[t]=w8.mapOptions[t])}e.maxPitch=85,e.maplibreLogo=!1,e.attributionControl=!1;let t=e.style===`RELIEF`||typeof e.style==`object`&&e.style.hasOwnProperty(`colorRelief`),n=typeof e.style==`string`&&e.style.includes(`https://geoserveis.icgc.cat/servei/catalunya/mapa-base/wmts/`);if(t){let t=typeof e.style==`object`?e.style:{},n=t.source||{type:`raster-dem`,tiles:[S8.ICGC5M],tileSize:512,maxzoom:20},r=t.colorRelief||[`interpolate`,[`linear`],[`elevation`],-50,`rgb(30, 70, 130)`,0,`rgb(120, 180, 210)`,5,`rgb(170, 220, 170)`,100,`rgb(180, 210, 140)`,300,`rgb(220, 220, 130)`,500,`rgb(245, 220, 110)`,800,`rgb(250, 200, 100)`,1100,`rgb(245, 170, 90)`,1400,`rgb(230, 140, 80)`,1700,`rgb(210, 130, 90)`,2e3,`rgb(190, 130, 110)`,2400,`rgb(180, 150, 130)`,2800,`rgb(200, 190, 180)`,3200,`rgb(235, 235, 235)`,3600,`rgb(255, 255, 255)`];this.map=new f.default.Map({container:e.container,center:e.center,zoom:e.zoom,pitch:e.pitch||0,bearing:e.bearing||0,hash:e.hash||!1,maxZoom:e.maxZoom||18,maxPitch:e.maxPitch||85,renderWorldCopies:!1,style:{version:8,sources:{terrainSource:n},layers:[{id:`color-relief`,type:`color-relief`,source:`terrainSource`,paint:{"color-relief-color":r}}]}})}else n?(this.map=new f.default.Map({container:e.container,center:e.center,zoom:e.zoom,pitch:e.pitch||0,hash:e.hash||!1,style:{version:8,sources:{},layers:[]}}),this.map.on(`load`,()=>{this.map.addSource(`raster-source`,{type:`raster`,tiles:[e.style],tileSize:256}),this.map.addLayer({id:`raster-layer`,type:`raster`,source:`raster-source`})})):this.map=new f.default.Map(e);this.map.on(`load`,()=>{if(this.addAttributionControl(),setTimeout(()=>{let e=document.querySelector(`.maplibregl-ctrl-attrib-button`);e&&e.click()},1e3),!n&&!t){let t=this.map.getStyle().name,n=e.style;this.map.addControl(new h4({color:n.indexOf(`orto`)===-1,defaultOptions:w8}),`bottom-left`),this._dealOrto3dStyle(t)}})}addGeocoderICGC(e={},t=`top-right`){try{e={collapsed:!0,marker:!0,zoom:16,popup:!0,showResultMarkers:!0,maplibregl:f.default,showResultsWhileTyping:!0,minLength:2,...e},this.map.addControl(new p4({forwardGeocode:async e=>{let t=[];try{let n=w8.geocoder.peliasUrl1+encodeURIComponent(e.query)+w8.geocoder.peliasUrl2,r=await(await fetch(n)).json();for(let e of r.features){let n=e.geometry.coordinates,r={type:`Feature`,geometry:{type:`Point`,coordinates:n},place_name:e.properties.etiqueta,properties:e.properties,text:e.properties.etiqueta,place_type:[`place`],center:n};t.push(r)}}catch(e){console.error(`Failed to forwardGeocode with error: ${e}`)}return{features:t}}},e),t);let n=document.getElementsByClassName(`maplibregl-ctrl-geocoder--input`);n[0].attributes[2].nodeValue=`Cerca...`,n[0].addEventListener(`input`,function(e){e.target.value.length})}catch(e){console.error(`Error adding ICGC geocoder: ${e.message}`)}}async loadImage(e){try{return this.map.loadImage(e)}catch(e){console.error(`Error getting loadImage: ${e.message}`)}}getConfigStyles(){try{let e=[];for(let t of x8)e.push(t.name);return e}catch(e){console.error(`Error retrieving base styles: ${e.message}`)}}getConfigWMSLayers(){try{let e=[];for(let t in C8.WMS)C8.WMS.hasOwnProperty(t)&&e.push(t);return e}catch(e){console.error(`Error retrieving WMS layers: ${e.message}`)}}getConfigOrtoLayers(){try{let e=[];for(let t in C8.Orto)C8.Orto.hasOwnProperty(t)&&e.push(t);return e}catch(e){console.error(`Error retrieving orto image layers: ${e.message}`)}}getConfigVectorLayers(){try{let e=[];for(let t in C8.Vector)C8.Vector.hasOwnProperty(t)&&e.push(t);return e}catch(e){console.error(`Error retrieving vector layers: ${e.message}`)}}getConfigVectorAdminLayers(){try{let e=[];for(let t in C8.VectorAdmin)C8.VectorAdmin.hasOwnProperty(t)&&e.push(t);return e}catch(e){console.error(`Error retrieving vectorAdmin layers: ${e.message}`)}}getConfigFGBAdminLayers(){try{let e=[];for(let t in C8.FGBAdmin)C8.FGBAdmin.hasOwnProperty(t)&&e.push(t);return e}catch(e){console.error(`Error retrieving FGBAdmin layers: ${e.message}`)}}async fetchData(e,t,n){try{(!n||n===void 0)&&(n={type:`line`,layout:{visibility:`visible`},paint:{"line-color":`grey`,"line-width":2},layerPosition:`top`});let r=n.layerPosition;if(e.includes(`.fgb`))this.addFGBLayerICGC(e,t,n);else{let i=await(await fetch(e)).json(),a=t,o=this._dealOrderLayer(r),s=i.features[0].geometry.type;s.includes(`ine`)&&(n===void 0?this.map.addLayer({id:a,type:`line`,source:{type:`geojson`,data:i},layout:{visibility:`visible`},paint:{"line-color":`black`,"line-width":2,"line-opacity":1}},o):this.map.addLayer({id:a,type:`line`,source:{type:`geojson`,data:i},layout:n.layout||{},paint:n.paint||{}},o)),s.includes(`olygon`)&&(n===void 0?this.map.addLayer({id:a,type:`fill`,source:{type:`geojson`,data:i},layout:{visibility:`visible`},paint:{"fill-color":`blue`,"fill-opacity":.6}},o):this.map.addLayer({id:a,type:`fill`,source:{type:`geojson`,data:i},layout:n.layout,paint:n.paint},o)),s.includes(`oint`)&&(n===void 0?this.map.addLayer({id:a,type:`circle`,source:{type:`geojson`,data:i},layout:{visibility:`visible`},paint:{"circle-color":`red`,"circle-opacity":.85}},o):this.map.addLayer({id:a,type:`circle`,source:{type:`geojson`,data:i},layout:n.layout,paint:n.paint},o))}}catch(e){console.error(`Error fetching data: ${e.message}`)}}async fetchDataAndMenu(e,t,n,r){try{let i;i=r===null?y8:r.layerPosition;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 o=`visible`,s=this._dealOrderLayer(i),c;if(e.includes(`.fgb`)){let n=this._getKeyByUrlFGB(e);n===null&&(n=`userFGB`);let i=await fetch(e),a={type:`FeatureCollection`,features:[]};for await(let e of qe(i.body))a.features.push(e);c=a;let l=t;if(this.map.addSource(l,{type:`geojson`,data:a}),e.includes(`text`))r===void 0?this.map.addLayer({id:t,type:`symbol`,source:l,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:o,"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)`}},s):this.map.addLayer({id:t,type:`symbol`,source:l,layout:r.layout,paint:r.paint},s);else{let e=t+`Text`;this.map.addLayer({id:e,type:`symbol`,source:l,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:o,"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)`}},s)}}else c=await(await fetch(e)).json();if(n!==`all`){let e=document.createElement(`div`);e.id=`titleDivMenu`,e.textContent=t,a.appendChild(e);let r=document.createElement(`div`);r.id=`titleDivMenuSub`,r.textContent=`📂 ${n}`,a.appendChild(r)}let l;if(l=r.type?r.type:c.features[0].geometry.type,n===`all`)l.includes(`ine`)&&(r===void 0?this.map.addLayer({id:t,type:`line`,source:{type:`geojson`,data:c},layout:{visibility:`visible`},paint:{"line-color":`black`,"line-width":2,"line-opacity":1}},s):this.map.addLayer({id:t,type:`line`,source:{type:`geojson`,data:c},layout:r.layout,paint:r.paint},s)),l.includes(`olygon`)&&(r===void 0?this.map.addLayer({id:t,type:`fill`,source:{type:`geojson`,data:c},layout:{visibility:`visible`},paint:{"fill-color":`#0000FF`,"fill-opacity":0}},s):this.map.addLayer({id:t,type:`fill`,source:{type:`geojson`,data:c},layout:r.layout,paint:r.paint},s)),l.includes(`oint`)&&(r===void 0?this.map.addLayer({id:t,type:`circle`,source:{type:`geojson`,data:c},layout:{visibility:`visible`},paint:{"circle-color":`red`,"circle-opacity":.85}},s):this.map.addLayer({id:t,type:`circle`,source:{type:`geojson`,data:c},layout:r.layout,paint:r.paint},s)),l.includes(`ymbol`)&&(r===void 0?this.map.addLayer({id:t,type:`symbol`,source:{type:`geojson`,data:c},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)`}},s):this.map.addLayer({id:t,type:`symbol`,source:{type:`geojson`,data:c},layout:r.layout,paint:r.paint},s)),this.addMenuItem(t);else{let e=n,i={};c.features.forEach(n=>{let a=n.properties[e],o=a+`-userFieldFilter-`+t;a!==null&&(i[o]||(l.includes(`ine`)&&(r===void 0?this.map.addLayer({id:o,type:`line`,source:{type:`geojson`,data:c},layout:{visibility:`visible`},filter:[`==`,`${e}`,a],paint:{"line-color":`black`,"line-width":2,"line-opacity":1}},s):this.map.addLayer({id:o,type:`line`,source:{type:`geojson`,data:c},layout:r.layout,paint:r.paint,filter:[`==`,`${e}`,a]},s)),l.includes(`olygon`)&&(r===void 0?this.map.addLayer({id:o,type:`fill`,source:{type:`geojson`,data:c},layout:{visibility:`visible`},filter:[`==`,`${e}`,a],paint:{"fill-color":`blue`,"fill-opacity":.6}},s):this.map.addLayer({id:o,type:`fill`,source:{type:`geojson`,data:c},filter:[`==`,`${e}`,a],layout:r.layout,paint:r.paint},s)),l.includes(`oint`)&&(r===void 0?this.map.addLayer({id:o,type:`circle`,source:{type:`geojson`,data:c},layout:{visibility:`visible`},filter:[`==`,`${e}`,a],paint:{"circle-color":`red`,"circle-opacity":.85}},s):this.map.addLayer({id:o,type:`circle`,source:{type:`geojson`,data:c},filter:[`==`,`${e}`,a],layout:r.layout,paint:r.paint},s)),i[o]=!0,this.addMenuItem(o)))})}}}catch(e){console.error(`Error fetching data: ${e.message}`)}}on(e,t){setTimeout(()=>{try{return this.map.on(e,t)}catch(e){console.error(`Error adding event ON listener: ${e.message}`)}},100)}setStyle(e,t){try{t===void 0?this.map.setStyle(e):this.map.setStyle(e,t),this.map.on(`styledata`,()=>{window.document.querySelector(`.maplibregl-compact-show`)&&window.document.querySelector(`.maplibregl-compact-show`).classList.remove(`maplibregl-compact-show`),this._dealOrto3dStyle(this.map.getStyle().name)})}catch(e){console.error(`Error setting style: ${e.message}`)}}addControl(e,t){try{t===void 0&&(t=`top-right`),this.map.addControl(e,t)}catch(e){console.error(`Error adding control: ${e.message}`)}}setSky(e){try{e===void 0&&(e=this.map.style.stylesheet.id.includes(`orto`)?{"sky-color":`#86bbd5`,"sky-horizon-blend":.3,"horizon-color":`#ffffff33`,"horizon-fog-blend":.1,"fog-ground-blend":.75,"fog-color":`#c5d6d6`}:this.map.style.stylesheet.id.includes(`mapa_estandard_general`)||this.map.style.stylesheet.id.includes(`icgc_mapa_vissir`)?{"sky-color":`#a5f0f0`,"sky-horizon-blend":.3,"horizon-color":`#e1e3e3`,"horizon-fog-blend":.9,"fog-ground-blend":.85,"fog-color":`#c5d6d6`}:this.map.style.stylesheet.id.includes(`fosc`)?{"sky-color":`#232423`,"sky-horizon-blend":.3,"horizon-color":`#969996`,"horizon-fog-blend":.9,"fog-ground-blend":.85,"fog-color":`#383838`}:{"sky-color":`#86bbd5`,"sky-horizon-blend":.3,"horizon-color":`#ffffff33`,"horizon-fog-blend":.1,"fog-ground-blend":.75,"fog-color":`#c5d6d6`}),this.map.setSky(e)}catch(e){console.error(`Error setting sky properties: ${e.message}`)}}addMouseCoordControl(e,t=`bottom-left`){try{this.map.addControl(new v4(e),t)}catch(e){console.error(`Error adding mouse coordinate control: ${e.message}`)}}addGeolocateControl(e,t){try{t===void 0&&(t=`top-right`),e===void 0?this.map.addControl(new f.default.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!0}),t):this.map.addControl(new f.default.GeolocateControl(e),t)}catch(e){console.error(`Error adding geolocate control: ${e.message}`)}}addFullscreenControl(e,t){try{t===void 0&&(t=`top-right`),e===void 0?this.map.addControl(new f.default.FullscreenControl({container:HTMLElement}),t):this.map.addControl(new f.default.FullscreenControl(e),t)}catch(e){console.error(`Error adding fullscreen control: ${e.message}`)}}addLayer(e,t){try{this.map.addLayer(e,t)}catch(e){console.error(`Error adding layer: ${e.message}`)}}addImage(e,t,n){try{this.map.addImage(e,t,n)}catch(e){console.error(`Error adding image: ${e.message}`)}return this}addSource(e,t){try{this.map.addSource(e,t)}catch(e){console.error(`Error adding source: ${e.message}`)}return this}addSprite(e,t,n){try{this.map.addSprite(e,t,n)}catch(e){console.error(`Error adding sprite: ${e.message}`)}return this}areTilesLoaded(){return this.map.areTilesLoaded()}cameraForBounds(e,t){return this.map.cameraForBounds(e,t)}easeTo(e,t){return this.map.easeTo(e,t),this}fitBounds(e,t,n){return this.map.fitBounds(e,t,n),this}fitScreenCoordinates(e,t,n,r,i){return this.map.fitScreenCoordinates(e,t,n,r,i),this}flyTo(e,t){return this.map.flyTo(e,t),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(e){return this.map.getFeatureState(e)}getFilter(e){return this.map.getFilter(e)}getGlyphs(){return this.map.getGlyphs()}getImage(e){return this.map.getImage(e)}getLayer(e){return this.map.getLayer(e)}getLayersOrder(){return this.map.getLayersOrder()}getLayoutProperty(e,t){return this.map.getLayoutProperty(e,t)}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(e,t){return this.map.getPaintProperty(e,t)}getPitch(){return this.map.getPitch()}getPixelRatio(){return this.map.getPixelRatio()}getRenderWorldCopies(){return this.map.getRenderWorldCopies()}getSource(e){return this.map.getSource(e)}getSprite(){return this.map.getSprite()}getStyle(){return this.map.getStyle()}getTerrain(){return this.map.getTerrain()}getZoom(){return this.map.getZoom()}hasControl(e){return this.map.hasControl(e)}hasImage(e){return this.map.hasImage(e)}isMoving(){return this.map.isMoving()}isRotating(){return this.map.isRotating()}isSourceLoaded(e){return this.map.isSourceLoaded(e)}isStyleLoaded(){return this.map.isStyleLoaded()}isZooming(){return this.map.isZooming()}jumpTo(e,t){return this.map.jumpTo(e,t)}listImages(){return this.map.listImages()}listens(e){return this.map.listens(e)}loadImage(e){return this.map.loadImage(e)}loaded(){return this.map.loaded()}LngLatBounds(e,t){return new f.default.LngLatBounds(e,t)}addProtocol(e,t){return this.map.addProtocol(e,t)}moveLayer(e,t){return this.map.moveLayer(e,t)}panBy(e,t,n){return this.map.panBy(e,t,n)}panTo(e,t,n){return this.map.panTo(e,t,n)}project(e){return this.map.project(e)}queryRenderedFeatures(e,t){return this.map.queryRenderedFeatures(e,t)}querySourceFeatures(e,t){return this.map.querySourceFeatures(e,t)}queryTerrainElevation(e){return this.map.queryTerrainElevation(e)}redraw(){return this.map.redraw()}remove(){return this.map.remove()}removeControl(e){return this.map.removeControl(e)}removeFeatureState(e,t){return this.map.removeFeatureState(e,t)}removeImage(e){return this.map.removeImage(e)}removeLayer(e){try{this.map.removeLayer(e)}catch(e){console.error(`Error removing layer: ${e.message}`)}}removeSource(e){try{this.map.removeSource(e)}catch(e){console.error(`Error removing source: ${e.message}`)}}removeSprite(e){return this.map.removeSprite(e)}resetNorth(e,t){return this.map.resetNorth(e,t)}resetNorthPitch(e,t){return this.map.resetNorthPitch(e,t)}resize(e){return this.map.resize(e)}rotateTo(e,t,n){return this.map.rotateTo(e,t,n)}setBearing(e,t){return this.map.setBearing(e,t)}setCenter(e,t){return this.map.setCenter(e,t)}setEventedParent(e,t){return this.map.setEventedParent(e,t)}setFeatureState(e,t){return this.map.setFeatureState(e,t)}setFilter(e,t,n){return this.map.setFilter(e,t,n)}setGlyphs(e,t){return this.map.setGlyphs(e,t)}setLayerZoomRange(e,t,n){return this.map.setLayerZoomRange(e,t,n)}setLayoutProperty(e,t,n,r){return this.map.setLayoutProperty(e,t,n,r)}setLight(e,t){return this.map.setLight(e,t)}setMaxBounds(e){return this.map.setMaxBounds(e)}setMaxPitch(e){return this.map.setMaxPitch(e)}setMaxZoom(e){return this.map.setMaxZoom(e)}setMinPitch(e){return this.map.setMinPitch(e)}setMinZoom(e){return this.map.setMinZoom(e)}setPadding(e,t){return this.map.setPadding(e,t)}setPaintProperty(e,t,n,r){return this.map.setPaintProperty(e,t,n,r)}setPitch(e,t){return this.map.setPitch(e,t)}setPixelRatio(e){return this.map.setPixelRatio(e)}setRenderWorldCopies(e){return this.map.setRenderWorldCopies(e)}setSprite(e,t){return this.map.setSprite(e,t)}setTerrain(e){return this.map.setTerrain(e)}setTransformRequest(e){return this.map.setTransformRequest(e)}setZoom(e,t){return this.map.setZoom(e,t)}snapToNorth(e,t){return this.map.snapToNorth(e,t)}stop(){return this.map.stop()}triggerRepaint(){return this.map.triggerRepaint()}unproject(e){return this.map.unproject(e)}updateImage(e,t){return this.map.updateImage(e,t)}zoomIn(e,t){return this.map.zoomIn(e,t)}zoomOut(e,t){return this.map.zoomOut(e,t)}zoomTo(e,t,n){return this.map.zoomTo(e,t,n)}addLayerGeoJSON(e,t){try{let n=this._dealOrderLayer(t);this.map.addSource(`${e.id}`,{type:`geojson`,data:e.data}),this.map.addLayer({id:`${e.id}-layerIcgcMap`,type:e.type,source:`${e.id}`,layout:e.layout,paint:e.paint},n)}catch(e){console.error(`Error adding GeoJSON layer: ${e.message}`)}}addLayerWMS(e,t,n){try{let r=this._dealOrderLayer(n.layerPosition);n?(this.map.addSource(`${t}`,{type:`raster`,tiles:[e],tileSize:256},r),this.map.addLayer({id:t,type:`raster`,source:t,layout:n.layout,paint:n.paint},r)):(this.map.addSource(`${t}`,{type:`raster`,tiles:[e],tileSize:256},r),this.map.addLayer({id:t,type:`raster`,source:t,paint:{}},r))}catch(e){console.error(`Error adding WMS layer: ${e.message}`)}}addLogo(e){try{let t=document.getElementById(`map`),n;n=document.createElement(`div`),n.id=`logos`,t.appendChild(n);let r=document.createElement(`img`);r.src=e.url,r.style.height=e.height;let i=document.getElementById(`logos`),a=document.createElement(`a`);a.id=e.id,a.href=e.href,a.target=`_blank`,a.style.position=`relative`,a.style.bottom=`1px`,a.appendChild(r),i.appendChild(a)}catch(e){console.error(`Error adding logo: ${e.message}`)}}addBasemapsICGC(e){try{let t=e=>{this.map.setStyle(e)},n=document.getElementById(`map`),r;r=document.createElement(`div`),r.id=`basemap-group`,r.classList.add=`filter-group`,n.appendChild(r);let i=document.getElementById(`basemap-group`);for(let n of e)for(let e of Object.keys(w8.baseStyles)){let r=w8.baseStyles[e];if(n===r.url){let e=document.createElement(`div`);e.className=`basemap-item`,e.title=r.key,e.style.backgroundImage=`url('${r.image}')`,i.appendChild(e),e.addEventListener(`click`,()=>t(r.url))}}}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addBasemaps(e){try{let t=e=>{map.setStyle(e.url)},n=document.getElementById(`map`),r;r=document.createElement(`div`),r.id=`basemap-group`,r.classList.add=`basemap-group`,n.appendChild(r);let i=document.getElementById(`basemap-group`);e.forEach(e=>{let n=document.createElement(`div`);n.className=`basemap-item`,n.title=e.label,n.style.backgroundImage=`url('${e.image}')`,i.appendChild(n),n.addEventListener(`click`,()=>t(e))})}catch(e){console.error(`Error adding basemaps: ${e.message}`)}}addFeatureQuery(e,t,n){try{let r;this.map.on(`mouseenter`,e,()=>{this.map.getCanvas().style.cursor=`pointer`}),this.map.on(`mouseleave`,e,()=>{this.map.getCanvas().style.cursor=``}),this.map.on(`click`,i=>{let a=this.map.queryRenderedFeatures(i.point);if(a&&a[0].source.includes(e)){let e=[i.lngLat.lng,i.lngLat.lat];if(t!==void 0&&t.length>0&&t!==`all`){if(t!==null){let i=``;t.forEach(e=>{let t=a[0].properties[e];i+=`<h4>${t}</h4>`}),r=i,this.addPopup(e,r,n)}}else{let t=``;for(let e in a[0].properties)t+=`<b>`+e+`</b>:`+a[0].properties[e]+`<br>`;r=t,this.addPopup(e,r,n)}}})}catch(e){console.error(`Error adding feature query: ${e.message}`)}}addScaleControl(e,t){try{var n=new f.default.ScaleControl(e);this.map.addControl(n,t)}catch(e){console.error(`Error adding scale: ${e.message}`)}}addExportControl(e,t){try{typeof e==`string`&&(t=e,e=void 0),e===void 0&&(e={PageSize:oq.A4,PageOrientation:aq.Landscape,Format:iq.PNG,DPI:rq[300],Crosshair:!0,PrintableArea:!0,Local:`ca`},t=`top-right`),this.map.addControl(new A2(e),t)}catch(e){console.error(`Error adding export control: ${e.message}`)}}addMarker(e){try{let t,n;return e.text===void 0?t=new f.default.Marker(e.options).setLngLat(e.coord).addTo(this.map):(n=new f.default.Popup({offset:e.textOffset}).setHTML(e.text),t=new f.default.Marker(e.options).setLngLat(e.coord).setPopup(n).addTo(this.map)),t}catch(e){return console.error(`Error adding marker: ${e.message}`),null}}addPopup(e,t,n){try{return n.image===void 0?new f.default.Popup().setLngLat(e).setHTML(`
|
|
3822
3822
|
<div class="popupBody">
|
|
3823
3823
|
<div class="popupTop">
|
|
3824
3824
|
${n.title}
|
|
@@ -3845,4 +3845,4 @@ end`};t.events.push([`putFont`,function(t){(function(t){var n=t.font,i=t.out,a=t
|
|
|
3845
3845
|
</div>
|
|
3846
3846
|
</div>
|
|
3847
3847
|
</div>
|
|
3848
|
-
`).addTo(this.map)}catch(e){return console.error(`Error adding popup: ${e.message}`),null}}addFullScreen(e){try{e===void 0&&(e=`top-right`),this.map.addControl(new f.default.FullscreenControl,e)}catch(e){console.error(`Error adding fullscreen control: ${e.message}`)}}addMenuItem(e){try{let t;if(t=e.includes(`-userFieldFilter-`)?e.split(`-userFieldFilter-`)[0]:e,e.length>0){let n=document.getElementById(`menu-group`),r=document.createElement(`input`);r.type=`checkbox`,r.id=e,r.checked=!0,n.appendChild(r);let i=document.createElement(`label`);i.setAttribute(`for`,e),i.textContent=t,n.appendChild(i),r.addEventListener(`change`,t=>{this.map.setLayoutProperty(e,`visibility`,t.target.checked?`visible`:`none`)})}}catch(e){console.error(`Error adding menu item: ${e.message}`)}}addLayerTree(e){try{let t=e.features,n=document.getElementById(`map`),r=document.createElement(`nav`);r.id=`filter-group`,n.appendChild(r);let i=document.getElementById(`filter-group`);this.map.addSource(`${e.id}`,{type:e.type,data:t}),t.features.forEach(t=>{let n=t.properties.icon,r=`poi-${n}`;if(!this.map.getLayer(r)){this.map.addLayer({id:r,type:`circle`,source:`${e.id}`,paint:{"circle-radius":6,"circle-color":`#B42222`},filter:[`==`,`icon`,n]},this._firstSymbolLayer());let t=document.createElement(`input`);t.type=`checkbox`,t.id=r,t.checked=!0,i.appendChild(t);let a=document.createElement(`label`);a.setAttribute(`for`,r),a.textContent=n,i.appendChild(a),t.addEventListener(`change`,e=>{this.map.setLayoutProperty(r,`visibility`,e.target.checked?`visible`:`none`)})}})}catch(e){console.error(`Error adding layer tree: ${e.message}`)}}createNavigationControl(e,t){try{t===void 0&&(t=`top-right`),this.map.addControl(new f.default.NavigationControl(e),t)}catch(e){return console.error(`Error creating navigation control: ${e.message}`),null}}addNavigationControl(e,t){try{t===void 0&&(t=`top-right`),this.map.addControl(new f.default.NavigationControl(e),t)}catch(e){console.error(`Error adding navigation control: ${e.message}`)}}addAttributionControl(e,t){try{let n=`<a style="font-weight: bold; color: #D97634;" href="https://www.icgc.cat/Eines-i-visors/Recursos-desenvolupadors/Biblioteca-MapICGC-GL-JS/" target="_blank">Fet amb MapICGC</a>`,r=Object.assign({},{compact:!0},e);r.customAttribution?Array.isArray(r.customAttribution)?r.customAttribution.includes(n)||(r.customAttribution=[n,...r.customAttribution]):r.customAttribution!==n&&(r.customAttribution=[n,r.customAttribution]):r.customAttribution=n,this.map.addControl(new f.default.AttributionControl(r),t)}catch(e){console.error(`Error adding attribution control: ${e.message}`)}}addImageLayerICGC(e,t,n){try{let r=null,i;n?(i=n,n.layerPosition):i={type:`raster`,layout:{visibility:`visible`},paint:{"raster-opacity":1},layerPosition:y8},r=this._findImageType(e,C8.Orto,C8.VectorAdmin,C8.WMS,C8.Vector),r||console.log(`❌ %c The layer: %c%s%c does not exist in the ICGC DB. Consult the documentation.`,`font-weight: bold; font-style: italic;`,`font-weight: normal; font-style: normal; color: red;`,e,`font-weight: bold; font-style: italic;`),this.addLayerWMS(e,t,i)}catch(e){console.error(`Error adding ICGC image layer: ${e.message}`)}}async addVectorLayerICGC(e,t,n){try{let{type:r=`line`,layerPosition:i=y8,layoutOptions:a={visibility:`visible`},paintOption:o}=n||{},s=this._dealOrderLayer(i);if(!e){console.log(`❌ %c The layer: %c%s%c does not exist in the ICGC DB. Consult the documentation.`,`font-weight: bold; font-style: italic;`,`font-weight: normal; font-style: normal; color: red;`,e,`font-weight: bold; font-style: italic;`);return}if(e.includes(`https`)){let t=this._getKeyByUrlVector(e);this.map.addSource(t,{type:`vector`,url:e});let r={id:t,type:`fill`,source:t,"source-layer":`cobertes`,maxzoom:18,layout:n.layout,paint:_8.cobertesSol};if(t===`cobertes2018`&&this.map.addLayer(r,s),a.visibility===`visible`){let e=this._getLegendByName(t);this.addLegend(e,t)}}else{let i=t;this.map.addSource(i,{type:`vector`,url:w8.limitsUrl});let a={id:t,type:r,source:i,"source-layer":e,layout:n.layout,paint:n.paint||{}};r===`fill`||r===`polygon`?a.paint=o||{"fill-color":`#0000FF`,"fill-opacity":0}:r===`line`&&(a.paint=o||{"line-color":`#4832a8`,"line-opacity":1,"line-width":1}),this.map.addLayer(a,s)}}catch(e){console.error(`Error adding ICGC vector layer: ${e.message}`)}}async addFGBLayerICGC(e,t,n){try{n||(n.layout={visibility:!0},n.paint={"line-color":`#4832a8`,"line-opacity":1,"line-width":1},n.type=`lines`,n.layerPosition=`labels`);let r=this._dealOrderLayer(n.layerPosition),i=await fetch(e),a={type:`FeatureCollection`,features:[]};for await(let e of qe(i.body))a.features.push(e);let o=t;this.map.addSource(o,{type:`geojson`,data:a}),e.includes(`text`)?this.map.addLayer({id:t,type:`symbol`,source:o,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:n.layout.visibility,"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)`}},r):this.map.addLayer({id:t,type:n.type,source:o,layout:n.layout,paint:n.paint},r)}catch(e){console.error(`Error adding ICGC FGB layer: ${e.message}`)}}addTerrainICGC(e,t){try{let n;for(let t in S8)if(S8.hasOwnProperty(t)){let r=S8[t];r===e&&(n=r)}let r=n;this.getSource(`terrainICGC`)!==void 0&&(this.getStyle().layers.forEach(e=>{e.source===`terrainICGC`&&this.removeLayer(e.id)}),this.removeSource(`terrainICGC`)),this.getSource(`terrainICGC`)===void 0&&(e.includes(`terrarium`)?this.map.addSource(`terrainICGC`,{type:`raster-dem`,tiles:[r],tileSize:512,encoding:`terrarium`,maxzoom:16}):this.map.addSource(`terrainICGC`,{type:`raster-dem`,tiles:[r],tileSize:256,maxzoom:14,minzoom:7})),this.map.setTerrain({source:`terrainICGC`,exaggeration:1.5}),t==null||this.map.addControl(new V({pitch:90,bearing:null,minpitchzoom:null}),t)}catch(e){console.error(`Error adding 3D terrain: ${e.message}`)}}addLegend(e,t){try{this.map.addControl(new g4({url:e,idLayer:t}))}catch(e){console.error(`Error adding legend: ${e.message}`)}}_findImageType(e,t,n,r,i){let a=[t,n,r,i];for(let t of a)for(let[n,r]of Object.entries(t))if(r===e)return n;return null}_getKeyByUrlFGB(e){for(let t in C8.FGBAdmin)if(C8.FGBAdmin.hasOwnProperty(t)&&C8.FGBAdmin[t]===e)return t;return null}_getLegendByName(e){for(let t in w8.vectorLayers){let n=w8.vectorLayers[t];if(n.key===e)return n.legend}return null}_getKeyByUrlVector(e){for(let t in C8.Vector)if(C8.Vector.hasOwnProperty(t)&&C8.Vector[t]===e)return t;return null}async _raiseText3DStyle(){try{let e=await this.map.loadImage(w8.map3dOptions.imageIcon);this.map.hasImage(`stick`)||this.map.addImage(`stick`,e.data),this.map.getStyle().layers.forEach(t=>{if(t[`source-layer`]===w8.map3dOptions.sourceLayerFilterId&&t.minzoom>=w8.map3dOptions.minZoomFilter&&e){let e=t.id;this.map.setLayoutProperty(e,`icon-image`,`stick`),this.map.setLayoutProperty(e,`text-offset`,[0,-9]),this.map.setLayoutProperty(e,`symbol-placement`,`point`),this.map.setLayoutProperty(e,`symbol-avoid-edges`,!1),this.map.setLayoutProperty(e,`text-allow-overlap`,!0),this.map.setLayoutProperty(e,`text-ignore-placement`,!1),this.map.setLayoutProperty(e,`text-pitch-alignment`,`auto`),this.map.setLayoutProperty(e,`text-rotation-alignment`,`auto`),this.map.setLayoutProperty(e,`text-justify`,`center`),this.map.setLayoutProperty(e,`text-anchor`,`bottom`),this.map.setLayoutProperty(e,`icon-anchor`,`bottom`),this.map.setPaintProperty(e,`text-color`,`#ffffff`),this.map.setPaintProperty(e,`text-halo-color`,`#000000`),this.map.setPaintProperty(e,`text-halo-width`,2)}})}catch(e){return console.error(`Error dealing orto 3D: ${e.message}`),null}}_dealStyleMaps(e){try{if(e&&e.indexOf(`icgc.cat`)!=-1){for(let t in x8)if(x8.hasOwnProperty(t)){let n=x8[t];if(t===e)return n}return x8[0]}else return e}catch(e){return console.error(`Error dealing with map styles: ${e.message}`),null}}_dealOrto3dStyle(e){try{if(e==`orto3d`){this.map.setMaxZoom(18.8),this.map.easeTo({pitch:45});let e=new vv({ambientLight:new rv({intensity:4})});this.map.setTerrain({source:w8.map3dOptions.terrainSource,exaggeration:w8.map3dOptions.exaggeration}),b8=new zD({interleaved:!0,layers:[this._createCitiesMapboxLayer(!1)],effects:[e],onAfterRender:()=>{try{let e=this.map.getZoom()>=w8.map3dOptions.minZoomRange;b8.setProps({layers:[this._createCitiesMapboxLayer(e)]})}catch{console.log(`No render 3D Mesh`)}}}),this.map.hasControl(b8)||(this.map.addControl(b8),this._raiseText3DStyle()),this.map.setSky({"sky-color":`#86bbd5`,"sky-horizon-blend":.3,"horizon-color":`#ffffff33`,"horizon-fog-blend":.1,"fog-ground-blend":.75,"fog-color":`#c5d6d6`}),this.map.on(`zoomend`,()=>{!this.map.getStyle().name==`orto3d`&&this.map.hasControl(b8)&&(this.map.removeControl(b8),b8.setProps({layers:[]}),this.map.setTerrain(null))})}else b8?.setProps({layers:[]}),this.map.hasControl(b8)&&(this.map.removeControl(b8),b8.setProps({layers:[]}),this.map.setTerrain(null))}catch(e){return console.error(`Error dealing orto 3D: ${e.message}`),null}}_dealOrderLayer(e){return e===y8?this._firstSymbolLayer():e===v8?this._firstLineLayer():``}_firstSymbolLayer(){try{let e=this.map.getStyle().layers,t;for(let n=0;n<e.length;n++)if(e[n].type===`symbol`&&e[n].id.indexOf(`contour`)===-1&&e[n].id.indexOf(`water`)===-1){t=e[n].id;break}return t}catch(e){console.error(`Error getting first symbol layer: ${e.message}`)}}_firstLineLayer(){try{let e=this.map.getStyle().layers,t;for(let n=0;n<e.length;n++)if(e[n].type===`line`){t=e[n].id;break}return t}catch(e){console.error(`Error getting first symbol layer: ${e.message}`)}}_createCitiesMapboxLayer(e=!1){try{return new Mz({id:w8.map3dOptions.layerId3d,data:w8.map3dOptions.urlTilesetCities,loader:Tz,beforeId:w8.map3dOptions.layerIdOrder,visible:e,loadOptions:{tileset:{viewDistanceScale:1,memoryAdjustedScreenSpaceError:w8.map3dOptions.spaceErrorFactor,updateTransforms:!0,adjustScreenSpaceError:w8.map3dOptions.spaceErrorFactor}},onTilesetLoad:e=>{e.adjustScreenSpaceError=w8.map3dOptions.spaceErrorFactor,e.memoryAdjustedScreenSpaceError=w8.map3dOptions.spaceErrorFactor},onTileLoad:e=>{e.content.cartographicOrigin.z-=w8.map3dOptions.zfactor},operation:`terrain+draw`,pickable:!1})}catch(e){return console.error(`Error adding MapboxOverlay: ${e.message}`),null}}},E8=c(((e,t)=>{function n(e,t){var n=e.getCenter(),r=e.getZoom(),i=e.getBearing(),a=e.getPitch();t.forEach(function(e){e.jumpTo({center:n,zoom:r,bearing:i,pitch:a})})}function r(){var e,t=arguments.length;if(t===1)e=arguments[0];else{e=[];for(var r=0;r<t;r++)e.push(arguments[r])}var i=[];e.forEach(function(t,n){i[n]=s.bind(null,t,e.filter(function(e,t){return t!==n}))});function a(){e.forEach(function(e,t){e.on(`move`,i[t])})}function o(){e.forEach(function(e,t){e.off(`move`,i[t])})}function s(e,t){o(),n(e,t),a()}return a(),function(){o(),i=[],e=[]}}t.exports=r})),D8=c(((e,t)=>{var n=typeof Reflect==`object`?Reflect:null,r=n&&typeof n.apply==`function`?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},i=n&&typeof n.ownKeys==`function`?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};function a(e){console&&console.warn&&console.warn(e)}var o=Number.isNaN||function(e){return e!==e};function s(){s.init.call(this)}t.exports=s,t.exports.once=y,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function l(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}Object.defineProperty(s,`defaultMaxListeners`,{enumerable:!0,get:function(){return c},set:function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received `+e+`.`);c=e}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e+`.`);return this._maxListeners=e,this};function u(e){return e._maxListeners===void 0?s.defaultMaxListeners:e._maxListeners}s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e===`error`,a=this._events;if(a!==void 0)i&&=a.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=Error(`Unhandled error.`+(o?` (`+o.message+`)`:``));throw s.context=o,s}var c=a[e];if(c===void 0)return!1;if(typeof c==`function`)r(c,this,t);else for(var l=c.length,u=g(c,l),n=0;n<l;++n)r(u[n],this,t);return!0};function d(e,t,n,r){var i,o,s;if(l(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit(`newListener`,t,n.listener?n.listener:n),o=e._events),s=o[t]),s===void 0)s=o[t]=n,++e._eventsCount;else if(typeof s==`function`?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),i=u(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var c=Error(`Possible EventEmitter memory leak detected. `+s.length+` `+String(t)+` listeners added. Use emitter.setMaxListeners() to increase limit`);c.name=`MaxListenersExceededWarning`,c.emitter=e,c.type=t,c.count=s.length,a(c)}return e}s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)};function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}s.prototype.once=function(e,t){return l(t),this.on(e,p(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,p(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,a,o;if(l(t),r=this._events,r===void 0||(n=r[e],n===void 0))return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():_(n,i),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit(`removeListener`,e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n=this._events,r;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!==`removeListener`&&this.removeAllListeners(a);return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t==`function`)this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function m(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i==`function`?n?[i.listener||i]:[i]:n?v(i):g(i,i.length)}s.prototype.listeners=function(e){return m(this,e,!0)},s.prototype.rawListeners=function(e){return m(this,e,!1)},s.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h;function h(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n==`function`)return 1;if(n!==void 0)return n.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function g(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function _(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function v(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function y(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){typeof e.removeListener==`function`&&e.removeListener(`error`,i),n([].slice.call(arguments))}x(e,t,a,{once:!0}),t!==`error`&&b(e,i,{once:!0})})}function b(e,t,n){typeof e.on==`function`&&x(e,`error`,t,n)}function x(e,t,n,r){if(typeof e.on==`function`)r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener==`function`)e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw TypeError(`The "emitter" argument must be of type EventEmitter. Received type `+typeof e)}})),O8=d(c(((e,t)=>{var n=E8(),r=D8().EventEmitter;function i(e,t,i,a){if(this.options=a||{},this._mapA=e,this._mapB=t,this._horizontal=this.options.orientation===`horizontal`,this._onDown=this._onDown.bind(this),this._onMove=this._onMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._ev=new r,this._swiper=document.createElement(`div`),this._swiper.className=this._horizontal?`compare-swiper-horizontal`:`compare-swiper-vertical`,this._controlContainer=document.createElement(`div`),this._controlContainer.className=this._horizontal?`maplibregl-compare maplibregl-compare-horizontal`:`maplibregl-compare`,this._controlContainer.className=this._controlContainer.className,this._controlContainer.appendChild(this._swiper),typeof i==`string`&&document.body.querySelectorAll){var o=document.body.querySelectorAll(i)[0];if(!o)throw Error(`Cannot find element with specified container selector.`);o.appendChild(this._controlContainer)}else if(i instanceof Element&&i.appendChild)i.appendChild(this._controlContainer);else throw Error(`Invalid container specified. Must be CSS selector or HTML element.`);this._bounds=t.getContainer().getBoundingClientRect();var s=(this._horizontal?this._bounds.height:this._bounds.width)/2;this._setPosition(s),this._clearSync=n(e,t),this._onResize=function(){this._bounds=t.getContainer().getBoundingClientRect(),this.currentPosition&&this._setPosition(this.currentPosition)}.bind(this),t.on(`resize`,this._onResize),this.options&&this.options.mousemove&&(e.getContainer().addEventListener(`mousemove`,this._onMove),t.getContainer().addEventListener(`mousemove`,this._onMove)),this._swiper.addEventListener(`mousedown`,this._onDown),this._swiper.addEventListener(`touchstart`,this._onDown)}i.prototype={_setPointerEvents:function(e){this._controlContainer.style.pointerEvents=e,this._swiper.style.pointerEvents=e},_onDown:function(e){e.touches?(document.addEventListener(`touchmove`,this._onMove),document.addEventListener(`touchend`,this._onTouchEnd)):(document.addEventListener(`mousemove`,this._onMove),document.addEventListener(`mouseup`,this._onMouseUp))},_setPosition:function(e){e=Math.min(e,this._horizontal?this._bounds.height:this._bounds.width);var t=this._horizontal?`translate(0, `+e+`px)`:`translate(`+e+`px, 0)`;this._controlContainer.style.transform=t,this._controlContainer.style.WebkitTransform=t;var n=this._horizontal?`rect(0, 999em, `+e+`px, 0)`:`rect(0, `+e+`px, `+this._bounds.height+`px, 0)`,r=this._horizontal?`rect(`+e+`px, 999em, `+this._bounds.height+`px,0)`:`rect(0, 999em, `+this._bounds.height+`px,`+e+`px)`;this._mapA.getContainer().style.clip=n,this._mapB.getContainer().style.clip=r,this.currentPosition=e},_onMove:function(e){this.options&&this.options.mousemove&&this._setPointerEvents(e.touches?`auto`:`none`),this._horizontal?this._setPosition(this._getY(e)):this._setPosition(this._getX(e))},_onMouseUp:function(){document.removeEventListener(`mousemove`,this._onMove),document.removeEventListener(`mouseup`,this._onMouseUp),this.fire(`slideend`,{currentPosition:this.currentPosition})},_onTouchEnd:function(){document.removeEventListener(`touchmove`,this._onMove),document.removeEventListener(`touchend`,this._onTouchEnd),this.fire(`slideend`,{currentPosition:this.currentPosition})},_getX:function(e){e=e.touches?e.touches[0]:e;var t=e.clientX-this._bounds.left;return t<0&&(t=0),t>this._bounds.width&&(t=this._bounds.width),t},_getY:function(e){e=e.touches?e.touches[0]:e;var t=e.clientY-this._bounds.top;return t<0&&(t=0),t>this._bounds.height&&(t=this._bounds.height),t},setSlider:function(e){this._setPosition(e)},on:function(e,t){return this._ev.on(e,t),this},fire:function(e,t){return this._ev.emit(e,t),this},off:function(e,t){return this._ev.removeListener(e,t),this},remove:function(){this._clearSync(),this._mapB.off(`resize`,this._onResize);var e=this._mapA.getContainer();e&&(e.style.clip=null,e.removeEventListener(`mousemove`,this._onMove));var t=this._mapB.getContainer();t&&(t.style.clip=null,t.removeEventListener(`mousemove`,this._onMove)),this._swiper.removeEventListener(`mousedown`,this._onDown),this._swiper.removeEventListener(`touchstart`,this._onDown),this._controlContainer.remove()}},window.maplibregl?maplibregl.Compare=i:t!==void 0&&(t.exports=i)}))());e.CompareMaps=class{constructor(e,t,n,r){let i=this;setTimeout(function(){i.mapCompare=new O8.default(e.map,t.map,n,{})},1e3)}},e.Config=g8,e.Map=T8});
|
|
3848
|
+
`).addTo(this.map)}catch(e){return console.error(`Error adding popup: ${e.message}`),null}}addFullScreen(e){try{e===void 0&&(e=`top-right`),this.map.addControl(new f.default.FullscreenControl,e)}catch(e){console.error(`Error adding fullscreen control: ${e.message}`)}}addMenuItem(e){try{let t;if(t=e.includes(`-userFieldFilter-`)?e.split(`-userFieldFilter-`)[0]:e,e.length>0){let n=document.getElementById(`menu-group`),r=document.createElement(`input`);r.type=`checkbox`,r.id=e,r.checked=!0,n.appendChild(r);let i=document.createElement(`label`);i.setAttribute(`for`,e),i.textContent=t,n.appendChild(i),r.addEventListener(`change`,t=>{this.map.setLayoutProperty(e,`visibility`,t.target.checked?`visible`:`none`)})}}catch(e){console.error(`Error adding menu item: ${e.message}`)}}addLayerTree(e){try{let t=e.features,n=document.getElementById(`map`),r=document.createElement(`nav`);r.id=`filter-group`,n.appendChild(r);let i=document.getElementById(`filter-group`);this.map.addSource(`${e.id}`,{type:e.type,data:t}),t.features.forEach(t=>{let n=t.properties.icon,r=`poi-${n}`;if(!this.map.getLayer(r)){this.map.addLayer({id:r,type:`circle`,source:`${e.id}`,paint:{"circle-radius":6,"circle-color":`#B42222`},filter:[`==`,`icon`,n]},this._firstSymbolLayer());let t=document.createElement(`input`);t.type=`checkbox`,t.id=r,t.checked=!0,i.appendChild(t);let a=document.createElement(`label`);a.setAttribute(`for`,r),a.textContent=n,i.appendChild(a),t.addEventListener(`change`,e=>{this.map.setLayoutProperty(r,`visibility`,e.target.checked?`visible`:`none`)})}})}catch(e){console.error(`Error adding layer tree: ${e.message}`)}}createNavigationControl(e,t){try{t===void 0&&(t=`top-right`),this.map.addControl(new f.default.NavigationControl(e),t)}catch(e){return console.error(`Error creating navigation control: ${e.message}`),null}}addNavigationControl(e,t){try{t===void 0&&(t=`top-right`),this.map.addControl(new f.default.NavigationControl(e),t)}catch(e){console.error(`Error adding navigation control: ${e.message}`)}}addAttributionControl(e,t){try{let n=`<a style="font-weight: bold; color: #D97634;" href="https://www.icgc.cat/Eines-i-visors/Recursos-desenvolupadors/Biblioteca-MapICGC-GL-JS/" target="_blank">Fet amb MapICGC</a>`,r=Object.assign({},{compact:!0},e),i=r.autoCollapseDelay;delete r.autoCollapseDelay,r.customAttribution?Array.isArray(r.customAttribution)?r.customAttribution.includes(n)||(r.customAttribution=[n,...r.customAttribution]):r.customAttribution!==n&&(r.customAttribution=[n,r.customAttribution]):r.customAttribution=n,this.map.addControl(new f.default.AttributionControl(r),t),i&&typeof i==`number`&&i>0&&setTimeout(()=>{let e=document.querySelector(`.maplibregl-ctrl-attrib-button`);e&&e.getAttribute(`aria-pressed`)===`true`&&e.click()},i)}catch(e){console.error(`Error adding attribution control: ${e.message}`)}}addImageLayerICGC(e,t,n){try{let r=null,i;n?(i=n,n.layerPosition):i={type:`raster`,layout:{visibility:`visible`},paint:{"raster-opacity":1},layerPosition:y8},r=this._findImageType(e,C8.Orto,C8.VectorAdmin,C8.WMS,C8.Vector),r||console.log(`❌ %c The layer: %c%s%c does not exist in the ICGC DB. Consult the documentation.`,`font-weight: bold; font-style: italic;`,`font-weight: normal; font-style: normal; color: red;`,e,`font-weight: bold; font-style: italic;`),this.addLayerWMS(e,t,i)}catch(e){console.error(`Error adding ICGC image layer: ${e.message}`)}}async addVectorLayerICGC(e,t,n){try{let{type:r=`line`,layerPosition:i=y8,layoutOptions:a={visibility:`visible`},paintOption:o}=n||{},s=this._dealOrderLayer(i);if(!e){console.log(`❌ %c The layer: %c%s%c does not exist in the ICGC DB. Consult the documentation.`,`font-weight: bold; font-style: italic;`,`font-weight: normal; font-style: normal; color: red;`,e,`font-weight: bold; font-style: italic;`);return}if(e.includes(`https`)){let t=this._getKeyByUrlVector(e);this.map.addSource(t,{type:`vector`,url:e});let r={id:t,type:`fill`,source:t,"source-layer":`cobertes`,maxzoom:18,layout:n.layout,paint:_8.cobertesSol};if(t===`cobertes2018`&&this.map.addLayer(r,s),a.visibility===`visible`){let e=this._getLegendByName(t);this.addLegend(e,t)}}else{let i=t;this.map.addSource(i,{type:`vector`,url:w8.limitsUrl});let a={id:t,type:r,source:i,"source-layer":e,layout:n.layout,paint:n.paint||{}};r===`fill`||r===`polygon`?a.paint=o||{"fill-color":`#0000FF`,"fill-opacity":0}:r===`line`&&(a.paint=o||{"line-color":`#4832a8`,"line-opacity":1,"line-width":1}),this.map.addLayer(a,s)}}catch(e){console.error(`Error adding ICGC vector layer: ${e.message}`)}}async addFGBLayerICGC(e,t,n){try{n||(n.layout={visibility:!0},n.paint={"line-color":`#4832a8`,"line-opacity":1,"line-width":1},n.type=`lines`,n.layerPosition=`labels`);let r=this._dealOrderLayer(n.layerPosition),i=await fetch(e),a={type:`FeatureCollection`,features:[]};for await(let e of qe(i.body))a.features.push(e);let o=t;this.map.addSource(o,{type:`geojson`,data:a}),e.includes(`text`)?this.map.addLayer({id:t,type:`symbol`,source:o,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:n.layout.visibility,"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)`}},r):this.map.addLayer({id:t,type:n.type,source:o,layout:n.layout,paint:n.paint},r)}catch(e){console.error(`Error adding ICGC FGB layer: ${e.message}`)}}addTerrainICGC(e,t){try{let n;for(let t in S8)if(S8.hasOwnProperty(t)){let r=S8[t];r===e&&(n=r)}let r=n;this.getSource(`terrainICGC`)!==void 0&&(this.getStyle().layers.forEach(e=>{e.source===`terrainICGC`&&this.removeLayer(e.id)}),this.removeSource(`terrainICGC`)),this.getSource(`terrainICGC`)===void 0&&(e.includes(`terrarium`)?this.map.addSource(`terrainICGC`,{type:`raster-dem`,tiles:[r],tileSize:512,encoding:`terrarium`,maxzoom:16}):this.map.addSource(`terrainICGC`,{type:`raster-dem`,tiles:[r],tileSize:256,maxzoom:14,minzoom:7})),this.map.setTerrain({source:`terrainICGC`,exaggeration:1.5}),t==null||this.map.addControl(new V({pitch:90,bearing:null,minpitchzoom:null}),t)}catch(e){console.error(`Error adding 3D terrain: ${e.message}`)}}addLegend(e,t){try{this.map.addControl(new g4({url:e,idLayer:t}))}catch(e){console.error(`Error adding legend: ${e.message}`)}}_findImageType(e,t,n,r,i){let a=[t,n,r,i];for(let t of a)for(let[n,r]of Object.entries(t))if(r===e)return n;return null}_getKeyByUrlFGB(e){for(let t in C8.FGBAdmin)if(C8.FGBAdmin.hasOwnProperty(t)&&C8.FGBAdmin[t]===e)return t;return null}_getLegendByName(e){for(let t in w8.vectorLayers){let n=w8.vectorLayers[t];if(n.key===e)return n.legend}return null}_getKeyByUrlVector(e){for(let t in C8.Vector)if(C8.Vector.hasOwnProperty(t)&&C8.Vector[t]===e)return t;return null}async _raiseText3DStyle(){try{let e=await this.map.loadImage(w8.map3dOptions.imageIcon);this.map.hasImage(`stick`)||this.map.addImage(`stick`,e.data),this.map.getStyle().layers.forEach(t=>{if(t[`source-layer`]===w8.map3dOptions.sourceLayerFilterId&&t.minzoom>=w8.map3dOptions.minZoomFilter&&e){let e=t.id;this.map.setLayoutProperty(e,`icon-image`,`stick`),this.map.setLayoutProperty(e,`text-offset`,[0,-9]),this.map.setLayoutProperty(e,`symbol-placement`,`point`),this.map.setLayoutProperty(e,`symbol-avoid-edges`,!1),this.map.setLayoutProperty(e,`text-allow-overlap`,!0),this.map.setLayoutProperty(e,`text-ignore-placement`,!1),this.map.setLayoutProperty(e,`text-pitch-alignment`,`auto`),this.map.setLayoutProperty(e,`text-rotation-alignment`,`auto`),this.map.setLayoutProperty(e,`text-justify`,`center`),this.map.setLayoutProperty(e,`text-anchor`,`bottom`),this.map.setLayoutProperty(e,`icon-anchor`,`bottom`),this.map.setPaintProperty(e,`text-color`,`#ffffff`),this.map.setPaintProperty(e,`text-halo-color`,`#000000`),this.map.setPaintProperty(e,`text-halo-width`,2)}})}catch(e){return console.error(`Error dealing orto 3D: ${e.message}`),null}}_dealStyleMaps(e){try{if(e&&e.indexOf(`icgc.cat`)!=-1){for(let t in x8)if(x8.hasOwnProperty(t)){let n=x8[t];if(t===e)return n}return x8[0]}else return e}catch(e){return console.error(`Error dealing with map styles: ${e.message}`),null}}_dealOrto3dStyle(e){try{if(e==`orto3d`){this.map.setMaxZoom(18.8),this.map.easeTo({pitch:45});let e=new rv({intensity:4});this.map.getTerrain()&&this.map.setTerrain(null),this.map.setTerrain({source:w8.map3dOptions.terrainSource,exaggeration:w8.map3dOptions.exaggeration});let t=new vv({ambientLight:e});b8=new zD({interleaved:!0,layers:[this._createCitiesMapboxLayer(!1)],effects:[t],onAfterRender:()=>{try{let e=this.map.getZoom()>=w8.map3dOptions.minZoomRange;b8.setProps({layers:[this._createCitiesMapboxLayer(e)]})}catch{console.log(`No render 3D Mesh`)}}}),this.map.hasControl(b8)||(this.map.addControl(b8),this._raiseText3DStyle()),this.map.setSky({"sky-color":`#86bbd5`,"sky-horizon-blend":.3,"horizon-color":`#ffffff33`,"horizon-fog-blend":.1,"fog-ground-blend":.75,"fog-color":`#c5d6d6`}),this.map.on(`zoomend`,()=>{!this.map.getStyle().name==`orto3d`&&this.map.hasControl(b8)&&(this.map.removeControl(b8),b8.setProps({layers:[]}),this.map.setTerrain(null))})}else b8?.setProps({layers:[]}),this.map.hasControl(b8)&&(this.map.removeControl(b8),b8.setProps({layers:[]}),this.map.setTerrain(null))}catch(e){return console.error(`Error dealing orto 3D: ${e.message}`),null}}_dealOrderLayer(e){return e===y8?this._firstSymbolLayer():e===v8?this._firstLineLayer():``}_firstSymbolLayer(){try{let e=this.map.getStyle().layers,t;for(let n=0;n<e.length;n++)if(e[n].type===`symbol`&&e[n].id.indexOf(`contour`)===-1&&e[n].id.indexOf(`water`)===-1){t=e[n].id;break}return t}catch(e){console.error(`Error getting first symbol layer: ${e.message}`)}}_firstLineLayer(){try{let e=this.map.getStyle().layers,t;for(let n=0;n<e.length;n++)if(e[n].type===`line`){t=e[n].id;break}return t}catch(e){console.error(`Error getting first symbol layer: ${e.message}`)}}_createCitiesMapboxLayer(e=!1){try{return new Mz({id:w8.map3dOptions.layerId3d,data:w8.map3dOptions.urlTilesetCities,loader:Tz,beforeId:w8.map3dOptions.layerIdOrder,visible:e,loadOptions:{tileset:{viewDistanceScale:1,memoryAdjustedScreenSpaceError:w8.map3dOptions.spaceErrorFactor,updateTransforms:!0,adjustScreenSpaceError:w8.map3dOptions.spaceErrorFactor}},onTilesetLoad:e=>{e.adjustScreenSpaceError=w8.map3dOptions.spaceErrorFactor,e.memoryAdjustedScreenSpaceError=w8.map3dOptions.spaceErrorFactor},onTileLoad:e=>{e.content.cartographicOrigin.z-=w8.map3dOptions.zfactor},operation:`terrain+draw`,pickable:!1})}catch(e){return console.error(`Error adding MapboxOverlay: ${e.message}`),null}}},E8=c(((e,t)=>{function n(e,t){var n=e.getCenter(),r=e.getZoom(),i=e.getBearing(),a=e.getPitch();t.forEach(function(e){e.jumpTo({center:n,zoom:r,bearing:i,pitch:a})})}function r(){var e,t=arguments.length;if(t===1)e=arguments[0];else{e=[];for(var r=0;r<t;r++)e.push(arguments[r])}var i=[];e.forEach(function(t,n){i[n]=s.bind(null,t,e.filter(function(e,t){return t!==n}))});function a(){e.forEach(function(e,t){e.on(`move`,i[t])})}function o(){e.forEach(function(e,t){e.off(`move`,i[t])})}function s(e,t){o(),n(e,t),a()}return a(),function(){o(),i=[],e=[]}}t.exports=r})),D8=c(((e,t)=>{var n=typeof Reflect==`object`?Reflect:null,r=n&&typeof n.apply==`function`?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},i=n&&typeof n.ownKeys==`function`?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};function a(e){console&&console.warn&&console.warn(e)}var o=Number.isNaN||function(e){return e!==e};function s(){s.init.call(this)}t.exports=s,t.exports.once=y,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function l(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}Object.defineProperty(s,`defaultMaxListeners`,{enumerable:!0,get:function(){return c},set:function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received `+e+`.`);c=e}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e+`.`);return this._maxListeners=e,this};function u(e){return e._maxListeners===void 0?s.defaultMaxListeners:e._maxListeners}s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e===`error`,a=this._events;if(a!==void 0)i&&=a.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=Error(`Unhandled error.`+(o?` (`+o.message+`)`:``));throw s.context=o,s}var c=a[e];if(c===void 0)return!1;if(typeof c==`function`)r(c,this,t);else for(var l=c.length,u=g(c,l),n=0;n<l;++n)r(u[n],this,t);return!0};function d(e,t,n,r){var i,o,s;if(l(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit(`newListener`,t,n.listener?n.listener:n),o=e._events),s=o[t]),s===void 0)s=o[t]=n,++e._eventsCount;else if(typeof s==`function`?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),i=u(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var c=Error(`Possible EventEmitter memory leak detected. `+s.length+` `+String(t)+` listeners added. Use emitter.setMaxListeners() to increase limit`);c.name=`MaxListenersExceededWarning`,c.emitter=e,c.type=t,c.count=s.length,a(c)}return e}s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)};function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}s.prototype.once=function(e,t){return l(t),this.on(e,p(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,p(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,a,o;if(l(t),r=this._events,r===void 0||(n=r[e],n===void 0))return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():_(n,i),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit(`removeListener`,e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n=this._events,r;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!==`removeListener`&&this.removeAllListeners(a);return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t==`function`)this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function m(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i==`function`?n?[i.listener||i]:[i]:n?v(i):g(i,i.length)}s.prototype.listeners=function(e){return m(this,e,!0)},s.prototype.rawListeners=function(e){return m(this,e,!1)},s.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h;function h(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n==`function`)return 1;if(n!==void 0)return n.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function g(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function _(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function v(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function y(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){typeof e.removeListener==`function`&&e.removeListener(`error`,i),n([].slice.call(arguments))}x(e,t,a,{once:!0}),t!==`error`&&b(e,i,{once:!0})})}function b(e,t,n){typeof e.on==`function`&&x(e,`error`,t,n)}function x(e,t,n,r){if(typeof e.on==`function`)r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener==`function`)e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw TypeError(`The "emitter" argument must be of type EventEmitter. Received type `+typeof e)}})),O8=d(c(((e,t)=>{var n=E8(),r=D8().EventEmitter;function i(e,t,i,a){if(this.options=a||{},this._mapA=e,this._mapB=t,this._horizontal=this.options.orientation===`horizontal`,this._onDown=this._onDown.bind(this),this._onMove=this._onMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._ev=new r,this._swiper=document.createElement(`div`),this._swiper.className=this._horizontal?`compare-swiper-horizontal`:`compare-swiper-vertical`,this._controlContainer=document.createElement(`div`),this._controlContainer.className=this._horizontal?`maplibregl-compare maplibregl-compare-horizontal`:`maplibregl-compare`,this._controlContainer.className=this._controlContainer.className,this._controlContainer.appendChild(this._swiper),typeof i==`string`&&document.body.querySelectorAll){var o=document.body.querySelectorAll(i)[0];if(!o)throw Error(`Cannot find element with specified container selector.`);o.appendChild(this._controlContainer)}else if(i instanceof Element&&i.appendChild)i.appendChild(this._controlContainer);else throw Error(`Invalid container specified. Must be CSS selector or HTML element.`);this._bounds=t.getContainer().getBoundingClientRect();var s=(this._horizontal?this._bounds.height:this._bounds.width)/2;this._setPosition(s),this._clearSync=n(e,t),this._onResize=function(){this._bounds=t.getContainer().getBoundingClientRect(),this.currentPosition&&this._setPosition(this.currentPosition)}.bind(this),t.on(`resize`,this._onResize),this.options&&this.options.mousemove&&(e.getContainer().addEventListener(`mousemove`,this._onMove),t.getContainer().addEventListener(`mousemove`,this._onMove)),this._swiper.addEventListener(`mousedown`,this._onDown),this._swiper.addEventListener(`touchstart`,this._onDown)}i.prototype={_setPointerEvents:function(e){this._controlContainer.style.pointerEvents=e,this._swiper.style.pointerEvents=e},_onDown:function(e){e.touches?(document.addEventListener(`touchmove`,this._onMove),document.addEventListener(`touchend`,this._onTouchEnd)):(document.addEventListener(`mousemove`,this._onMove),document.addEventListener(`mouseup`,this._onMouseUp))},_setPosition:function(e){e=Math.min(e,this._horizontal?this._bounds.height:this._bounds.width);var t=this._horizontal?`translate(0, `+e+`px)`:`translate(`+e+`px, 0)`;this._controlContainer.style.transform=t,this._controlContainer.style.WebkitTransform=t;var n=this._horizontal?`rect(0, 999em, `+e+`px, 0)`:`rect(0, `+e+`px, `+this._bounds.height+`px, 0)`,r=this._horizontal?`rect(`+e+`px, 999em, `+this._bounds.height+`px,0)`:`rect(0, 999em, `+this._bounds.height+`px,`+e+`px)`;this._mapA.getContainer().style.clip=n,this._mapB.getContainer().style.clip=r,this.currentPosition=e},_onMove:function(e){this.options&&this.options.mousemove&&this._setPointerEvents(e.touches?`auto`:`none`),this._horizontal?this._setPosition(this._getY(e)):this._setPosition(this._getX(e))},_onMouseUp:function(){document.removeEventListener(`mousemove`,this._onMove),document.removeEventListener(`mouseup`,this._onMouseUp),this.fire(`slideend`,{currentPosition:this.currentPosition})},_onTouchEnd:function(){document.removeEventListener(`touchmove`,this._onMove),document.removeEventListener(`touchend`,this._onTouchEnd),this.fire(`slideend`,{currentPosition:this.currentPosition})},_getX:function(e){e=e.touches?e.touches[0]:e;var t=e.clientX-this._bounds.left;return t<0&&(t=0),t>this._bounds.width&&(t=this._bounds.width),t},_getY:function(e){e=e.touches?e.touches[0]:e;var t=e.clientY-this._bounds.top;return t<0&&(t=0),t>this._bounds.height&&(t=this._bounds.height),t},setSlider:function(e){this._setPosition(e)},on:function(e,t){return this._ev.on(e,t),this},fire:function(e,t){return this._ev.emit(e,t),this},off:function(e,t){return this._ev.removeListener(e,t),this},remove:function(){this._clearSync(),this._mapB.off(`resize`,this._onResize);var e=this._mapA.getContainer();e&&(e.style.clip=null,e.removeEventListener(`mousemove`,this._onMove));var t=this._mapB.getContainer();t&&(t.style.clip=null,t.removeEventListener(`mousemove`,this._onMove)),this._swiper.removeEventListener(`mousedown`,this._onDown),this._swiper.removeEventListener(`touchstart`,this._onDown),this._controlContainer.remove()}},window.maplibregl?maplibregl.Compare=i:t!==void 0&&(t.exports=i)}))());e.CompareMaps=class{constructor(e,t,n,r){let i=this;setTimeout(function(){i.mapCompare=new O8.default(e.map,t.map,n,{})},1e3)}},e.Config=g8,e.Map=T8});
|
package/dist/mapicgc-gl.mjs
CHANGED
|
@@ -86343,7 +86343,10 @@ var cK = "https://eines.icgc.cat/recursos/mapicgc-gl-js/mapicgc-config.json", lK
|
|
|
86343
86343
|
});
|
|
86344
86344
|
})) : this.map = new P.default.Map(e);
|
|
86345
86345
|
this.map.on("load", () => {
|
|
86346
|
-
if (this.addAttributionControl(),
|
|
86346
|
+
if (this.addAttributionControl(), setTimeout(() => {
|
|
86347
|
+
let e = document.querySelector(".maplibregl-ctrl-attrib-button");
|
|
86348
|
+
e && e.click();
|
|
86349
|
+
}, 1e3), !n && !t) {
|
|
86347
86350
|
let t = this.map.getStyle().name, n = e.style;
|
|
86348
86351
|
this.map.addControl(new lU({
|
|
86349
86352
|
color: n.indexOf("orto") === -1,
|
|
@@ -87519,8 +87522,11 @@ var cK = "https://eines.icgc.cat/recursos/mapicgc-gl-js/mapicgc-config.json", lK
|
|
|
87519
87522
|
}
|
|
87520
87523
|
addAttributionControl(e, t) {
|
|
87521
87524
|
try {
|
|
87522
|
-
let n = "<a style=\"font-weight: bold; color: #D97634;\" href=\"https://www.icgc.cat/Eines-i-visors/Recursos-desenvolupadors/Biblioteca-MapICGC-GL-JS/\" target=\"_blank\">Fet amb MapICGC</a>", r = Object.assign({}, { compact: !0 }, e);
|
|
87523
|
-
r.customAttribution ? Array.isArray(r.customAttribution) ? r.customAttribution.includes(n) || (r.customAttribution = [n, ...r.customAttribution]) : r.customAttribution !== n && (r.customAttribution = [n, r.customAttribution]) : r.customAttribution = n, this.map.addControl(new P.default.AttributionControl(r), t)
|
|
87525
|
+
let n = "<a style=\"font-weight: bold; color: #D97634;\" href=\"https://www.icgc.cat/Eines-i-visors/Recursos-desenvolupadors/Biblioteca-MapICGC-GL-JS/\" target=\"_blank\">Fet amb MapICGC</a>", r = Object.assign({}, { compact: !0 }, e), i = r.autoCollapseDelay;
|
|
87526
|
+
delete r.autoCollapseDelay, r.customAttribution ? Array.isArray(r.customAttribution) ? r.customAttribution.includes(n) || (r.customAttribution = [n, ...r.customAttribution]) : r.customAttribution !== n && (r.customAttribution = [n, r.customAttribution]) : r.customAttribution = n, this.map.addControl(new P.default.AttributionControl(r), t), i && typeof i == "number" && i > 0 && setTimeout(() => {
|
|
87527
|
+
let e = document.querySelector(".maplibregl-ctrl-attrib-button");
|
|
87528
|
+
e && e.getAttribute("aria-pressed") === "true" && e.click();
|
|
87529
|
+
}, i);
|
|
87524
87530
|
} catch (e) {
|
|
87525
87531
|
console.error(`Error adding attribution control: ${e.message}`);
|
|
87526
87532
|
}
|
|
@@ -87748,14 +87754,16 @@ var cK = "https://eines.icgc.cat/recursos/mapicgc-gl-js/mapicgc-config.json", lK
|
|
|
87748
87754
|
try {
|
|
87749
87755
|
if (e == "orto3d") {
|
|
87750
87756
|
this.map.setMaxZoom(18.8), this.map.easeTo({ pitch: 45 });
|
|
87751
|
-
let e = new
|
|
87752
|
-
this.map.setTerrain({
|
|
87757
|
+
let e = new oh({ intensity: 4 });
|
|
87758
|
+
this.map.getTerrain() && this.map.setTerrain(null), this.map.setTerrain({
|
|
87753
87759
|
source: vK.map3dOptions.terrainSource,
|
|
87754
87760
|
exaggeration: vK.map3dOptions.exaggeration
|
|
87755
|
-
})
|
|
87761
|
+
});
|
|
87762
|
+
let t = new xh({ ambientLight: e });
|
|
87763
|
+
mK = new nx({
|
|
87756
87764
|
interleaved: !0,
|
|
87757
87765
|
layers: [this._createCitiesMapboxLayer(!1)],
|
|
87758
|
-
effects: [
|
|
87766
|
+
effects: [t],
|
|
87759
87767
|
onAfterRender: () => {
|
|
87760
87768
|
try {
|
|
87761
87769
|
let e = this.map.getZoom() >= vK.map3dOptions.minZoomRange;
|
package/package.json
CHANGED
package/src/map/Map.js
CHANGED
|
@@ -179,6 +179,12 @@ export default class Map {
|
|
|
179
179
|
|
|
180
180
|
this.map.on("load", () => {
|
|
181
181
|
this.addAttributionControl()
|
|
182
|
+
setTimeout(() => {
|
|
183
|
+
const attribBtn = document.querySelector('.maplibregl-ctrl-attrib-button');
|
|
184
|
+
if (attribBtn) {
|
|
185
|
+
attribBtn.click();
|
|
186
|
+
}
|
|
187
|
+
}, 1000);
|
|
182
188
|
if (!isRaster && !isRelief) {
|
|
183
189
|
const nameStyle = this.map.getStyle().name;
|
|
184
190
|
const urlName = options.style;
|
|
@@ -2853,6 +2859,7 @@ export default class Map {
|
|
|
2853
2859
|
* @param {Object} [options] - Options for the attribution control.
|
|
2854
2860
|
* @param {boolean} [options.compact=true] - If true, the attribution control will be compact.
|
|
2855
2861
|
* @param {string|string[]} [options.customAttribution] - Additional custom attribution(s) to display alongside "Fet amb MapICGC".
|
|
2862
|
+
* @param {number} [options.autoCollapseDelay] - If set, the attribution will auto-collapse after this many milliseconds. E.g., 3000 for 3 seconds.
|
|
2856
2863
|
* @param {string} [position='bottom-right'] - Position to add the control on the map.
|
|
2857
2864
|
* @example
|
|
2858
2865
|
* // Default usage: shows "Fet amb MapICGC" with compact mode
|
|
@@ -2863,11 +2870,18 @@ export default class Map {
|
|
|
2863
2870
|
*
|
|
2864
2871
|
* // With multiple custom attributions
|
|
2865
2872
|
* map.addAttributionControl({ customAttribution: ['© Projecte A', '© Projecte B'] });
|
|
2873
|
+
*
|
|
2874
|
+
* // With auto-collapse after 3 seconds
|
|
2875
|
+
* map.addAttributionControl({ autoCollapseDelay: 3000 });
|
|
2866
2876
|
*/
|
|
2867
2877
|
addAttributionControl(options, position) {
|
|
2868
2878
|
try {
|
|
2869
2879
|
const mapicgcAttribution = '<a style="font-weight: bold; color: #D97634;" href="https://www.icgc.cat/Eines-i-visors/Recursos-desenvolupadors/Biblioteca-MapICGC-GL-JS/" target="_blank">Fet amb MapICGC</a>';
|
|
2870
2880
|
const mergedOptions = Object.assign({}, { compact: true }, options);
|
|
2881
|
+
const autoCollapseDelay = mergedOptions.autoCollapseDelay;
|
|
2882
|
+
|
|
2883
|
+
// Remove autoCollapseDelay from options before passing to AttributionControl
|
|
2884
|
+
delete mergedOptions.autoCollapseDelay;
|
|
2871
2885
|
|
|
2872
2886
|
if (mergedOptions.customAttribution) {
|
|
2873
2887
|
if (Array.isArray(mergedOptions.customAttribution)) {
|
|
@@ -2884,6 +2898,16 @@ export default class Map {
|
|
|
2884
2898
|
}
|
|
2885
2899
|
|
|
2886
2900
|
this.map.addControl(new maplibregl.AttributionControl(mergedOptions), position);
|
|
2901
|
+
|
|
2902
|
+
// Auto-collapse after specified delay if autoCollapseDelay is set
|
|
2903
|
+
if (autoCollapseDelay && typeof autoCollapseDelay === 'number' && autoCollapseDelay > 0) {
|
|
2904
|
+
setTimeout(() => {
|
|
2905
|
+
const attributionButton = document.querySelector('.maplibregl-ctrl-attrib-button');
|
|
2906
|
+
if (attributionButton && attributionButton.getAttribute('aria-pressed') === 'true') {
|
|
2907
|
+
attributionButton.click();
|
|
2908
|
+
}
|
|
2909
|
+
}, autoCollapseDelay);
|
|
2910
|
+
}
|
|
2887
2911
|
} catch (error) {
|
|
2888
2912
|
console.error(`Error adding attribution control: ${error.message}`);
|
|
2889
2913
|
}
|
|
@@ -3348,14 +3372,19 @@ export default class Map {
|
|
|
3348
3372
|
const ambientLight = new AmbientLight({
|
|
3349
3373
|
intensity: 4,
|
|
3350
3374
|
});
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
});
|
|
3375
|
+
|
|
3376
|
+
if (this.map.getTerrain()) this.map.setTerrain(null);
|
|
3354
3377
|
this.map.setTerrain({
|
|
3355
3378
|
source: defaultOptions.map3dOptions.terrainSource,
|
|
3356
3379
|
exaggeration: defaultOptions.map3dOptions.exaggeration,
|
|
3357
3380
|
});
|
|
3358
3381
|
|
|
3382
|
+
const lightingEffect = new LightingEffect({
|
|
3383
|
+
ambientLight,
|
|
3384
|
+
});
|
|
3385
|
+
|
|
3386
|
+
|
|
3387
|
+
|
|
3359
3388
|
citiesMapboxLayer = new MapboxOverlay({
|
|
3360
3389
|
interleaved: true,
|
|
3361
3390
|
layers: [this._createCitiesMapboxLayer(false)], // Inicialment invisible
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<title>Exemple mapicgc-gl-js: Afegir mapa base ICGC</title>
|
|
6
6
|
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
|
|
7
7
|
|
|
8
|
-
<script src="../../dist/mapicgc-gl.
|
|
8
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
9
9
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
10
10
|
|
|
11
11
|
<style>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<title>Exemple mapicgc-gl-js: Afegir comparador</title>
|
|
6
6
|
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.
|
|
7
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
8
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
9
|
|
|
10
10
|
<style>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>test mapicgc-gl-js</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.
|
|
7
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
8
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
9
|
|
|
10
10
|
<style>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>test mapicgc-gl-js</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.
|
|
7
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
8
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
9
|
|
|
10
10
|
<style>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<meta charset='utf-8' />
|
|
4
4
|
<title>addGeocoderICGC.html</title>
|
|
5
5
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
6
|
-
<script src="../../dist/mapicgc-gl.
|
|
6
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
7
7
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
8
8
|
<style>
|
|
9
9
|
body {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<meta charset='utf-8' />
|
|
4
4
|
<title>addICGCTerrain.html</title>
|
|
5
5
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
6
|
-
<script src="../../dist/mapicgc-gl.
|
|
6
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
7
7
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
8
8
|
<style>
|
|
9
9
|
body {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<meta charset='utf-8' />
|
|
4
4
|
<title>addICGCTerrain.html</title>
|
|
5
5
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
6
|
-
<script src="../../dist/mapicgc-gl.
|
|
6
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
7
7
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
8
8
|
<style>
|
|
9
9
|
body {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>test mapicgc-gl-js</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.
|
|
7
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
8
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
9
|
<style>
|
|
10
10
|
body {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>addLayerGeojson.html</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.
|
|
7
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
8
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
9
|
<style>
|
|
10
10
|
body {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>addLayerTree</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.
|
|
7
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
8
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
9
|
<style>
|
|
10
10
|
body {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<meta charset='utf-8' />
|
|
4
4
|
<title>addLogo</title>
|
|
5
5
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
6
|
-
<script src="../../dist/mapicgc-gl.
|
|
6
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
7
7
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
8
8
|
<style>
|
|
9
9
|
body {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>addMapStyle</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.
|
|
7
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
8
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
9
|
<style>
|
|
10
10
|
body {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<meta charset='utf-8' />
|
|
4
4
|
<title>addMarker</title>
|
|
5
5
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
6
|
-
<script src="../../dist/mapicgc-gl.
|
|
6
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
7
7
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
8
8
|
<style>
|
|
9
9
|
body {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<meta charset='utf-8' />
|
|
4
4
|
<title>addMouseCoordinateControl</title>
|
|
5
5
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
6
|
-
<script src="../../dist/mapicgc-gl.
|
|
6
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
7
7
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
8
8
|
<style>
|
|
9
9
|
body {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>addICGCTerrain.html</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.
|
|
7
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
8
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
9
|
<style>
|
|
10
10
|
body {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>addVectorLayerICGC</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.
|
|
7
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
8
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
9
|
<style>
|
|
10
10
|
body {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>advancedExemple</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.
|
|
7
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
8
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
9
|
<style>
|
|
10
10
|
body {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>fetchData</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.
|
|
7
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
8
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
9
|
<style>
|
|
10
10
|
body {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<meta charset='utf-8' />
|
|
4
4
|
<title>test mapicgc-gl-js</title>
|
|
5
5
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
6
|
-
<script src="../../dist/mapicgc-gl.
|
|
6
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
7
7
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
8
8
|
<style>
|
|
9
9
|
body {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset='utf-8' />
|
|
5
5
|
<title>styleOrto3D</title>
|
|
6
6
|
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
|
|
7
|
-
<script src="../../dist/mapicgc-gl.
|
|
7
|
+
<script src="../../dist/mapicgc-gl.js"></script>
|
|
8
8
|
<link href="../../dist/mapicgc-gl.css" rel="stylesheet" />
|
|
9
9
|
<style>
|
|
10
10
|
body {
|