-1

I'm trying to apply multiple styles to a Google Fusion Table Layer.

This works and colors all polygons that are in an array to the blue color:

layer = new google.maps.FusionTablesLayer({
      map : map,
      query : {
        select : "geometry",
        from : "1gwSN6n_00uZ7YuAP7g4FiUiilybqDRlRmWJrpvA"
      },

    styles: [{
     polygonOptions:
      {
              fillColor: "#ffffff",
              strokeColor: "#bcbcbc",
              fillOpacity: ".75"
      }
    },
    {
          where: whereClause,
          polygonOptions: {
            fillColor: "#0D58A6"
          }
    }

    ]

    });
layer.setMap(map);

But this doesn't work -- no polygons even appear on my map:

layer = new google.maps.FusionTablesLayer({
      map : map,
      query : {
        select : "geometry",
        from : "1gwSN6n_00uZ7YuAP7g4FiUiilybqDRlRmWJrpvA"
      },

    styles: [{
     polygonOptions:
      {
              fillColor: "#ffffff",
              strokeColor: "#bcbcbc",
              fillOpacity: ".75"
      }
    },
    {
          where: whereClause,
          polygonOptions: {
            fillColor: "#0D58A6"
          }
    }
    ,
    {
          where: whereClause,
          polygonOptions: {
            fillColor: "#ff0000"
          }
    }
    ]

    });
layer.setMap(map);

Never mind that I'm coloring the same thing one color and then another--I just want the second style to work. When I take out the second style, all is fine. I put in the second style--and no polygons any more.

Can someone tell me what I'm doing wrong, please?

LauraNMS
  • 2,720
  • 7
  • 39
  • 73

1 Answers1

1

This may very well be an error (the exact same where clause with two different styles):

{
      where: whereClause,
      polygonOptions: {
        fillColor: "#0D58A6"
      }
}
,
{
      where: whereClause,
      polygonOptions: {
        fillColor: "#ff0000"
      }
}

I would expect the where clause to have to be unique.

UPDATE:

My current guess is that you are running into a query limit on the size of the data sent back to the server.

Each of the whereClauses works independently

If this is the issue (the query string is too big), mapping the "COUSUBFP" codes to something shorter (3 decimal digits or two hex digits), might make it work (or for that matter, just truncating the leading "0's").

 03320 -> 0
 03608 -> 1
 etc.
geocodezip
  • 158,664
  • 13
  • 220
  • 245
  • I've tried it with two different where clauses, with the same result, though. – LauraNMS Dec 05 '12 at 18:10
  • what is the value of whereClause? Is it valid for the table? – geocodezip Dec 05 '12 at 18:29
  • I build whereClause programmtically. In this case, it is "'COUSUBFP' IN (03320, 03608, 03928, 03932, 05312, 05504, 07000, 07976, 07992, 08008, 08416, 11336, 11680, 12496, 13608, 13704, 16144, 16848, 19576, 19856, 20432, 21024, 21444, 21712, 22520, 23616, 24160, 26592, 29432, 33592, 35424, 37000, 42392, 46072, 46256, 46264, 49920, 50528, 51696, 51744, 52320, 53136, 54816, 55488, 55840, 56384, 59032, 59152, 60712, 61000, 63408, 64240, 68388, 69776, 74648, 75816, 76104, 77912, 80032, 80040, 80600, 83200, 83512, 84144, 84440, 85184, 85188, 85496)" – LauraNMS Dec 05 '12 at 18:43
  • whereClause definitely works. whereClause2 is 'COUSUBFP' IN (00724, 05216, 05520, 06064, 08064, 08624, 13392, 15216, 17048, 22576, 22992, 23000, 25400, 25904, 26896, 27120, 27552, 27608, 29592, 31256, 32328, 32624, 32832, 33312, 36808, 37955, 39312, 39624, 42368, 43064, 43408, 47696, 45900, 50784, 55016, 56088, 56392, 29732, 60272, 61328, 61536, 62320, 64528, 65352, 66264, 66320, 69376, 69400, 69416, 69584, 72160, 72400, 72568, 72960, 72968, 76560, 77272, 79274, 82800, 82848, 84512, 84704) – LauraNMS Dec 05 '12 at 18:43
  • I want all the polygons that are in the whereClause to be colored one color, all those that are in the whereClause2 to be colored another color. – LauraNMS Dec 05 '12 at 18:44
  • There is a problem with the second half of whereClause2. – geocodezip Dec 05 '12 at 19:14
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/20656/discussion-between-lauranms-and-geocodezip) – LauraNMS Dec 05 '12 at 19:45