如果您阅读:https ://developers.google.com/chart/interactive/docs/reference#google.visualization.arraytodatatable
你会发现一个函数getValue(rowIndex, columnIndex)
在我的示例中,我有一个纬度/经度列表,我确保其中有效,然后渲染。单击纬度/经度后,我想对经度/经度做一些事情。向下滚动到底部查看 DataTable.getValue() 的用法
var dataTable = new google.visualization.DataTable();
dataTable.addColumn('number', 'Latitude');
dataTable.addColumn('number', 'Longitude');
dataTable.addColumn('string', 'Name');
$.each(data, function(i, o) {
var lat = parseFloat(o.lat);
var lon = parseFloat(o.lon);
var name = o.name;
if(LIB.Location.isLatLonValid([lat, lon])) {
var row = [lat, lon, name];
dataTable.addRow(row);
}
});
var options = {
width : 550
,height : 240
,region: country
,legend: 'none'
,showTip : false
,mapType : 'normal'
};
var chart = new google.visualization.Map(document.getElementById('location_pin_chart'));
chart.draw(dataTable, options);
// handle clicking on pin
google.visualization.events.addListener(chart,'select', function(e) {
var selection = chart.getSelection();
var lat = dataTable.getValue(selection[0].row, 0); // HERE is where I get the value!
var lon = dataTable.getValue(selection[0].row, 1);
alert(lat + ", " + lon);
});