Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make getfeatureinfo requests not fail together #2003

Merged
merged 2 commits into from
May 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/getfeatureinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,23 +319,27 @@ 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) => {
const layer = viewer.getLayer(requests[i].layer);
if (result.status === 'fulfilled' && result.value) {
const groupLayers = viewer.getGroupLayers();
const map = viewer.getMap();
result.value.forEach((feature) => {
const si = createSelectedItem(feature, layer, map, groupLayers);
requestResult.push(si);
});
return requestResult;
} else {
console.warn(`GetFeatureInfo request failed for layer: ${layer.get('name')}`);
}
});

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

function getFeaturesAtPixel({
Expand Down
Loading