我試圖在InfoWindow(Fusion Table圖層)中顯示圖表(Google Chart API),但問題出在容器上「未捕獲錯誤:容器爲空或未定義 「。每當我嘗試在InfoWindow中包含div時。將Google圖表添加到FusionTableLayer infowindow
我試圖解決在此基礎上解決這一問題,但它不能與融合表工作 Add a google chart to a infowindow using google maps api
請幫
<script type="text/javascript">
google.load('visualization', '1', {packages: ['corechart']});
function drawVisualization() {
var queryText = encodeURIComponent("SELECT Year, Austria, Bulgaria, Denmark, Greece FROM 641716");
google.visualization.drawChart({
"containerId": 'visualization_div',
"dataSourceUrl": 'https://www.google.com/fusiontables/gvizdata?tq=',
"query":"SELECT Year, Austria, Bulgaria, Denmark, Greece FROM 641716",
"refreshInterval": 5,
"chartType": "PieChart",
"options": {
"title":"Yearly Coffee Consumption by Country",
"vAxis": {"title": "Year"},
"hAxis": {"title": "Cups"}
}
});
}
function initialize() {
var map = new google.maps.Map(document.getElementById('map-canvas'), {
center: new google.maps.LatLng(29.296435107347698, -29.54822280000008),
zoom: 2,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var layer = new google.maps.FusionTablesLayer({
query: {
select: 'col0',
from: '1PoUAVtdJKOKnJT_ZYkoM7yDpGw-wNJMHXakPeC0'
},
map: map
});
google.maps.event.addListener(layer, 'click', function(e) {
drawVisualization(this);
e.infoWindowHtml += "<div id='visualization_div'></div>";{
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
PS。
還有一件事!可以從一行數據中顯示圖表。在我點擊一個國家的例子中?
謝謝你的工作完美!有時需要0,001秒來加載,但這不是一個問題在這裏。 – PiotrK