我正在尝试基于单击(使用我的 google.maps.event.addListener() )从两行(POTENTIAL_ 和 TOTAL_ROOF)创建数据的柱形图。
所以基本上一行数据会显示在图表上——基于用户的点击。
谁能帮我除掉杂草?……
js函数1:
google.load('visualization', '1', {packages: ['corechart']});
function drawVisualization() {
var queryText = encodeURIComponent("SELECT POTENTIAL_, TOTAL_ROOF, BLDG_ID FROM 1DGswslbC5ijqWHPJvOH1NH7vltkZIPURJun_L5I");
google.visualization.drawChart({
"containerId" : "visualization_div",
"dataSourceUrl" : 'https://www.google.com/fusiontables/DataSource?docid=',
"query" : "SELECT POTENTIAL_, TOTAL_ROOF FROM 1DGswslbC5ijqWHPJvOH1NH7vltkZIPURJun_L5I",
"chartType" : "ColumnChart"
})};
js函数2:
// Function call: Click Listener on layer using jquery
google.maps.event.addListener(layer, 'click', function(e, drawVisualization) {
$("#roof-panel-area").html(
'<p><strong>Total Roof Area (sqft)</strong>: ' + ' ' + Math.round(e.row['TOTAL_ROOF'].value) +
'<br><strong> Potential Roof Area (sqft)</strong>:' + ' ' + Math.round(e.row['POTENTIAL_'].value) +
'<br><strong> Pitched or Flat Roof (?)</strong>:'+ ' ' + e.row['PITCHED_OR'].value +
'<br><strong> # of Panels per Roof Area :</strong>' + ' ' + Math.round(e.row['NUMBER_OF_'].value) + '</p>');
});
layer.setMap(map);
html:
<div id="sidebar-content-area" style="padding:5px;">
<div id="intro" style="text-align: center; margin-top: 20px; display: none;">
<p><i>Buildings are symbolized according to roof size, and the possibility of increased panel placement.</i><p>
</div>
<div id="overview" style:"">
<h3>Building Overview:</h3>
<p id ="roof-panel-area"></p>
<div id = "visualization_div"></div>
</div>