我正在构建我的第一个融合表,并将两个融合表带入谷歌地图——一个多边形和一个点。当您单击多边形或点时,我不想显示常规信息窗口,而是想从 Fusion Table 中提取一些数据,但它无法正常工作:
<script>
function initialize() {
var england = new google.maps.LatLng(53.2, -2);
map = new google.maps.Map(document.getElementById('map_canvas'), {
center: england,
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
layer1 = new google.maps.FusionTablesLayer({
query: {select: 'geometry', from: '1HgGUc72F2Wlp6dvy4GWvLyWrl1kC6aJhnM7jPyc'},
styles: [
{ where: "Score = 0", polygonOptions: { fillColor: "#cdcdcd", fillOpacity: 0.3 } },
{ where: "Score = 1", polygonOptions: { fillColor: "#FF0000", fillOpacity: 0.5 } },
{ where: "Score = 2", polygonOptions: { fillColor: "#FF7E00", fillOpacity: 0.5 } },
{ where: "Score = 3", polygonOptions: { fillColor: "#008000", fillOpacity: 0.5 } }],
options: {suppressInfoWindows: true},
map: map,
});
google.maps.event.addListener(layer1, 'click', function(e) {e.infoWindowHtml = "Score" + e.row['Score'].value;}
});
layer2 = new google.maps.FusionTablesLayer({
query: {select: 'postcode', from: '1bawAKwQAUGE4mzYSyw4lTbOcgp7MgIGOLROel8Y'},
options: {suppressInfoWindows: true},
map: map,
});
google.maps.event.addListener(layer2, 'click', function(e) {e.infoWindowHtml = "Postcode" + e.row['Postcode'].value;}
});
google.maps.event.addDomListener(window, 'load', initialize);
}
</script>
</head>
<body onLoad="initialize()">
<div id="map_canvas"></div>
</body>
</html>
在我添加 AddListener 和 addDomListeners 之前,一切运行良好,infowindows 被抑制。谁能帮我回到正轨,好吗?