0

我想应用不同的标记样式取决于具有三个不同字符串值的列。查询工作正常,如果脚本中没有定义样式,它会使用 FT 样式,但如果实现了条件逻辑 - 地图会获取带有“数据仍然可能正在加载”标签的图层并且不会产生错误。

代码是:

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
        var map,layer;
        google.load('maps', '3', { other_params: 'sensor=false' });
        google.setOnLoadCallback(function(){
        var cp = new google.maps.LatLng(42.87, 74.57);
        map = new google.maps.Map(document.getElementById('map'), {
          center: cp,
          zoom: 7,
          mapTypeId: 'roadmap'
        });
        layer = new google.maps.FusionTablesLayer({
          query: { select: 'Locations (oblast, rayon, village)', from: '2825956' },
          // if the styles definition below exists map doesn't get any data layer applied
          styles: [
            { markerOptions: { iconName: 'wht_blank'} },
                { where: "'Thematic area' = 'Environment and Sustainable development'", markerOptions: { iconName: 'grn_blank' }},
                { where: "'Thematic area' = 'Democratic Governance Programme'", markerOptions: { iconName: 'blu_blank' }},
                { where: "'Thematic area' = 'Poverty Reduction'", markerOptions: { iconName: 'red_blank' }}
            ]
        });
        layer.setMap(map);
    });
</script>
4

1 回答 1

1

很高兴看到您正在使用 FT 样式。这是一个很棒的功能。

您的代码只有一个问题。您在表中查找的列实际上称为Locations.

将您的查询更改为:

query: { select: 'Locations', from: '2825956' },

一切正常。

于 2012-02-08T21:18:13.840 回答