From bccc0e35c6147a726c59ef4c187251b562a9b889 Mon Sep 17 00:00:00 2001 From: Marcrb3 Date: Fri, 14 Jun 2024 13:47:26 +0200 Subject: [PATCH] change default baselayer --- dist/assets/{index-B2z3WzQw.js => index-Dzs1S6jP.js} | 2 +- dist/index.html | 6 +++--- index.html | 4 ++-- src/main.js | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) rename dist/assets/{index-B2z3WzQw.js => index-Dzs1S6jP.js} (67%) diff --git a/dist/assets/index-B2z3WzQw.js b/dist/assets/index-Dzs1S6jP.js similarity index 67% rename from dist/assets/index-B2z3WzQw.js rename to dist/assets/index-Dzs1S6jP.js index 34c40f3..e6c867c 100644 --- a/dist/assets/index-B2z3WzQw.js +++ b/dist/assets/index-Dzs1S6jP.js @@ -1,4 +1,4 @@ -(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const t of document.querySelectorAll('link[rel="modulepreload"]'))i(t);new MutationObserver(t=>{for(const n of t)if(n.type==="childList")for(const l of n.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&i(l)}).observe(document,{childList:!0,subtree:!0});function r(t){const n={};return t.integrity&&(n.integrity=t.integrity),t.referrerPolicy&&(n.referrerPolicy=t.referrerPolicy),t.crossOrigin==="use-credentials"?n.credentials="include":t.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(t){if(t.ep)return;t.ep=!0;const n=r(t);fetch(t.href,n)}})();var e,b;let E="all",u,f=null;const k={top:5,bottom:window.innerHeight*.5},M={top:100,bottom:100,left:300,right:50};async function I(){const o=S(e.getStyle().layers),r=document.getElementById("serveiSelector2").value;let i=null;if(e.getLayer("clicked-layer")){const n=e.getSource("clicked-layer");n&&n._data&&(i=n._data)}let t;r==="orto"?t="https://geoserveis.icgc.cat/contextmaps/icgc_orto_estandard.json":r==="topo"?t="https://geoserveis.icgc.cat/contextmaps/icgc_mapa_estandard_general.json":r==="fosc"&&(t="https://geoserveis.icgc.cat/contextmaps/icgc_mapa_base_fosc.json"),e.setStyle(t),e.once("styledata",()=>{i&&(e.getSource("clicked-layer")||e.addSource("clicked-layer",{type:"geojson",data:i}),e.getLayer("clicked-layer")||e.addLayer({id:"clicked-layer",type:"fill",source:"clicked-layer",layout:{},paint:{"fill-color":"#f9f91d","fill-outline-color":"#f9f91d","fill-opacity":.5}},o)),w().then(function(){x()})})}async function w(){e.getSource("terrainMapZen")||e.addSource("terrainMapZen",{type:"raster-dem",url:"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png",tileSize:512,maxzoom:14})}function x(){try{e.setTerrain({source:"terrainMapZen",exaggeration:1.5})}catch(o){console.log("ERROR addTerrain"),console.log(o)}}function L(){e.getLayer("clicked-layer")&&e.removeLayer("clicked-layer"),e.getSource("clicked-layer")&&e.removeSource("clicked-layer")}function T(o){const a=S(e.getStyle().layers);e.getLayer("hovered-layer")&&e.removeLayer("hovered-layer"),e.getSource("hovered-layer")&&e.removeSource("hovered-layer");let r=new maplibregl.LngLatBounds;for(let i=0;i{r.extend(n)}):t.type==="MultiPolygon"&&t.coordinates.forEach(n=>{n[0].forEach(l=>{r.extend(l)})})}}function _(){e.getLayer("hovered-layer")&&e.removeLayer("hovered-layer"),e.getSource("hovered-layer")&&e.removeSource("hovered-layer")}async function B(o,a,r){P(),F();const t=await(await fetch(`https://api.icgc.cat/territori/${r}/geo/${a}/${o}`)).json();u=t[0].features;const n=document.getElementById("infoPanelContent");n.innerHTML="";let l=[],d=null,m=null;if(t[0].features.length<4)document.getElementById("infoPanelContent").innerHTML="No hi ha dades sobre el punt seleccionat.";else{for(let s=0;sAdreça: ${d.etiqueta}
`),m&&(n.innerHTML+=`Coordenades: ${o.toFixed(4)}, ${a.toFixed(4)}
`,n.innerHTML+=`Elevació: ${m} metres

`);for(let s=0;s{f=c,h(c,p)}),p.addEventListener("mouseover",()=>{T(c)}),p.addEventListener("mouseout",()=>{_()}),n.appendChild(p),n.appendChild(document.createElement("br"))}l.length>0&&!f?setTimeout(()=>{f=l[0],h(f,n.querySelector(".myButtonClass"))},0):f&&document.querySelectorAll(".myButtonClass").forEach(c=>{c.textContent.includes(f)&&h(f,c)})}H()}function h(o,a){const r=S(e.getStyle().layers);L();const i=document.querySelector(".closeButtonClass");i&&i.parentNode.removeChild(i);let t=new maplibregl.LngLatBounds;for(let d=0;d{t.extend(y)}):m.type==="MultiPolygon"&&m.coordinates.forEach(y=>{y[0].forEach(v=>{t.extend(v)})}),document.querySelectorAll(".layer-properties").forEach(y=>y.remove());const c=document.createElement("div");c.classList.add("layer-properties");const p=u[d].properties;for(const[y,v]of Object.entries(p)){const C=document.createElement("div");C.textContent=`${y}: ${v}`,c.appendChild(C)}const g=document.createElement("button");g.textContent="×",g.classList.add("closeButtonClass"),g.addEventListener("click",()=>{L(),c.remove(),g.remove(),a.classList.remove("highlighted-button")}),c.appendChild(g),a.parentNode.insertBefore(c,a.nextSibling),a.parentNode.insertBefore(g,a.nextSibling),document.querySelectorAll(".myButtonClass").forEach(y=>y.classList.remove("highlighted-button")),a.classList.add("highlighted-button")}const l=window.innerWidth<750?k:M;e.fitBounds(t,{padding:l})}function $(){e=new maplibregl.Map({container:"map",style:"https://geoserveis.icgc.cat/contextmaps/icgc_mapa_base_fosc.json",center:[2.0042,41.7747],zoom:7,maxZoom:18,attributionControl:!1,hash:!1}),e.on("load",function(){w().then(function(){x()}),e.addControl(new maplibregl.NavigationControl,"top-right");var o=new maplibregl.FullscreenControl;e.addControl(o,"top-right"),e.addControl(new maplibregl.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!1}),"top-right"),e.on("click",function(a){var r=document.getElementById("notification");r&&r.classList.remove("show");let i=a.lngLat.lng,t=a.lngLat.lat;f?(L(),B(t,i,E).then(()=>{h(f,document.querySelector(".myButtonClass.highlighted-button"))})):B(t,i,E),b?b.setLngLat([i,t]):b=new maplibregl.Marker({color:"#FF6E42"}).setLngLat([i,t]).addTo(e)})})}function S(o){let a="background";for(var r=0;r${t.features[0].properties.etiqueta}
+(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const t of document.querySelectorAll('link[rel="modulepreload"]'))i(t);new MutationObserver(t=>{for(const n of t)if(n.type==="childList")for(const l of n.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&i(l)}).observe(document,{childList:!0,subtree:!0});function r(t){const n={};return t.integrity&&(n.integrity=t.integrity),t.referrerPolicy&&(n.referrerPolicy=t.referrerPolicy),t.crossOrigin==="use-credentials"?n.credentials="include":t.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(t){if(t.ep)return;t.ep=!0;const n=r(t);fetch(t.href,n)}})();var e,L;let E="all",u,f=null;const k={top:5,bottom:window.innerHeight*.5},M={top:100,bottom:100,left:300,right:50};async function I(){const o=S(e.getStyle().layers),r=document.getElementById("serveiSelector2").value;let i=null;if(e.getLayer("clicked-layer")){const n=e.getSource("clicked-layer");n&&n._data&&(i=n._data)}let t;r==="orto"?t="https://geoserveis.icgc.cat/contextmaps/icgc_orto_estandard.json":r==="topo"?t="https://geoserveis.icgc.cat/contextmaps/icgc_mapa_estandard_general.json":r==="fosc"&&(t="https://geoserveis.icgc.cat/contextmaps/icgc_mapa_base_fosc.json"),e.setStyle(t),e.once("styledata",()=>{i&&(e.getSource("clicked-layer")||e.addSource("clicked-layer",{type:"geojson",data:i}),e.getLayer("clicked-layer")||e.addLayer({id:"clicked-layer",type:"fill",source:"clicked-layer",layout:{},paint:{"fill-color":"#f9f91d","fill-outline-color":"#f9f91d","fill-opacity":.5}},o)),w().then(function(){x()})})}async function w(){e.getSource("terrainMapZen")||e.addSource("terrainMapZen",{type:"raster-dem",url:"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png",tileSize:512,maxzoom:14})}function x(){try{e.setTerrain({source:"terrainMapZen",exaggeration:1.5})}catch(o){console.log("ERROR addTerrain"),console.log(o)}}function b(){e.getLayer("clicked-layer")&&e.removeLayer("clicked-layer"),e.getSource("clicked-layer")&&e.removeSource("clicked-layer")}function T(o){const a=S(e.getStyle().layers);e.getLayer("hovered-layer")&&e.removeLayer("hovered-layer"),e.getSource("hovered-layer")&&e.removeSource("hovered-layer");let r=new maplibregl.LngLatBounds;for(let i=0;i{r.extend(n)}):t.type==="MultiPolygon"&&t.coordinates.forEach(n=>{n[0].forEach(l=>{r.extend(l)})})}}function _(){e.getLayer("hovered-layer")&&e.removeLayer("hovered-layer"),e.getSource("hovered-layer")&&e.removeSource("hovered-layer")}async function B(o,a,r){P(),F();const t=await(await fetch(`https://api.icgc.cat/territori/${r}/geo/${a}/${o}`)).json();u=t[0].features;const n=document.getElementById("infoPanelContent");n.innerHTML="";let l=[],d=null,g=null;if(t[0].features.length<4)document.getElementById("infoPanelContent").innerHTML="No hi ha dades sobre el punt seleccionat.";else{for(let s=0;sAdreça: ${d.etiqueta}
`),g&&(n.innerHTML+=`Coordenades: ${o.toFixed(4)}, ${a.toFixed(4)}
`,n.innerHTML+=`Elevació: ${g} metres

`);for(let s=0;s{f=c,h(c,p)}),p.addEventListener("mouseover",()=>{T(c)}),p.addEventListener("mouseout",()=>{_()}),n.appendChild(p),n.appendChild(document.createElement("br"))}l.length>0&&!f?setTimeout(()=>{f=l[0],h(f,n.querySelector(".myButtonClass"))},0):f&&document.querySelectorAll(".myButtonClass").forEach(c=>{c.textContent.includes(f)&&h(f,c)})}H()}function h(o,a){const r=S(e.getStyle().layers);b();const i=document.querySelector(".closeButtonClass");i&&i.parentNode.removeChild(i);let t=new maplibregl.LngLatBounds;for(let d=0;d{t.extend(y)}):g.type==="MultiPolygon"&&g.coordinates.forEach(y=>{y[0].forEach(v=>{t.extend(v)})}),document.querySelectorAll(".layer-properties").forEach(y=>y.remove());const c=document.createElement("div");c.classList.add("layer-properties");const p=u[d].properties;for(const[y,v]of Object.entries(p)){const C=document.createElement("div");C.textContent=`${y}: ${v}`,c.appendChild(C)}const m=document.createElement("button");m.textContent="×",m.classList.add("closeButtonClass"),m.addEventListener("click",()=>{b(),c.remove(),m.remove(),a.classList.remove("highlighted-button")}),c.appendChild(m),a.parentNode.insertBefore(c,a.nextSibling),a.parentNode.insertBefore(m,a.nextSibling),document.querySelectorAll(".myButtonClass").forEach(y=>y.classList.remove("highlighted-button")),a.classList.add("highlighted-button")}const l=window.innerWidth<750?k:M;e.fitBounds(t,{padding:l})}function $(){e=new maplibregl.Map({container:"map",style:"https://geoserveis.icgc.cat/contextmaps/icgc_mapa_estandard_general.json",center:[2.0042,41.7747],zoom:7,maxZoom:18,attributionControl:!1,hash:!1}),e.on("load",function(){w().then(function(){x()}),e.addControl(new maplibregl.NavigationControl,"top-right");var o=new maplibregl.FullscreenControl;e.addControl(o,"top-right"),e.addControl(new maplibregl.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!1}),"top-right"),e.on("click",function(a){var r=document.getElementById("notification");r&&r.classList.remove("show");let i=a.lngLat.lng,t=a.lngLat.lat;f?(b(),B(t,i,E).then(()=>{h(f,document.querySelector(".myButtonClass.highlighted-button"))})):B(t,i,E),L?L.setLngLat([i,t]):L=new maplibregl.Marker({color:"#FF6E42"}).setLngLat([i,t]).addTo(e)})})}function S(o){let a="background";for(var r=0;r${t.features[0].properties.etiqueta}
Carrer: ${t.features[0].properties.nom}
Municipi: ${t.features[0].properties.municipi}
Codi Postal: ${t.features[0].properties.codi_postal}
`).addTo(e)}),e.on("mouseleave","punts2",function(t){e.getCanvas().style.cursor="",i.remove()}))}function F(){document.getElementById("loader").style.display="block",document.getElementById("infoPanelContent").style.display="none"}function H(){document.getElementById("loader").style.display="none",document.getElementById("infoPanelContent").style.display="block"}function P(){var o=document.getElementById("infoPanel");o.classList.add("open"),o.style.width="300px",document.getElementById("openPanel").style.display="none"}function O(){var o=document.getElementById("infoPanel");o.classList.remove("open"),o.style.width="0px",document.getElementById("openPanel").style.display="block"}function q(){$();const o=document.getElementById("textSelector");o.addEventListener("change",()=>{const a=o.value;j(a)})}window.addEventListener("DOMContentLoaded",q);window.closePanel=O;window.openPanel=P;window.onBaseChange=I; diff --git a/dist/index.html b/dist/index.html index 41bc42f..3d674e9 100644 --- a/dist/index.html +++ b/dist/index.html @@ -412,7 +412,7 @@ } - + @@ -428,9 +428,9 @@
Base de referència:
diff --git a/index.html b/index.html index 7e5dcec..31dd91e 100644 --- a/index.html +++ b/index.html @@ -427,9 +427,9 @@
Base de referència:
diff --git a/src/main.js b/src/main.js index 7abbdda..fce12d5 100644 --- a/src/main.js +++ b/src/main.js @@ -326,7 +326,7 @@ function initMap() { map = new maplibregl.Map({ container: "map", style: - "https://geoserveis.icgc.cat/contextmaps/icgc_mapa_base_fosc.json", + "https://geoserveis.icgc.cat/contextmaps/icgc_mapa_estandard_general.json", center: [2.0042, 41.7747], zoom: 7, maxZoom: 18,