Thanks for the help! :) Like I mentioned, everything works fine on my own computer (even your code). However, when I alter the table data to support a .csv format, the "... var output = csvData.join('\n'); " line from your example causes the map/charts/etc to fail to load on my localhost port. Replacing the "\n" with anything else (e.g., ",") will sort of fix the issue, but I fail to get the .csv in two column form. I had the same problem when trying to print the data from a table to a textarea in the body of my page.
function plotElevation(results) {
elevations = results;
var obj=document.getElementById('textlocation'); //This assigns the textarea
var path = [];
for (var i = 0; i < results.length; i++) {
path.push(elevations[i].location);
}
if (polyline) {
polyline.setMap(null);
}
polyline = new google.maps.Polyline({
path: path,
strokeColor: "#79d6fe",
map: map});
data = new google.visualization.DataTable();
data.addColumn('string', 'Resolution (m)');
data.addColumn('number', 'Elevation (m)');
var len= 0;
for (var i = 0; i < results.length; i++) {
len = len + elevations[i].resolution;
len1 = Math.round(len);
var print_len = len1.toString();
data.addRow([print_len, elevations[i].elevation ]);
var txt=document.createTextNode(print_len+", "+elevations[i].elevation+"\n") //This prescribes what to write in the textarea
obj.appendChild(txt) /This adds text to the textarea
}
var endcode = document.createTextNode('Next City...'+"\n")
obj.appendChild(endcode)
document.getElementById('chart_div').style.display = 'block';
chart.draw(data, {
width: 600,
height: 150,
legend: 'none',
titleY: 'Elevation (m)',
titleX: 'Resolution (m)',
focusBorderColor: '#00ff00',
colors: ['#cedfad']
});
}
In my body:
<textarea name= "textloc" id="textlocation" style="resize: none;" cols="25" rows="20" ></textarea></td>