謝謝大家的回答: @ODI - 我的最終需求是我想解僱上述查詢並首先查找相關國家併爲它着色,然後(現在不是imp)就是在地圖上顯示這個數字。 我正在嘗試你提到的建議。Google fusion table - 在融合表中處理「group by」和「count(col_name)」函數
@ user1224571 - 謝謝你。
@Eric - 其實你查詢發佈沒有工作。請在下面找到工作代碼。如果你添加group by子句它不會工作。
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="UTF-8">
<title>Fusion Tables Layer Example: Basic Fusion Tables Layer</title>
<link href="http://code.google.com/apis/fusiontables/docs/samples/style/default.css"
rel="stylesheet" type="text/css">
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
var map;
function initialize() {
map = new google.maps.Map(document.getElementById('map-canvas'), {
center: new google.maps.LatLng(44.0718, -2.768555),
zoom: 2,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var layer = new google.maps.FusionTablesLayer({
query: {
select: 'masterNarrative, (count())',
from: '1EsjL3dUyez6R8bXlJVtrL8Zq3esRsaoxcamKoVM',
where : "masterNarrative IN ('Pharaoh','Badr')"},
styles: [{
polygonOptions: {
fillColor: '#00FF00',
fillOpacity: 0.5
}
}]
//map: map
});
layer.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>
我猜你想要顯示的查詢文本,而不是在地圖上,右側的結果呢?如果是這樣,您不應該使用FusionTablesLayer,而應該查看[SQL參考](https://developers.google.com/fusiontables/docs/v1/sql-reference),也可以使用[gapi-client ](http://code.google.com/p/google-api-javascript-client/)。請參閱[此答案爲客戶端的示例用法](http://stackoverflow.com/a/11747872/549755)。 – Odi 2012-08-06 16:29:29
請在上面找到我的回覆作爲主要問題。我無法發佈我自己的回覆以獲取某些堆棧溢出限制 – ravi 2012-08-06 21:34:11
如果要使用FusionTablesLayer在地圖上顯示數據,則必須在選擇部分中添加位置列(請參見[FusionTablesLayer文檔](https://developers.google。 com/maps/documentation/javascript/layers#FusionTablesConstructor)。在你的情況下,這可能是「幾何」列。 – Odi 2012-08-07 05:11:41