Skip to content

Commit

Permalink
maps: Catch unloaded data
Browse files Browse the repository at this point in the history
If a single geojson file is uploaded this will prevent errors and return an console log that one of the files could not be loaded. This is less elegant than switching which layers to create but that route has added complexity. A good future improvement
  • Loading branch information
Jared Parnell committed Nov 16, 2022
1 parent 0644f5e commit 6c798c3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cove_ofds/templates/cove_ofds/explore.html
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,7 @@ <h4 class="panel-title">
}

function getJsonFromDict(feature) {
console.log(feature.geometry.type)
if (feature.geometry.type === 'Point') {
console.log('node', document.getElementById('node-fields').textContent)
return JSON.parse(document.getElementById('node-fields').textContent);
} else if (feature.geometry.type === 'LineString') {
return JSON.parse(document.getElementById('span-fields').textContent);
Expand Down Expand Up @@ -439,6 +437,9 @@ <h4 class="panel-title">
spanLayerGroup.addLayer(layer)
map.fitBounds(layer.getBounds())
return generateLegendItems(spanFeatureData)
}).catch(err => {
console.log("The Spans data could not be loaded.");
return [];
})
}

Expand All @@ -455,7 +456,11 @@ <h4 class="panel-title">
}
}).bindPopup(layer => generatePopup(layer), customOptions)
nodeLayerGroup.addLayer(layer)
map.fitBounds(layer.getBounds())
return generateLegendItems(nodeFeatureData)
}).catch(err => {
console.log("The Nodes data could not be loaded.")
return [];
})
}

Expand Down

0 comments on commit 6c798c3

Please sign in to comment.