So I want to create a buffer around addresses (received via user upload) and extract aggregated data for them but I'm getting issues around the geometry() in BufferGeom(). Could someone please help me understand and resolve this issue?
const address_geo = []
document.getElementById("download-button").onclick = () => {
var fileInput = document.getElementById('fileInput');
var file = fileInput.files[0];
if (file) {
var reader = new FileReader();
reader.onload = function (e) {
var data = e.target.result;
var workbook = XLSX.read(data, { type: 'binary' });
var sheetName = workbook.SheetNames[0];
var sheet = workbook.Sheets[sheetName];
var dataArray = XLSX.utils.sheet_to_json(sheet, { header: 1 });
list_address = dataArray.flat()
const geocode = "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer";
for (var i = 0; i < list_address.length; i++) {
const addressinput = list_address[i]
const params = {
address: {
address: addressinput,
},
countryCode: "CAN",
};
locator.addressToLocations(geocode, params).then((results) => {
showResult(results);
});
function showResult(results) {
if (results.length) {
const result = results[0];
uniqueAddressID2.push(result.address);
const point = new Graphic({
symbol: {
type: "simple-marker",
style: "circle",
size: "16px",
color: [70, 90, 141, 0.4],
},
geometry: result.location,
attributes: {
title: "Address",
address: result.address,
score: result.score,
},
});
address_geo.push(point)
}
};
}
BufferGeom(address_geo)
};
reader.readAsBinaryString(file);
} else {
alert('Please select a file.');
}
}
function BufferGeom(geo_points) {
var d = document.getElementById("distance");
const buffGeoms = geometryEngine.geodesicBuffer(
geo_points,
d.value,
"kilometers"
);
buffGeoms.forEach((buffGeom) => {
const buffgra = new Graphic({
geometry: buffGeom,
symbol: {
type: "simple-fill",
color: [112, 128, 144, 0],
},
});
});
