I'm trying to apply the same code as this exmaple to zoom the google map to a KML Markers loaded into Fusion Table Layer.
The example code works for KML Polygon loaded into Fusion Table Layer but not for markers. Does anyone know how to apply that to KML markers?
kml example:
<Point><coordinates>-59.028645,50.772916,0.0</coordinates></Point>
script:
query = "SELECT * FROM 1eiOWq49sR8DXdymYALNdItE0uf-f4mNRbyJOVOU";
query.send(zoom2query);
function zoom2query(query) {
// zoom and center map on query results
//set the query using the parameter
var queryText = encodeURIComponent(query);
var query = new google.visualization.Query('http://www.google.com/fusiontables/gvizdata?tq=' + queryText);
//set the callback function
query.send(zoomTo);
}
function zoomTo(response) {
if (!response) {
alert('no response');
return;
}
if (response.isError()) {
alert('Error in query: ' + response.getMessage() + ' ' ++ response.getDetailedMessage());
return;
}
FTresponse = response;
//for more information on the response object, see the documentation
//http://code.google.com/apis/visualization/documentation/reference.html#QueryResponse
numRows = response.getDataTable().getNumberOfRows();
numCols = response.getDataTable().getNumberOfColumns();
var geoXml = new geoXML3.parser();
var bounds = new google.maps.LatLngBounds();
for (var i = 0; i < numCols; i++){
if (FTresponse.getDataTable().getColumnLabel(i) == 'geometry') {
var ColIndex = i;
}
}
if (!ColIndex){
alert('Geometry column "geometry" not found.')
}
for (var i = 0; i < numRows; i++){
var bounds = new google.maps.LatLngBounds();
for(i = 0; i < numRows; i++) {
var kml = FTresponse.getDataTable().getValue(i,ColIndex);
geoXml.parseKmlString("<Placemark>"+kml+"</Placemark>");
bounds.union(geoXml.docs[i].bounds);
}
// zoom to the bounds
map.fitBounds(bounds);
}

