4

I have a problem with data visualization from fusion table. For example I have the next code:

function initialize() {
    map = new google.maps.Map(document.getElementById('map_canvas'), {
        center: new google.maps.LatLng(38.71980474264242, -121.552734375),
        zoom: 5,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    fusionLayer = new google.maps.FusionTablesLayer({
        query: {
            select: 'column',
            from: 'tableId',
            where: "a huge where clause"
        },
        map: map
    });
}

As you can see there I have a "huge where clause" in 'where' option of the query. But during initialization, google maps API performs a lot of GET requests to URI something like this:

http://mt1.googleapis.com/mapslt?hl=en-US&lyrs=ft:tableId|sc:'column'|sg:{huge_where_clause}&x=6&y=13&z=5&w=256&h=256&source=apiv3&token=74442

All of that requests fails with the status code 414: Request-URI Too Large.

So, my question: is it possible to query fusion table with huge where clauses or using POST requests instead of GET?

davidkonrad
  • 83,997
  • 17
  • 205
  • 265
oaleynik
  • 655
  • 5
  • 19
  • How huge are you talking about? Perhaps there's a way to optimize your where condition. I have an app which allows numerous where conditions but have never run into this 414 response. – Eric Bridger Oct 12 '12 at 21:21
  • About 2400 characters long. For example, we have a vendor, which service covers many small areas along US territory. So, in the simplest situation we should generate where clause which will look something like this: zip IN ('zip1', 'zip2', ..., 'zipN', ...). If vendor covers more than 300 areas, our 'where clause' will be too large. – oaleynik Oct 15 '12 at 09:55
  • Nevertheless, what do you mean under 'numerous where conditions'? Does Fusion Tables API allows numerous where conditions? – oaleynik Oct 15 '12 at 09:58
  • I have tried to split our long where clause to three different layers, but, for unknown reasons, google maps API joins all where clauses to one request to http://mt{n}.googleapis.com/mapslt. – oaleynik Oct 15 '12 at 10:05
  • I am running into the same issue. My character lengths is a bit longer 4500 (the length of the escaped API call). I note if I knock it down to 2070sh it starts working again. Which I am not sure I can do. Alek have you had any luck since? P.S. Fusion tables does allow numerous WHERE conditions -- at least when we are talking about maps -- you can set styles differently for different WHERE conditions. You can style different parts of the map differently based on other values in the table. This is why my call is so long... – Adrian Cotter Oct 27 '12 at 03:36

1 Answers1

1

The GET URL's are limited to ~2k characters, and as you noted you can certainly create a complex WHERE clause that is longer, which causes this issue.

If you are just over the limit, one solution may be to rename your columns, so that they are less long.

Or, you maybe be able to simplify the query. As noted above this was one query that went over:

zip IN ('zip1', 'zip2', ..., 'zipN')

But you could potentially rewrite to save a lot of characters:

zip < zipN
jlivni
  • 4,759
  • 1
  • 19
  • 30
  • Thanks for your answer. I was trying to completely minify the columns names to something like a, b, c etc. But that was not enough. – oaleynik Dec 13 '12 at 12:39
  • Years ago I worked with US zipcode databases. Zipcodes are grouped by the first 3 digits, then the last two. So perhaps you could filter based on that? E.g. I now live in Portland ME. All zipcodes start with 041. Grew up in New York. Manhatten: 100XX, Flushing 113XX, etc. – Eric Bridger Dec 21 '12 at 01:47