Search code examples
ruby-on-rails-3gmaps4rails

gmaps4rails hide show sidebar


So, if markers are hidden on the map, their sidebar item stays visible. I read through the entire gem, and I didn't see any functionality for also hiding the corresponding sidebar element. Anyone have a clue on this one?


Solution

  • 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;
    }
    

    did that... with a corresponding show method. works nicely!