我有一个方法可以查询州边界的公共Fusion表之一。我想做的是以不同的颜色突出威斯康星州,并改变伊利诺伊州的填充水平。这是代码:
layer = new google.maps.FusionTablesLayer(531237, {
query: "select geometry from 531237 WHERE STATE_ABBR in (" + states + ") " ,
styles: [
{ where: "STATE_ABBR = 'WI'", polygonOptions: { fillColor: "#0000FF" } },
{ where: "STATE_ABBR = 'IL'", polygonOptions: { fillOpacity: 1.0} }
]
});
layer.setMap(map);
当查询返回时,威斯康星州和伊利诺伊州仍然是与所有其他州相同的突出显示颜色。我试图设计风格是否存在语法上的错误?
答案 0 :(得分:2)
你想要更像这样的东西:
layer = new google.maps.FusionTablesLayer({
query: {
select: 'geometry',
from: '531237',
where: "STATE_ABBR in (" + states + ") "
},
styles: [
{ where: "STATE_ABBR = 'WI'", polygonOptions: { fillColor: "#0000FF" } },
{ where: "STATE_ABBR = 'IL'", polygonOptions: { fillOpacity: 1.0} }
]
});