0

谢谢大家的回答:@ODI - 我的最终要求是我想触发上述查询并首先找到相关国家并为其着色,然后(现在不是小鬼)是在地图上显示这个计数。我正在尝试你提到的建议。

@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>
4

2 回答 2

1

根据SQL 参考,计数语法只是 count(),而不是 count(column_name)。

于 2012-08-06T18:30:27.170 回答
0

user1224571 是正确的。

尝试:

query: {
  select: 'master_narrative_name, (count())',
  from: '1hFPiPmQilakQ4zESVCJqq9ENmeo5e_EJXy_Usy8',
  where : "master_narrative_name IN ('Pharaoh','Badr')"  GROUP BY master_narrative_name},
于 2012-08-06T19:01:53.710 回答