Skip to content

Commit

Permalink
fix: make getfeatureinfo requests not fail together
Browse files Browse the repository at this point in the history
  • Loading branch information
Grammostola committed May 2, 2024
1 parent 368a450 commit cd1a247
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/getfeatureinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,23 +319,25 @@ function getFeatureInfoRequests({
return requests;
}

function getFeaturesFromRemote(requestOptions, viewer, textHtmlHandler) {
async function getFeaturesFromRemote(requestOptions, viewer, textHtmlHandler) {
const requestResult = [];
const requestPromises = getFeatureInfoRequests(requestOptions, viewer, textHtmlHandler).map((request) => request.fn.then((features) => {
const layer = viewer.getLayer(request.layer);
const groupLayers = viewer.getGroupLayers();
const map = viewer.getMap();
if (features) {
features.forEach((feature) => {
const requests = getFeatureInfoRequests(requestOptions, viewer, textHtmlHandler);
const featureInfoPromises = requests.map((request) => request.fn);
const featureInfoPromisesResults = await Promise.allSettled(featureInfoPromises);

featureInfoPromisesResults.forEach((result, i) => {
if (result.status === 'fulfilled' && result.value) {
const layer = viewer.getLayer(requests[i].layer);
const groupLayers = viewer.getGroupLayers();
const map = viewer.getMap();
result.value.forEach((feature) => {
const si = createSelectedItem(feature, layer, map, groupLayers);
requestResult.push(si);
});
return requestResult;
}
});

return false;
}));
return Promise.all([...requestPromises]).then(() => requestResult).catch(error => console.log(error));
return requestResult;
}

function getFeaturesAtPixel({
Expand Down

0 comments on commit cd1a247

Please sign in to comment.