2013-04-25 84 views
0

因此,如果標記隱藏在地圖上,它們的邊欄項保持可見。我通讀了整個寶石,並且我沒有看到任何隱藏相應側邊欄元素的功能。任何人都有這方面的線索?gmaps4rails隱藏顯示邊欄

回答

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

做到了......用相應的顯示方法。很好地工作!

0

要定製gmap4rails,您需要學習並瀏覽支持中提供的所有api或方法。您也可以使用PARAMS下面給出的方法

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

而且更多的鏈接在這裏https://github.com/apneadiving/Google-Maps-for-Rails/wiki給出隱藏顯示側邊欄。請參閱。

+1

嗯。謝謝,但這並不能回答我的問題。我非常瞭解如何自定義側邊欄。你展示的例子實際上已經過時了。您現在可以(也應該)從控制器構建所有內容 - https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Controller。如果單個標記對地圖隱藏,我正在專門查看側邊欄中的單個條目。 – Dudo 2013-04-25 17:38:17