From de190bd223d99bf257f7bb89b77c84bd4c83020f Mon Sep 17 00:00:00 2001 From: Marcrb3 Date: Wed, 5 Jun 2024 14:02:07 +0200 Subject: [PATCH] fix openPanel button issue --- dist/assets/{index-B2Pisj5J.js => index-WDeUfrCN.js} | 4 ++-- dist/index.html | 6 +++--- index.html | 4 ++-- src/main.js | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) rename dist/assets/{index-B2Pisj5J.js => index-WDeUfrCN.js} (87%) diff --git a/dist/assets/index-B2Pisj5J.js b/dist/assets/index-WDeUfrCN.js similarity index 87% rename from dist/assets/index-B2Pisj5J.js rename to dist/assets/index-WDeUfrCN.js index 1258d45..954aa88 100644 --- a/dist/assets/index-B2Pisj5J.js +++ b/dist/assets/index-WDeUfrCN.js @@ -1,4 +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"]'))c(e);new MutationObserver(e=>{for(const o of e)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&c(a)}).observe(document,{childList:!0,subtree:!0});function n(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 c(e){if(e.ep)return;e.ep=!0;const o=n(e);fetch(e.href,o)}})();var t,f;let L="all",y="fosc",u;const b=5,E=150;async function P(){y=document.getElementById("serveiSelector2").value,y==="orto"?t.setStyle("https://geoserveis.icgc.cat/contextmaps/icgc_orto_estandard.json"):y==="topo"?t.setStyle("https://geoserveis.icgc.cat/contextmaps/icgc_mapa_estandard_general.json"):y==="fosc"&&t.setStyle("https://geoserveis.icgc.cat/contextmaps/icgc_mapa_base_fosc.json")}async function B(r,l,n){t.getLayer("clicked-layer")&&t.removeLayer("clicked-layer"),t.getSource("clicked-layer")&&t.removeSource("clicked-layer"),h(),k();const e=await(await fetch(`https://api.icgc.cat/territori/${n}/geo/${l}/${r}`)).json();u=e[0].features;const o=document.getElementById("infoPanelContent");o.innerHTML="";let a=[],p=null,d=null;if(e[0].features.length<4)document.getElementById("infoPanelContent").innerHTML="No hi ha dades sobre el punt seleccionat.";else{for(let s=0;sAdreça: ${p.etiqueta}
`),d&&(o.innerHTML+=`Elevació: ${d} metres

