通常对于一个层,我们可以在 onclick 事件引发时生成 InfoWindow。但是在这里我在单层中有许多多边形。因此,通过查询中的 where 条件,我们可以获得每个条件并为它们设置样式差异。但这里我需要的是,对于层的每个多边形,必须为 onclick 事件生成一个 InfoWndow。
这是我为图层中的每个多边形设置样式的代码。
var layer = new google.maps.FusionTablesLayer(
{
query: {
select: 'geometry',
from: 'myTableId'
},
styles: [
{
where: "Dist_id in ('0101001') and Insert_date='25/08/2012'",
polygonOptions: { strokeColor:"#0071bc",fillColor:"#0000FF",fillOpacity:0.2,strokeWeight:2,clickable:false }
},
{
where: "Dist_id in ('0101002') and Insert_date='25/08/2012'",
polygonOptions: { strokeColor:"#0071bc",fillColor:"#FF0000",fillOpacity:0.2,strokeWeight:2,clickable:false }
},
{
where: "Dist_id in ('0101003') and Insert_date='25/08/2012'",
polygonOptions: { strokeColor:"#0071bc",fillColor:"#00FF00",fillOpacity:0.2,strokeWeight:2,clickable:false }
},
{
where: "Dist_id in ('0101004') and Insert_date='25/08/2012'",
polygonOptions: { strokeColor:"#0071bc",fillColor:"#FF00FF",fillOpacity:0.2,strokeWeight:2,clickable:false }
},
{
where: "Dist_id in ('0101005') and Insert_date='25/08/2012'",
polygonOptions: { strokeColor:"#0071bc",fillColor:"#00FFFF",fillOpacity:0.2,strokeWeight:2,clickable:false }
}
],
map:map
});
现在我如何为图层的每个多边形生成信息窗口。