You want to export it to a text file from Javascript? Because you can export a console log to a text file from the browser.
But if you want to do it in Javascript, this should work:
let blob = new Blob(["test"]);
let url = URL.createObjectURL(blob);
let file = document.createElement(`a`);
file.download = `file.txt`;
file.href = url;
document.body.appendChild(file);
file.click();
file.remove();
URL.revokeObjectURL(url);
Replace "test"
with what you want to be in the text file. You can concatenate all elevations in a variable and replace "test"
with variable
.
So, for example, you could do:
var text = "";
for (var i = 0; i < elevations.length; i++) {
data.addRow(['', elevations[i].elevation]);
console.log(elevations[i].elevation);
text += elevations[i].elevation + "\n";
}
And then use text
in let blob = new Blob([text]);
.