如果要在頁面加載時打開InfoWindow,可以簡單地在頁面加載時調用的JavaScript函數中執行此操作(請參見下面的initialize()函數末尾)。
要僅從融合表中獲取特定行,可以將「where」參數添加到FusionTablesLayer查詢中,請參閱下面的代碼。
我修改這個例子中你提到,顯示這兩個東西:
<!DOCTYPE html>
<html>
<head>
<title>FusionTableLayer with WHERE clause and InfoWindow</title>
<meta charset="utf-8">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">
function initialize() {
var chicago = new google.maps.LatLng(41.948766, -87.691497);
var map = new google.maps.Map(document.getElementById('map_canvas'), {
center: chicago,
zoom: 11,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var layer = new google.maps.FusionTablesLayer({
query: {
select: 'address',
from: '198945',
where: 'ridership > 5000'
}
});
layer.setMap(map);
var infoWindow = new google.maps.InfoWindow();
infoWindow.setContent('Hello Chicago!');
infoWindow.setPosition(chicago);
infoWindow.open(map);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:600px; height:400px"></div>
</body>
</html>
關於信息窗口和Fusion Tables的更多信息:
來源
2012-03-27 21:33:26
Odi