From eeb22e942945b89e0ae4869302f7825b446c370a Mon Sep 17 00:00:00 2001 From: Marcrb3 Date: Wed, 5 Jun 2024 10:25:56 +0200 Subject: [PATCH] update init --- dist/assets/index-CRQUOndl.js | 4 ++++ dist/assets/index-DlEL5neL.js | 1 - dist/index.html | 2 +- index.html | 4 ++-- src/main.js | 23 +++++++++++++++++++++-- 5 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 dist/assets/index-CRQUOndl.js delete mode 100644 dist/assets/index-DlEL5neL.js diff --git a/dist/assets/index-CRQUOndl.js b/dist/assets/index-CRQUOndl.js new file mode 100644 index 0000000..ad077cc --- /dev/null +++ b/dist/assets/index-CRQUOndl.js @@ -0,0 +1,4 @@ +(function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))n(e);new MutationObserver(e=>{for(const s of e)if(s.type==="childList")for(const i of s.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&n(i)}).observe(document,{childList:!0,subtree:!0});function r(e){const s={};return e.integrity&&(s.integrity=e.integrity),e.referrerPolicy&&(s.referrerPolicy=e.referrerPolicy),e.crossOrigin==="use-credentials"?s.credentials="include":e.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(e){if(e.ep)return;e.ep=!0;const s=r(e);fetch(e.href,s)}})();var t,y;let v="all",m="fosc",u;async function h(){m=document.getElementById("serveiSelector2").value,m==="orto"?t.setStyle("https://geoserveis.icgc.cat/contextmaps/icgc_orto_estandard.json"):m==="topo"?t.setStyle("https://geoserveis.icgc.cat/contextmaps/icgc_mapa_estandard_general.json"):m==="fosc"&&t.setStyle("https://geoserveis.icgc.cat/contextmaps/icgc_mapa_base_fosc.json")}async function L(a,l,r){t.getLayer("clicked-layer")&&t.removeLayer("clicked-layer"),t.getSource("clicked-layer")&&t.removeSource("clicked-layer"),g(),P();const e=await(await fetch(`https://api.icgc.cat/territori/${r}/geo/${l}/${a}`)).json();u=e[0].features;const s=document.getElementById("infoPanelContent");s.innerHTML="";let i=[],p=null,f=null;if(e[0].features.length<4)document.getElementById("infoPanelContent").innerHTML="No hi ha dades sobre el punt seleccionat.";else{for(let o=0;oAdreça: ${p.etiqueta}
`),f&&(s.innerHTML+=`Elevació: ${f} metres

`);for(let o=0;o{b(d,c)}),s.appendChild(c),s.appendChild(document.createElement("br"))}}C()}function b(a,l){console.log("Afegim geometria per al servei:",a),t.getLayer("clicked-layer")&&t.removeLayer("clicked-layer"),t.getSource("clicked-layer")&&t.removeSource("clicked-layer");let r=new maplibregl.LngLatBounds;for(let n=0;n{r.extend(o)}):e.type==="MultiPolygon"&&e.coordinates.forEach(o=>{o[0].forEach(d=>{r.extend(d)})}),document.querySelectorAll(".layer-properties").forEach(o=>o.remove());const i=document.createElement("div");i.classList.add("layer-properties");const p=u[n].properties;for(const[o,d]of Object.entries(p)){const c=document.createElement("div");c.textContent=`${o}: ${d}`,i.appendChild(c)}l.parentNode.insertBefore(i,l.nextSibling),document.querySelectorAll(".myButtonClass").forEach(o=>o.classList.remove("highlighted-button")),l.classList.add("highlighted-button")}t.fitBounds(r,{padding:200})}async function E(a){const r=await(await fetch(`https://api.icgc.cat/territori/adress/${a}`)).json();r.features?(t.getLayer("punts2")?(t.removeLayer("punts2").removeSource("punts2"),t.addSource("punts2",{type:"geojson",data:{type:"FeatureCollection",features:r.features}}),t.addLayer({id:"punts2",type:"circle",source:"punts2",paint:{"circle-color":"red","circle-opacity":.8,"circle-radius":6}})):(t.addSource("punts2",{type:"geojson",data:{type:"FeatureCollection",features:r.features}}),t.addLayer({id:"punts2",type:"circle",source:"punts2",paint:{"circle-color":"red","circle-opacity":.8,"circle-radius":6}})),t.flyTo({center:[r.features[0].geometry.coordinates[0],r.features[0].geometry.coordinates[1]],zoom:11,essential:!0})):alert(r);const n=new maplibregl.Popup({closeButton:!1,closeOnClick:!1});t.getLayer("punts2")&&(t.on("mouseenter","punts2",function(e){t.getCanvas().style.cursor="pointer",n.setLngLat(e.features[0].geometry.coordinates).setHTML(`Adreça: ${e.features[0].properties.etiqueta}
+ Carrer: ${e.features[0].properties.street}
+ Municipi: ${e.features[0].properties.mun}
+ Codi Postal: ${e.features[0].properties.postalcode}
`).addTo(t)}),t.on("mouseleave","punts2",function(e){t.getCanvas().style.cursor="",n.remove()}))}function B(){t=new maplibregl.Map({container:"map",style:"https://geoserveis.icgc.cat/contextmaps/icgc_mapa_base_fosc.json",center:[2.0042,41.7747],zoom:7,attributionControl:!1,hash:!1}),t.addControl(new maplibregl.NavigationControl,"top-right");var a=new maplibregl.FullscreenControl;t.addControl(a,"top-right"),t.on("click",function(l){let r=l.lngLat.lng,n=l.lngLat.lat;L(n,r,v),y?(y.remove(),y=new maplibregl.Marker({color:"#FF6E42"}).setLngLat([r,n]).addTo(t)):y=new maplibregl.Marker({color:"#FF6E42"}).setLngLat([r,n]).addTo(t)})}function P(){document.getElementById("loader").style.display="block",document.getElementById("infoPanelContent").style.display="none"}function C(){document.getElementById("loader").style.display="none",document.getElementById("infoPanelContent").style.display="block"}function g(){var a=document.getElementById("infoPanel");a.classList.add("open"),a.style.width="400px",document.getElementById("openPanel").style.display="none"}function S(){var a=document.getElementById("infoPanel");a.classList.remove("open"),a.style.width="0px",document.getElementById("openPanel").style.display="block"}function k(){B(),document.getElementById("serveiSelector2").addEventListener("change",h),document.getElementById("openPanel").addEventListener("click",g),document.getElementById("closePanel").addEventListener("click",S);const n=document.getElementById("textSelector");n.addEventListener("change",()=>{const e=n.value;E(e)})}window.addEventListener("DOMContentLoaded",k); diff --git a/dist/assets/index-DlEL5neL.js b/dist/assets/index-DlEL5neL.js deleted file mode 100644 index dd40107..0000000 --- a/dist/assets/index-DlEL5neL.js +++ /dev/null @@ -1 +0,0 @@ -(function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))n(e);new MutationObserver(e=>{for(const o of e)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&n(l)}).observe(document,{childList:!0,subtree:!0});function a(e){const o={};return e.integrity&&(o.integrity=e.integrity),e.referrerPolicy&&(o.referrerPolicy=e.referrerPolicy),e.crossOrigin==="use-credentials"?o.credentials="include":e.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(e){if(e.ep)return;e.ep=!0;const o=a(e);fetch(e.href,o)}})();var r,y;let m="all",u;async function g(s,i,a){r.getLayer("clicked-layer")&&r.removeLayer("clicked-layer"),r.getSource("clicked-layer")&&r.removeSource("clicked-layer"),E(),v();const e=await(await fetch(`https://api.icgc.cat/territori/${a}/geo/${i}/${s}`)).json();u=e[0].features;const o=document.getElementById("infoPanelContent");o.innerHTML="";let l=[],f=null,p=null;if(e[0].features.length<4)document.getElementById("infoPanelContent").innerHTML="No hi ha dades sobre el punt seleccionat.";else{for(let t=0;tAdreça: ${f.etiqueta}
`),p&&(o.innerHTML+=`Elevació: ${p} metres

`);for(let t=0;t{h(d,c)}),o.appendChild(c),o.appendChild(document.createElement("br"))}}b()}function h(s,i){console.log("Afegim geometria per al servei:",s),r.getLayer("clicked-layer")&&r.removeLayer("clicked-layer"),r.getSource("clicked-layer")&&r.removeSource("clicked-layer");let a=new maplibregl.LngLatBounds;for(let n=0;n{a.extend(t)}):e.type==="MultiPolygon"&&e.coordinates.forEach(t=>{t[0].forEach(d=>{a.extend(d)})}),document.querySelectorAll(".layer-properties").forEach(t=>t.remove());const l=document.createElement("div");l.classList.add("layer-properties");const f=u[n].properties;for(const[t,d]of Object.entries(f)){const c=document.createElement("div");c.textContent=`${t}: ${d}`,l.appendChild(c)}i.parentNode.insertBefore(l,i.nextSibling),document.querySelectorAll(".myButtonClass").forEach(t=>t.classList.remove("highlighted-button")),i.classList.add("highlighted-button")}r.fitBounds(a,{padding:200})}function L(){r=new maplibregl.Map({container:"map",style:"https://geoserveis.icgc.cat/contextmaps/icgc_mapa_base_fosc.json",center:[2.0042,41.7747],zoom:7,attributionControl:!1,hash:!1}),r.addControl(new maplibregl.NavigationControl,"top-right");var s=new maplibregl.FullscreenControl;r.addControl(s,"top-right"),r.on("click",function(i){let a=i.lngLat.lng,n=i.lngLat.lat;g(n,a,m),y?(y.remove(),y=new maplibregl.Marker({color:"#FF6E42"}).setLngLat([a,n]).addTo(r)):y=new maplibregl.Marker({color:"#FF6E42"}).setLngLat([a,n]).addTo(r)})}function v(){document.getElementById("loader").style.display="block",document.getElementById("infoPanelContent").style.display="none"}function b(){document.getElementById("loader").style.display="none",document.getElementById("infoPanelContent").style.display="block"}function E(){var s=document.getElementById("infoPanel");s.classList.add("open"),s.style.width="400px",document.getElementById("openPanel").style.display="none"}L(); diff --git a/dist/index.html b/dist/index.html index f4ad6fe..372ddb2 100644 --- a/dist/index.html +++ b/dist/index.html @@ -259,7 +259,7 @@ } - + diff --git a/index.html b/index.html index 6b9c7d4..5d45cc3 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,7 @@ - + Visor Territorial