how to open specific infowindow on page load in Fusion Table Layers
I am creating a map of some locations in Fusion Table Layers. I am using an example: http://code.google.com/intl/pl/apis/maps/documentation/javascript/examples/layer-fusiontables-simple.html
How can I open a specific infowindow on page load? How can I call to a specific row in Fusion tab开发者_运维百科le?
If you want to open an InfoWindow on page load, you can simply do that in a javascript function that is called on page load (see at the end of the initialize() function below).
To get only specific rows from a fusion table, you can add the "where" parameter to the FusionTablesLayer-query, see code below.
I modified the example you referred to, to show these two things:
<!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>
More Information about InfoWindows and Fusion Tables:
- Open InfoWindow on query
- Tutorial "Map sample data with Fusion Tables"
精彩评论