Search code examples
google-maps-api-3google-fusion-tables

Possible to pass a google.visualization.Query into the google.maps.FusionTablesLayer constructor?


The constructor for google.maps.FusionTablesLayer takes a query parameter, which contains the same information as can be found in a google.visualization.Query, as I understand it.

I have some code which constructs a FusionTablesLayer (which will submit a query to the API) and some other code that fetches data based on a Query. This will, I think, result in two GET requests for the same data. I think it's best if I try to avoid this double-query if I can.

Any ideas on how to do this? If I could construct a Query and pass it into the constructor for FusionTablesLayer somehow, that might work. But the two documentation pages don't reference each other.

EDIT

I should add that in the case I'm working with, Google is actually constructing the map tiles on the server. I did try pulling down the polygons and working with them but the data was massive. If you are thinking of doing anything along these lines, I suggest you don't do it in the browser.


Solution

  • Although you are dealing with the same data, the two concepts are very different. When you use a google.visualization.Query, you actually transfer raw data from a Fusion Table to the client. Normally you would use this data for a visualization of any kind.

    When you specify a query for google.maps.FusionTablesLayer you can only get the location column. And this data is not raw, it is already wrapped in a layer which you can add to a map. That's basically it. You can add some styling and define what other data you want to display in the info window, but that's it.

    It's maybe a little bit misleading that they both are called query, but actually they are very different.