I have seen example here how to use map.fitBounds on fusiontablelayer here and here , but I think it works with markers table only. Its impossible to parse the lat and long when the vertex coordinates are in the geometry column as in a kml polygon layer.

Is there a solution to use fitBounds or other function to zoom to the extent of a kml polygon fusion table layer?


Yes. You are correct. Currently the functionality to zoom/fit bounds does not exist for polygon or line data from fusion tables. You will need to use the GVIZ (Google Visualization API) and the geoxml3 parser. I used some of the code from the following applications. One is a polygon example and the other is a line/arc example.

There is a post in the Google Fusion Tables group pointing out that the functionality is not there (yet). I had the same problem and I managed to get my application working recycling some of the code from the examples above. Hope it helps.

Update: Google Fusion Tables is being turned down in December 2019.


Consider moving to GeoJSON for markers/lines and TopoJSON for complex polygons.

| improve this answer | |
  • Thank you for your answer, it works for me. However, have you found a way to have the extent of all rows/features of the kml and not only one at a time in order to have the bounds of the entire table? – DemarsM Feb 26 '13 at 20:56
  • @DemarsM. Fusion Tables uses the ST_INTERSECTS to find map features within a defined area. This may work. I have not tested it myself. I need to do the same for some of my queries so I will give this a try soon. I thought it was deprecated but apparently it is not. Failing that I would think that creating a KML that is a 'box' containing your area and adding to the table may work for your selection(s). Another possibility is parsing the rows necessary to capture the entire area. These are just guesses/suggestions at this point. – danagerous Feb 27 '13 at 22:55
  • I dont know about ST_INTERSECTS. If you can do something interresting with that let me know. However, take a look a the second example, the one with line/arc. It shows how to zoom on the entire kml using union(). It works with polygon kml too. – DemarsM Mar 1 '13 at 1:02
  • Thanks for pointing that out. I totally missed that (or more like was not looking for it at the time). I'll give it a try. Cheers. – danagerous Mar 1 '13 at 19:24
  • any code snippet for the union solution you can post here? thx – Val Neekman May 19 '13 at 3:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.