【问题标题】:Filter from Fusion Table to Google Maps v3 Checkbox Issues从 Fusion Table 过滤到 Google Maps v3 复选框问题
【发布时间】:2012-11-22 23:52:15
【问题描述】:

我尝试使用 Fusion 表并使用复选框在不同的过滤器之间切换,而不是使用一百万 kmls(大约十分钟后会停止显示)。这对于前两个非常有效,但现在其他类别将不会显示,除非第一个或两个被单击并单击关闭。显然有些不对劲。我从 Google 示例(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/

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

【问题讨论】:

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


    【解决方案1】:

    Annnnnd 我是个白痴。解决方案是不要用大写字母或空格或标点符号来命名您的 Fusion Table 列(这将成为您的 id、您的名称和您的值)。 Java 不喜欢它。

    【讨论】:

      猜你喜欢
      • 2013-05-06
      • 1970-01-01
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      • 2013-10-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多