gmaps4rails隐藏显示侧边栏

时间:2013-04-25 04:06:34

标签: ruby-on-rails-3 gmaps4rails

因此,如果标记隐藏在地图上,则其侧边栏项目将保持可见状态。我阅读了整个gem,我没有看到任何隐藏相应侧边栏元素的功能。有没有人知道这个?

2 个答案:

答案 0 :(得分:0)

要自定义gmap4rails,您需要学习并完成支持中提供的所有api或方法。您也可以使用params隐藏show sidebar以下方法

  def gmaps4rails_sidebar
    "#{self.name} #{self.gps}"
  end

此处还提供了更多链接https://github.com/apneadiving/Google-Maps-for-Rails/wiki。请参考。

答案 1 :(得分:0)

function hide(category) {
  var regEx = new RegExp("[" + category + "]")
  for (var i=0; i<Gmaps.map.markers.length; i++) {
    if (Gmaps.map.markers[i].cat) {
      if (Gmaps.map.markers[i].cat.match(regEx)) {
        Gmaps.map.hideMarker(Gmaps.map.markers[i]);
        $('a#' + Gmaps.map.markers[i].id).closest('li').hide();
        Gmaps.map.visibleInfoWindow.close();
      }
    }
  }
  // == clear the checkbox ==
  document.getElementById(category+"box").checked = false;
}

做了那个...用相应的show方法。效果很好!

相关问题