From ca78972ffcd5d4e612b1cabc54bc9092677d8165 Mon Sep 17 00:00:00 2001 From: "amaury.zarzelli" Date: Tue, 19 Dec 2023 16:30:33 +0100 Subject: [PATCH] feat(gfi): gfi now uses generic position control --- src/css/map.css | 4 ---- src/js/gfi.js | 25 ++++++++++--------------- src/js/map-listeners.js | 11 ++++++++--- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/css/map.css b/src/css/map.css index f9b63ecb..21bd4041 100644 --- a/src/css/map.css +++ b/src/css/map.css @@ -5,10 +5,6 @@ color: black; } -/* Popup getFeatureInfo */ -.getfeatureinfoPopup { -} - .maplibregl-ctrl-bottom-left { bottom: -35px; left: 15px; diff --git a/src/js/gfi.js b/src/js/gfi.js index b7373f4f..0a896235 100644 --- a/src/js/gfi.js +++ b/src/js/gfi.js @@ -22,7 +22,7 @@ async function multipleGFI(layerArray) { `&TILECOL=${layer[1].tiles.tile.x}&TILEROW=${layer[1].tiles.tile.y}&TILEMATRIX=${layer[1].computeZoom}&TILEMATRIXSET=PM` + `&FORMAT=${layer[1].format}` + `&STYLE=${layer[1].style}&INFOFORMAT=text/html&I=${layer[1].tiles.tilePixel.x}&J=${layer[1].tiles.tilePixel.y}` - ).then((response => { return response.text()}) + ).then((response => {return response.text()}) , () => { throw new Error("GetFeatureInfo : HTTP error"); @@ -39,18 +39,10 @@ async function multipleGFI(layerArray) { const xmlStr = serializer.serializeToString(doc); throw new Error(xmlStr); } - const result = { - layer: layer[0].split('$')[0], - html: res, - }; - return result; + return res; }); - const result = { - layer: layer[0].split('$')[0], - html: response, - }; - return result; - }) + return response; + }); let responsesArray = Promise.allSettled(promisesArray); let response = (await responsesArray).find(r => r.status == "fulfilled"); @@ -59,7 +51,11 @@ async function multipleGFI(layerArray) { const isAboveThreshold = (v) => v > i; // on ne retourne une infobulle que si la couche n'est pas recouverte par une couche non requĂȘtable if (indexbase.every(isAboveThreshold)) { - return response.value; + const result = { + layer: layerArray[i][1].title, + html: response.value, + }; + return result; } else { throw new Error("Under non requestable layer"); @@ -70,5 +66,4 @@ async function multipleGFI(layerArray) { } } - -export default multipleGFI +export default multipleGFI; diff --git a/src/js/map-listeners.js b/src/js/map-listeners.js index e6abcabd..d0b406f0 100644 --- a/src/js/map-listeners.js +++ b/src/js/map-listeners.js @@ -69,13 +69,18 @@ const addListeners = () => { if (!Globals.interactivity.shown) { return; } + if (Globals.backButtonState === "position") { + Globals.menu.close("position"); + } let features = map.queryRenderedFeatures(ev.point); // On clique sur une feature tuile vectorielle let featureHTML; if (features.length > 0) { - featureHTML = JSON.stringify(features[0].properties) + console.log(features) + featureHTML = JSON.stringify(features[0].properties); if (features[0].source === "poi_osm") { - Globals.position.compute(ev.lngLat, features[0].source, featureHTML).then(() => { + let featureName = features[0].properties.texte; + Globals.position.compute(ev.lngLat, featureName, featureHTML).then(() => { Globals.menu.open("position"); }); return; @@ -114,7 +119,7 @@ const addListeners = () => { return; }).catch((err) => { if (featureHTML && featureHTML != '{}') { - Globals.position.compute(ev.lngLat, features[0].source, featureHTML).then(() => { + Globals.position.compute(ev.lngLat, features[0].sourceLayer, featureHTML).then(() => { Globals.menu.open("position"); }); }