Skip to content

Commit

Permalink
removed timeout reporting from waitForLayerChange as it was not relev…
Browse files Browse the repository at this point in the history
…ant. also added some comments to new functions from last commit
  • Loading branch information
acatchpole committed Jan 10, 2024
1 parent 7cc589f commit b751e1d
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions app/frontend/src/aquifers/components/SingleAquiferMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,10 @@ export default {
},
async layersChanged(layerId, show) {
try {
// Turn the layer's visibility on / off
this.map.setLayoutProperty(layerId, 'visibility', show ? 'visible' : 'none');
// Turn the layer's visibility on / off
this.map.setLayoutProperty(layerId, 'visibility', show ? 'visible' : 'none');
try {
// Wait for the layer change to be rendered
await this.waitForLayerChangeRender(layerId, show);
Expand All @@ -354,7 +354,7 @@ export default {
}
},
async waitForLayerChangeRender(layerId, show) {
async waitForLayerChangeRender(layerId, show) {//waits for layer with layerId to appear or be removed based on value of show
const maxAttempts = 10; // Adjust the number of attempts as needed
let attempts = 0;
let hasChangeBeenRendered = false;
Expand All @@ -369,16 +369,11 @@ export default {
}
if (!hasChangeBeenRendered) {
// Add a delay before checking again (e.g., 100ms)
// Add a delay before checking again
await new Promise(resolve => setTimeout(resolve, 100));
attempts++;
}
}
if (!hasChangeBeenRendered) {
console.warn('Timeout waiting for layer change to be rendered.');
// Handle the timeout scenario (e.g., log, throw, etc.)
}
},
zoomToAquifer (fitBoundsOptions) {
Expand Down Expand Up @@ -459,7 +454,7 @@ export default {
}
this.legendControl.update();
},
getRenderedLayerIds(){
getRenderedLayerIds(){ //returns a set of all layer ids which are currently being rendered
const visibleFeatures = (this.map.queryRenderedFeatures());
const uniqueRenderedLayerIds = new Set();
visibleFeatures.forEach(item => {
Expand Down

0 comments on commit b751e1d

Please sign in to comment.