Skip to content

Commit 0d5d149

Browse files
committed
Also add geo_id
1 parent a621fc5 commit 0d5d149

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/modes/exportdata/ExportData.svelte

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
}
2828
}
2929
30+
// Pre-fill the form from URL parameters.
31+
// Supported parameters: source, sensor, start, end, geo_type, geo_id
3032
const urlParams = new URLSearchParams(window.location.search);
3133
3234
// Overwrite default source & sensor if these are present in the URL
@@ -41,7 +43,7 @@
4143
$: isWeekly = sensor ? sensor.isWeeklySignal : false;
4244
$: formatDate = isWeekly ? (d) => formatWeek(d).replace('W', '') : formatDateISO;
4345
44-
let geoType = urlParams.has('geo') ? urlParams.get('geo') : 'county';
46+
let geoType = urlParams.has('geo_type') ? urlParams.get('geo_type') : 'county';
4547
4648
let startDate = new Date();
4749
let endDate = new Date();
@@ -72,12 +74,20 @@
7274
7375
let geoValuesMode = 'all';
7476
let geoValues = [];
77+
let geoURLSet = false;
7578
$: geoItems = [...(infosByLevel[geoType] || []), ...(geoType === 'county' ? infosByLevel.state : [])];
7679
$: {
7780
if (geoItems != null) {
7881
geoValues = [];
7982
geoValuesMode = guessMode(geoItems.length);
8083
}
84+
85+
// Populate region based on URL params... but let the user override this later
86+
if (urlParams.has('geo_id') && !geoURLSet) {
87+
let infos = infosByLevel[geoType].filter((d) => d.propertyId == urlParams.get('geo_id'));
88+
addRegion(infos[0]);
89+
geoURLSet = true;
90+
}
8191
}
8292
8393
function flatIds(geoValues) {

0 commit comments

Comments
 (0)