More than one conditions in Where clause of Fusion Table Layer ignored in Styles

旧时模样 提交于 2019-12-12 01:17:40

问题


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:


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



来源:https://stackoverflow.com/questions/33711568/more-than-one-conditions-in-where-clause-of-fusion-table-layer-ignored-in-styles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!