`);for(let s=0;s{C(m,i)}),o.appendChild(i),o.appendChild(document.createElement("br"))}}I()}function C(r,l){console.log("Afegim geometria per al servei:",r),t.getLayer("clicked-layer")&&t.removeLayer("clicked-layer"),t.getSource("clicked-layer")&&t.removeSource("clicked-layer");let n=new maplibregl.LngLatBounds;for(let o=0;o{n.extend(i)}):a.type==="MultiPolygon"&&a.coordinates.forEach(i=>{i[0].forEach(g=>{n.extend(g)})}),document.querySelectorAll(".layer-properties").forEach(i=>i.remove());const d=document.createElement("div");d.classList.add("layer-properties");const s=u[o].properties;for(const[i,g]of Object.entries(s)){const v=document.createElement("div");v.textContent=`${i}: ${g}`,d.appendChild(v)}l.parentNode.insertBefore(d,l.nextSibling),document.querySelectorAll(".myButtonClass").forEach(i=>i.classList.remove("highlighted-button")),l.classList.add("highlighted-button")}const e=window.innerWidth<750?b:E;t.fitBounds(n,{padding:e})}async function S(r){const n=await(await fetch(`https://api.icgc.cat/territori/adress/${r}`)).json();n.features?(t.getLayer("punts2")?(t.removeLayer("punts2").removeSource("punts2"),t.addSource("punts2",{type:"geojson",data:{type:"FeatureCollection",features:n.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:n.features}}),t.addLayer({id:"punts2",type:"circle",source:"punts2",paint:{"circle-color":"red","circle-opacity":.8,"circle-radius":6}})),t.flyTo({center:[n.features[0].geometry.coordinates[0],n.features[0].geometry.coordinates[1]],zoom:11,essential:!0})):alert(n);const c=new maplibregl.Popup({closeButton:!1,closeOnClick:!1});t.getLayer("punts2")&&(t.on("mouseenter","punts2",function(e){t.getCanvas().style.cursor="pointer",c.setLngLat(e.features[0].geometry.coordinates).setHTML(`Adreça: ${e.features[0].properties.etiqueta}
+(function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))c(e);new MutationObserver(e=>{for(const o of e)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&c(a)}).observe(document,{childList:!0,subtree:!0});function n(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 c(e){if(e.ep)return;e.ep=!0;const o=n(e);fetch(e.href,o)}})();var t,f;let L="all",y="fosc",u;const b=5,E=150;async function B(){y=document.getElementById("serveiSelector2").value,y==="orto"?t.setStyle("https://geoserveis.icgc.cat/contextmaps/icgc_orto_estandard.json"):y==="topo"?t.setStyle("https://geoserveis.icgc.cat/contextmaps/icgc_mapa_estandard_general.json"):y==="fosc"&&t.setStyle("https://geoserveis.icgc.cat/contextmaps/icgc_mapa_base_fosc.json")}async function P(r,l,n){t.getLayer("clicked-layer")&&t.removeLayer("clicked-layer"),t.getSource("clicked-layer")&&t.removeSource("clicked-layer"),h(),k();const e=await(await fetch(`https://api.icgc.cat/territori/${n}/geo/${l}/${r}`)).json();u=e[0].features;const o=document.getElementById("infoPanelContent");o.innerHTML="";let a=[],p=null,d=null;if(e[0].features.length<4)document.getElementById("infoPanelContent").innerHTML="No hi ha dades sobre el punt seleccionat.";else{for(let s=0;sAdreça: ${p.etiqueta}
`),d&&(o.innerHTML+=`Elevació: ${d} metres

`);for(let s=0;s{C(m,i)}),o.appendChild(i),o.appendChild(document.createElement("br"))}}I()}function C(r,l){console.log("Afegim geometria per al servei:",r),t.getLayer("clicked-layer")&&t.removeLayer("clicked-layer"),t.getSource("clicked-layer")&&t.removeSource("clicked-layer");let n=new maplibregl.LngLatBounds;for(let o=0;o{n.extend(i)}):a.type==="MultiPolygon"&&a.coordinates.forEach(i=>{i[0].forEach(g=>{n.extend(g)})}),document.querySelectorAll(".layer-properties").forEach(i=>i.remove());const d=document.createElement("div");d.classList.add("layer-properties");const s=u[o].properties;for(const[i,g]of Object.entries(s)){const v=document.createElement("div");v.textContent=`${i}: ${g}`,d.appendChild(v)}l.parentNode.insertBefore(d,l.nextSibling),document.querySelectorAll(".myButtonClass").forEach(i=>i.classList.remove("highlighted-button")),l.classList.add("highlighted-button")}const e=window.innerWidth<750?b:E;t.fitBounds(n,{padding:e})}async function S(r){const n=await(await fetch(`https://api.icgc.cat/territori/adress/${r}`)).json();n.features?(t.getLayer("punts2")?(t.removeLayer("punts2").removeSource("punts2"),t.addSource("punts2",{type:"geojson",data:{type:"FeatureCollection",features:n.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:n.features}}),t.addLayer({id:"punts2",type:"circle",source:"punts2",paint:{"circle-color":"red","circle-opacity":.8,"circle-radius":6}})),t.flyTo({center:[n.features[0].geometry.coordinates[0],n.features[0].geometry.coordinates[1]],zoom:11,essential:!0})):alert(n);const c=new maplibregl.Popup({closeButton:!1,closeOnClick:!1});t.getLayer("punts2")&&(t.on("mouseenter","punts2",function(e){t.getCanvas().style.cursor="pointer",c.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="",c.remove()}))}function w(){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 r=new maplibregl.FullscreenControl;t.addControl(r,"top-right"),t.on("click",function(l){let n=l.lngLat.lng,c=l.lngLat.lat;B(c,n,L),f?(f.remove(),f=new maplibregl.Marker({color:"#FF6E42"}).setLngLat([n,c]).addTo(t)):f=new maplibregl.Marker({color:"#FF6E42"}).setLngLat([n,c]).addTo(t)})}function k(){document.getElementById("loader").style.display="block",document.getElementById("infoPanelContent").style.display="none"}function I(){document.getElementById("loader").style.display="none",document.getElementById("infoPanelContent").style.display="block"}function h(){var r=document.getElementById("infoPanel");r.classList.add("open"),r.style.width="400px",document.getElementById("openPanel").style.display="none"}function x(){var r=document.getElementById("infoPanel");r.classList.remove("open"),r.style.width="0px",document.getElementById("openPanel").style.display="block"}function M(){w(),document.getElementById("serveiSelector2").addEventListener("change",P),document.getElementById("openPanel").addEventListener("click",h),document.getElementById("closePanel").addEventListener("click",x);const c=document.getElementById("textSelector");c.addEventListener("change",()=>{const e=c.value;S(e)})}window.addEventListener("DOMContentLoaded",M); + Codi Postal: ${e.features[0].properties.postalcode}
`).addTo(t)}),t.on("mouseleave","punts2",function(e){t.getCanvas().style.cursor="",c.remove()}))}function w(){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 r=new maplibregl.FullscreenControl;t.addControl(r,"top-right"),t.on("click",function(l){let n=l.lngLat.lng,c=l.lngLat.lat;P(c,n,L),f?(f.remove(),f=new maplibregl.Marker({color:"#FF6E42"}).setLngLat([n,c]).addTo(t)):f=new maplibregl.Marker({color:"#FF6E42"}).setLngLat([n,c]).addTo(t)})}function k(){document.getElementById("loader").style.display="block",document.getElementById("infoPanelContent").style.display="none"}function I(){document.getElementById("loader").style.display="none",document.getElementById("infoPanelContent").style.display="block"}function h(){var r=document.getElementById("infoPanel");r.classList.add("open"),r.style.width="400px",document.getElementById("openPanelBtn").style.display="none"}function x(){var r=document.getElementById("infoPanel");r.classList.remove("open"),r.style.width="0px",document.getElementById("openPanelBtn").style.display="block"}function M(){w(),document.getElementById("serveiSelector2").addEventListener("change",B),document.getElementById("openPanelBtn").addEventListener("click",h),document.getElementById("closePanel").addEventListener("click",x);const c=document.getElementById("textSelector");c.addEventListener("change",()=>{const e=c.value;S(e)})}window.addEventListener("DOMContentLoaded",M); diff --git a/dist/index.html b/dist/index.html index 0fe79c4..1355691 100644 --- a/dist/index.html +++ b/dist/index.html @@ -176,7 +176,7 @@ display: block; } - #openPanel { + #openPanelBtn { position: absolute; top: 20px; left: 10px; @@ -293,7 +293,7 @@ } - + @@ -325,7 +325,7 @@ - + diff --git a/index.html b/index.html index 4ca9daa..6ec6291 100644 --- a/index.html +++ b/index.html @@ -176,7 +176,7 @@ display: block; } - #openPanel { + #openPanelBtn { position: absolute; top: 20px; left: 10px; @@ -324,7 +324,7 @@ - + diff --git a/src/main.js b/src/main.js index ef29ffe..d939c82 100644 --- a/src/main.js +++ b/src/main.js @@ -294,14 +294,14 @@ function openPanel() { var infoPanel = document.getElementById("infoPanel"); infoPanel.classList.add("open"); infoPanel.style.width = "400px"; // Amplada del panell quan està obert - document.getElementById("openPanel").style.display = "none"; // Amagar el botó d'obrir quan el panell està obert + document.getElementById("openPanelBtn").style.display = "none"; // Amagar el botó d'obrir quan el panell està obert } function closePanel() { var infoPanel = document.getElementById("infoPanel"); infoPanel.classList.remove("open"); infoPanel.style.width = "0px"; // Tancar el panell - document.getElementById("openPanel").style.display = "block"; // Mostrar el botó d'obrir quan el panell està tancat + document.getElementById("openPanelBtn").style.display = "block"; // Mostrar el botó d'obrir quan el panell està tancat } function init() { initMap(); @@ -310,7 +310,7 @@ function init() { serveiSelector2.addEventListener('change', onBaseChange); // Altres funcions d'inicialització aquí si n'hi ha - const openPanelButton = document.getElementById("openPanel"); + const openPanelButton = document.getElementById("openPanelBtn"); openPanelButton.addEventListener('click', openPanel); const closePanelButton = document.getElementById("closePanel"); closePanelButton.addEventListener('click', closePanel);