Hi everyone, I'm trying to download statistics for a drawn buffer. I'm able to do that but if I change my year (the where clause) instead of downloading the data for the new year, it keeps using the same year. For instance, if I select 2020, it will download the data statistics using 2020 year but then if I switch to the 2021 year it still downloads 2020.
let querycentroids = layer.createQuery();
querycentroids.spatialRelationship = "contains";
querycentroids.geometry = buffgra.geometry;
$(".chosen-benchmark")
.chosen()
.change(function () {
var option = [$("#YearSource").val()];
var result = "'" + option.join("','") + "'";
querycentroids.where="year IN (" + result + ")"
if ($(".chosen-benchmark").val() == 'Toronto') {
console.log('Toronto')
if ($(".chosen-year").val() == '2020') {
console.log('works')
document.getElementById("report").onclick = () => {
downloadData(Toronto_2020,option)
}
}
else if ($(".chosen-year").val() == '2021') {
console.log('works2021')
document.getElementById("report").onclick = () => {
downloadData(Toronto_2021,option)
}
}
else if ($(".chosen-year").val() == '2022') {
console.log('works2022')
document.getElementById("report").onclick = () => {
downloadData(Toronto_2022,option)
}
}
$(".chosen-year")
.chosen()
.change(function () {
var yearoptions2 = [$("#YearSource").val()];
var yearresult2 = "'" + yearoptions2.join("','") + "'";
querycentroids.where="year IN (" + yearresult2 + ")"
if ($(".chosen-year").val() == '2020') {
console.log('2020')
document.getElementById("report").onclick = () => {
downloadData(Toronto_2020,yearoptions2)
}
}
else if ($(".chosen-year").val() == '2021') {
console.log('2021')
document.getElementById("report").onclick = () => {
downloadData(Toronto_2021,yearoptions2)
}
}
else if ($(".chosen-year").val() == '2022') {
console.log('2022')
document.getElementById("report").onclick = () => {
downloadData(Toronto_2022,yearoptions2)
}
}
})
}
else if ($(".chosen-benchmark").val() == 'BC') {
//// same stuff
}
});
});
You should put this in a separate question. And it's quite an ask to review this much coding. It's better to create a small example that illustrates the problem
Hi @KenBuja I had created a new question, could you please check it out