Google Maps Fusion Table 图层不应用基于文本列的条件样式
我想根据具有三个不同字符串值的列应用不同的标记样式。查询工作正常,如果脚本中没有定义样式,它会使用 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>
I'd like to apply different marker styles depends on the column with three different string values. Query works fine, it uses FT styles if no styles defined in the script, but if there is conditional logic implemented - map gets the layer with "Data still maybe loading" label and no error produced.
The code is:
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很高兴看到您正在使用 FT 造型。这是一个很棒的功能。
您的代码只有一个问题。您在表格中查找的列实际上称为
Locations
。将您的查询更改为:
一切正常。
Cool to see that you're using FT styling. It's a great feature.
There's only one problem with your code. The column you're looking for in your table is actually called
Locations
.Change your query to this:
and everything works.