Javascript 谷歌高程服务API(英尺)

Javascript 谷歌高程服务API(英尺),javascript,jquery,google-maps,google-visualization,google-elevation-api,Javascript,Jquery,Google Maps,Google Visualization,Google Elevation Api,我正在使用GoogleElevationAPI在GoogleMaps上沿着路径获取高程数据,然后在GoogleVisualization柱状图上绘制 我获取数据的代码如下: function createUpdateProfile(){ var path=[]; for (var i = 0; i < markers.length; i++) { path.push(markers[i].getPosition()); }; var elevator = new

我正在使用GoogleElevationAPI在GoogleMaps上沿着路径获取高程数据,然后在GoogleVisualization柱状图上绘制

我获取数据的代码如下:

function createUpdateProfile(){
  var path=[];
  for (var i = 0; i < markers.length; i++) {
    path.push(markers[i].getPosition());
    };
  var elevator = new google.maps.ElevationService;
  // Draw the path, using the Visualization API and the Elevation service.
  displayPathElevation(path, elevator, map);
  }

function displayPathElevation(path, elevator, map) {
  elevator.getElevationAlongPath({
  'path': path,
  'samples': 256
  }, plotElevation);
  }

function plotElevation(elevations, status) {
 var chartDiv = document.getElementById('elevation_chart');
if (status !== google.maps.ElevationStatus.OK) {
 // Show the error code inside the chartDiv.
chartDiv.innerHTML = 'Cannot show elevation: request failed because ' +
    status;
 return;
 }
 // Create a new chart in the elevation_chart DIV.
 var chart = new google.visualization.ColumnChart(chartDiv);

 // Extract the data from which to populate the chart.
 // Because the samples are equidistant, the 'Sample'
 // column here does double duty as distance along the
 // X axis.
 var data = new google.visualization.DataTable();
 data.addColumn('string', 'Sample');
 data.addColumn('number', 'Elevation');
 for (var i = 0; i < elevations.length; i++) {
  data.addRow(['', elevations[i].elevation]);
}

 // Draw the chart using the data within its DIV.
 chart.draw(data, {
  height: 200,
 legend: 'none',
 titleY: 'Elevation (m)'


 });
函数createUpdateProfile(){
var路径=[];
对于(var i=0;i

返回的数据以公制(米)为单位,如何将返回的高程数据转换为英尺,然后将其发送到图表?

要将米转换为英尺,请乘以英尺/米

for (var i = 0; i < elevations.length; i++) {
  data.addRow(['', elevations[i].elevation*3.28084]);
}
for(变量i=0;i
谢谢你的回复。我经常使用你的网站来参考谷歌地图!我试过了,但我得到了以下错误:“未捕获错误:如果参数被赋予addRow,它必须是一个数组,或者为null”非常感谢!!如果你能看看我的另一个问题,关于你网站上的代码,我会非常感激。