From 6c798c32a0bd2dfb8ddb7194f2359effaee3aa67 Mon Sep 17 00:00:00 2001 From: Jared Parnell Date: Wed, 16 Nov 2022 16:38:23 +0000 Subject: [PATCH] maps: Catch unloaded data 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 --- cove_ofds/templates/cove_ofds/explore.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cove_ofds/templates/cove_ofds/explore.html b/cove_ofds/templates/cove_ofds/explore.html index 265a3b9..bd9dafd 100644 --- a/cove_ofds/templates/cove_ofds/explore.html +++ b/cove_ofds/templates/cove_ofds/explore.html @@ -380,9 +380,7 @@

} 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); @@ -439,6 +437,9 @@

spanLayerGroup.addLayer(layer) map.fitBounds(layer.getBounds()) return generateLegendItems(spanFeatureData) + }).catch(err => { + console.log("The Spans data could not be loaded."); + return []; }) } @@ -455,7 +456,11 @@

} }).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 []; }) }