Javascript 使用Google Fusion创建的标记的多个过滤器

Javascript 使用Google Fusion创建的标记的多个过滤器,javascript,google-fusion-tables,Javascript,Google Fusion Tables,我正在尝试基于融合表中的列为标记创建多个过滤器。我希望过滤器并行交叉工作,而不是单独过滤。这是我到目前为止的代码,我基于ERIC在这里找到的答案,但它对我不起作用: <!DOCTYPE html> <html> <head> <style> #map-canvas { width:500px; height:400px; } </style> <script src="http://code.jquery.com/jque

我正在尝试基于融合表中的列为标记创建多个过滤器。我希望过滤器并行交叉工作,而不是单独过滤。这是我到目前为止的代码,我基于ERIC在这里找到的答案,但它对我不起作用:

<!DOCTYPE html>
<html>
  <head>
<style>
#map-canvas { width:500px; height:400px; }
  </style>
<script src="http://code.jquery.com/jquery.min.js"></script> 
<script src="http://code.jquery.com/ui/1.8.18/jquery-ui.min.js"></script>
<script src="eq_jsonp.js"></script> 
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> 
<script type="text/javascript"src="http://maps.google.com/maps/api/js?sensor=false">         </script>
 <script type="text/javascript">
var map;
 var layerl0;
var tableid = 3470746;
var locationCol = 'Latitude'; 
  function initialize() {
  map = new google.maps.Map(document.getElementById('map-canvas'), {
    center: new google.maps.LatLng(28.2798935535169, -81.3486099243164),
    zoom: 13,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  });

 layerl0 = new google.maps.FusionTablesLayer({
    query: {
      select: "'latitude'",
      from: 3470746
    },
    map: map
  });
}
google.maps.event.addDomListener(window, 'load', initialize);

function doQuery(){

// collect WHERE conditions here for each search-string value

 var query = [];

 var searchString = '';

// I'd name my select id's something more descriptive, e.g. "damage_level" vs search-     string1, etc.

 searchString = document.getElementById('classification').value;

 if(searchString){

 query.push(" 'Roadway Classification:' = '" + searchString + "'");

}

searchString = document.getElementById('name').value;

if(searchString){

query.push("'Roadway Name:' = '" + searchString + "'");

}

// Date Filter

 searchString = dateFilter();

if(searchString){

query.push(searchString);

}

// Now build the WHERE clause by joining with ' AND ' all the conditions.

// Note: if nothing is in the where Fusion Tables will not object

var where = query.join(' AND ');
//alert(where);

var qryOpts = {

query: {

  select: "'latitude'",

  from: 3470746,


  }

};

layer.setOptions(qryOpts);
return;

}

// set all form inputs to null and call doQuery again.

function resetQuery(){

 $('#classification').val('');
 $('#name').val('');
 doQuery();
}

</script>
</head>
<body>
 <div id="map-canvas"></div>
 <form> 
<div style="margin-top: 10px;">
   <label>Roadway Classification</label>
   <select id="classification" onchange="doQuery;" title="Select Roadway by  Classification">
    <option value="">--Roadway Type--</option>
    <option value="Collector">Collector</option>
    <option value="Highway">Highway</option>
    <option value="Minor Arterial">Minor Arterial</option>
  </select>
 </div>
<div style="margin-top: 10px;">
  <label>Roadway Name</label>
  <select id="name" onchange="doQuery;" title="Select Roadway by Name">
    <option value="">--Roadway Name--</option>
    <option value="Neptune Rd">Neptune Rd</option>
    <option value="Partin Settlement Rd">Partin Settlement Rd</option>
    <option value="Shady Ln">Shady Ln</option>
   </select>
  <br>
  <input type="button" onclick="doQuery();" value="Search" />

  <input type="button" onclick="resetQuery();" value="Reset" />
  </form>
 </div>
</body>
</html>'
查看了您的,并且您的列名后面没有冒号。尝试:

query.push("'Roadway Name' = '" + searchString + "'");

此外,您没有将where子句添加到qryOpts:

var where = query.join(' AND ');


var qryOpts = {

query: {

  select: "'latitude'",

  from: 3470746,
  // WHERE clause was missing
  where: where

  }

};

埃里克,谢谢你的快速回复。好的,我已经根据你的评论修改了代码。但是,当我单击“搜索”时,过滤器不起作用,标记也不会相应更改。我不知道我哪里出错了!再次感谢Eric,你能进一步解释在where子句中写什么吗?应该在哪里:“道路分类”和“道路名称”?我对表格和脚本做了一些修改,删除了列名中的空格,并将列名保留为小写。但是,搜索按钮仍然无法正确启动!有什么问题吗?没有。应该是:“道路分类”='xxxxx'和“道路名称”='BBBBBBBB'很好,但由于我在每个栏中有多个选项,它将是“道路分类”='aaaa'、'bbbbbb'、'cccc'和“道路名称”='dddd'、'eeee'、'ffff'?
var where = query.join(' AND ');


var qryOpts = {

query: {

  select: "'latitude'",

  from: 3470746,
  // WHERE clause was missing
  where: where

  }

};