Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
823 views
in Technique[技术] by (71.8m points)

javascript - "WHERE" clauses being ignored in Fusion Table Layer in Google Maps

I am trying to use a Google Fusion table as a layer in Google maps via API. Just adding the layer to the Google Map using FusionTableLayer() works fine. I can see the map and all. The "fun" begins when I try to apply a filter (i.e. a "where clause") to the select query or to the Styles section. The filters just do not work! It does not throw any error. Map keeps on working. But the result set is not filtered down--as if the where clause wasn't even there. The same symptoms for the 'where' clause used for the Styles section. It is completely ignored. I have three different styles, which I want applied based on filter conditions. All of the those are ignored. The strange thing is that the very last style section listed in the Styles block gets applied to ALL features in the fusion table layer. I verified it by switching the sections around. I tried replacing the actual field names by the references like "col10", but that didn't make any difference.

What am I missing? How can I "enable" the use of WHERE clauses in my FusionTableLayer so that they get applied both in the Select query, and also in the Styles sections?

Note: in the code snippet below, the (//) comments were inserted for this post. These comments do not exist in the actual page/code I am developing.

  layer = new google.maps.FusionTablesLayer({
  map: map,
  heatmap: { enabled: false },
  query: {
     select: "col11",
     from: "1D6d93-0iT2zUCw8IvkbpDPYDx2-jA0ZAWXi07mQD",
     //the following filter in select query does not work! 
     //I replaced col10 with actual field name (shift_id) but still EVERYTHING from the table is returned
     where: "col10 <= 3" 
  },
        styles: [{
          //this where clause has no effect. I've tried replacing shift_id with col10.
          where: "((shift_id != 1) AND (shift_id != 2))",
          polylineOptions: {
            strokeColor: "#FFFFFF",
            strokeWeight: "3"  }
        }, {
          //this where clause has no effect. I've tried replacing shift_id with col10.
          where: "shift_id == 1",
          polylineOptions: {
            strokeColor: "#FF0000",
            strokeWeight: "3"  }
        }, {
          //this where clause has no effect. I've tried replacing shift_id with col10.
          //whichever of these three blocks is listed last is the one that gets applied to the layer.
          where: "shift_id == 2",
          polylineOptions: {
            strokeColor: "#ffbf00",
            strokeWeight: "3"  }
        }] 
});
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...