Skip to content

Commit

Permalink
feat(gfi): gfi now uses generic position control
Browse files Browse the repository at this point in the history
  • Loading branch information
azarz committed Dec 20, 2023
1 parent 5830402 commit ca78972
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
4 changes: 0 additions & 4 deletions src/css/map.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
color: black;
}

/* Popup getFeatureInfo */
.getfeatureinfoPopup {
}

.maplibregl-ctrl-bottom-left {
bottom: -35px;
left: 15px;
Expand Down
25 changes: 10 additions & 15 deletions src/js/gfi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand All @@ -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");
Expand All @@ -70,5 +66,4 @@ async function multipleGFI(layerArray) {
}
}


export default multipleGFI
export default multipleGFI;
11 changes: 8 additions & 3 deletions src/js/map-listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
});
}
Expand Down

0 comments on commit ca78972

Please sign in to comment.