More than one conditions in Where clause of Fusion

2019-08-28 23:55发布

I am writing with reference to an earlier question of mine, which also had to do with the use of Where clauses for Fusion Table Layer in Google Maps. Link to earlier question. I have noticed that if the Where clause in Styles section has more than one filtering conditions in it, it is ignored altogether. Google Map/Fusion Tables Layers then ends up applying that Style to ALL of the features contained in that Fusion table. You can remove a filtering condition from the Where clause to make it a single filter where clause, and it then works as expected so I am pretty sure that it doesn't like multiple filtering condition in the SAME where clause (or the way I am writing it).

Here is an example that illustrates this behavior:

    layer = new google.maps.FusionTablesLayer({
  map: map,
  options: {
    templateId: 2
  },
  heatmap: { enabled: false },
  query: {
    select: "geometry",
     from: "1D6d93-0iT2zUCw8IvkbpDPYDx2-jA0ZAWXi07mQD",
  },      
        styles: [{

          //note multiple filters in the same Where clause.

          where: "((SHIFT_ID != 1) AND (SHIFT_ID != 2))",

          //you'd expect the following Style option applied to only those map features
          //which met above criteria. However, they are applied to ALL map features.

          polylineOptions: {
            strokeOpacity: 0.70,
            strokeColor: "#FFFFFF",
            strokeWeight: "5"  }

     //if Where clause is reduced to just having one filter, it works fine.
     //For example, either of the following two work fine by themselves.
     //where: "SHIFT_ID != 1"   --OR--
     //where: "SHIFT_ID != 2"    etc.

        }] 
});

1条回答
乱世女痞
2楼-- · 2019-08-29 00:35

Geocodezip was right; query was invalid.

This is what I have been able to determine re use of queries for Fusion Tables.

  1. Can have multiple fields/filters in one where clause.
  2. Can't use brackets "()" for Boolean logic.
  3. Instead of !=, use NOT EQUAL TO
  4. For NULL values, check equality with '' (empty string).
  5. Field names are case sensitive.

https://developers.google.com/fusiontables/docs/v2/sql-reference

查看更多
登录 后发表回答