Skip to content

Commit

Permalink
Don't block the map when there is a wrong layer name in URL parameters (
Browse files Browse the repository at this point in the history
3liz#3955)

Fix gl224
  • Loading branch information
nboisteault authored Nov 3, 2023
1 parent 78c42f0 commit c86f622
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
32 changes: 21 additions & 11 deletions assets/src/legacy/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -4661,13 +4661,23 @@ window.lizMap = function() {
}

// Request config and capabilities in parallel
Promise.all([configRequest, keyValueConfigRequest, WMSRequest, WMTSRequest, WFSRequest, featureExtentRequest, getFeatureInfoRequest]).then(responses => {
// config is defined globally
config = responses[0];
keyValueConfig = responses[1];
const wmsCapaData = responses[2];
const wmtsCapaData = responses[3];
const wfsCapaData = responses[4];
Promise.allSettled([configRequest, keyValueConfigRequest, WMSRequest, WMTSRequest, WFSRequest, featureExtentRequest, getFeatureInfoRequest]).then(responses => {
// Raise an error when one those required requests fails
// Other requests can fail silently
const requiredRequests = [responses[0], responses[2], responses[3], responses[4]];

for (const request of requiredRequests) {
if (request.status === "rejected") {
throw new Error(request.reason);
}
}

// `config` is defined globally
config = responses[0].value;
keyValueConfig = responses[1].value;
const wmsCapaData = responses[2].value;
const wmtsCapaData = responses[3].value;
const wfsCapaData = responses[4].value;

self.events.triggerEvent("configsloaded", {
initialConfig: config,
Expand All @@ -4676,16 +4686,16 @@ window.lizMap = function() {
wfsCapabilities: wfsCapaData,
});

let featuresExtent = responses[5]?.features?.[0]?.bbox;
let features = responses[5]?.features;
let featuresExtent = responses[5].value?.features?.[0]?.bbox;
let features = responses[5].value?.features;

if(featuresExtent){
for (const feature of responses[5].features) {
for (const feature of features) {
featuresExtent = extend(featuresExtent, feature.bbox);
}
}

getFeatureInfo = responses[6];
getFeatureInfo = responses[6].value;

const domparser = new DOMParser();

Expand Down
4 changes: 2 additions & 2 deletions assets/src/modules/WFS.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class WFS {
...options
})
});
return await response.json();
return response.json();
}

/**
Expand All @@ -49,6 +49,6 @@ export default class WFS {
...options
})
});
return await response.json();
return response.json();
}
}

0 comments on commit c86f622

Please sign in to comment.