我想应用不同的标记样式取决于具有三个不同字符串值的列。查询工作正常,如果脚本中没有定义样式,则使用FT样式,但如果实现了条件逻辑 - map将使用“Data still maybe loading”标签获取图层,并且不会产生错误。
代码是:
<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>
答案 0 :(得分:1)
很酷,看到你正在使用FT造型。这是一个很棒的功能。
您的代码只有一个问题。您在表格中查找的列实际上称为Locations
。
将您的查询更改为:
query: { select: 'Locations', from: '2825956' },
一切正常。