从Fusion Table过滤到Google Maps v3复选框问题

时间:2012-12-05 07:38:12

标签: java google-maps-api-3 checkbox where google-fusion-tables

我没有使用一百万公里(在10个左右后会停止显示),而是尝试使用Fusion表并使用复选框在不同的过滤器之间切换。这对于前两个非常有效,但是现在其他类别将不显示,除非单击并单击前一个或两个。显然有些不对劲。我偷了谷歌示例中的代码(IN,关于披萨店),但这并没有用于扩展。另外,我有一个不断扩大的侧边栏,这并没有帮助我控制它。

我创造了很多这些:

google.maps.event.addDomListener(document.getElementById('Food Manufacturing/Wholesale'),
        'click', function() {
          filterMap(layer, tableId, map);
    });

然后是这个:

      function filterMap(layer, tableId, map) {
    var where = generateWhere();

    if (where) {
      if (!layer.getMap()) {
        layer.setMap(map);
      }
      layer.setOptions({
        query: {
          select: 'Longitude',
          from: tableId,
          where: where
        }
      });
    } else {
      layer.setMap(null);
    }
  }

  // Generate a where clause from the checkboxes. If no boxes
  // are checked, return an empty string.
  function generateWhere() {
    var filter = [];
    var stores = document.getElementsByName('store');
    for (var i = 0, store; store = stores[i]; i++) {
      if (store.checked) {
        var storeName = store.value.replace(/'/g, '\\\'');
        filter.push("'" + storeName + "'");
      }
    }
    var where = '';
    if (filter.length) {
      where = "'Displ_Type' IN (" + filter.join(',') + ')';
    }
    return where;
  }

  google.maps.event.addDomListener(window, 'load', initialize);

然后这些在div体内:

<li><a1><input type="checkbox" name="store" id="cafe" value="Cafe">Cafe</a1></li>
    <li><a1><input type="checkbox" name="store" id="Catering" value="Catering"> Catering</a1></li>
    <li><a1><input type="checkbox" name="store" id="Cooking School" value="Cooking School"> Cooking School</a1></li>

另外 http://jsfiddle.net/pwhqq/1/

Fusion表是: https://www.google.com/fusiontables/DataSource?snapid=S7955100ZHL

1 个答案:

答案 0 :(得分:0)

Annnnnd我是个白痴。解决方案不是将您的Fusion Table列(将成为您的ID,您的名称和值)命名为大写字母或空格或标点符号。 Java并不善待它。