2013-10-16 220 views
0

我與谷歌地圖問題,當我使用jQuery標籤 - 我看到標籤 我要尋找的答案在這裏的一個地圖上只有很小的一部分,發現後,說要添加腳本。我說這沒有任何的運氣顯示谷歌地圖

我怎樣才能解決這個問題?

$(document).ready(function(){ 

    $("a.tab").click(function() { 
     $(".active").removeClass("active"); 

     $(this).addClass("active"); 

     $(".tab_block").slideUp(); 

     var content_show = $(this).attr("title"); 
     $("#"+content_show).slideDown(); 
    }); 

}); 

/// addon script: //// 
$(function(){ 

    $('#maptab').bind('click',function() { 
       var w = $('#map_view').width(); 
       var h = $('#map_view').height(); 
       $('#map').css({ width: w, height: h }); 
       google.maps.event.trigger(map, 'resize'); 

    }); 

});  

TABS代碼:

<ul class="tabs"> 
    <li><a href="#" title="content_4" class="tab" id="maptab">MAP</a></li> 
    <li><a href="#" title="content_5" class="tab ">tab 5</a></li> 
</ul> 

<div id="content_4" class="tab_block"> 

    MAP SCRIPTS GOES HERE... 

    <div id='map'></div> 


</div> 

回答

0

與初始化地圖時,它隱藏的是它依賴於性能/那是不會正常工作時,它的隱藏價值的問題。相反,在初始化頁面加載地圖(內$(function(){ .. });)的,你會想,當您單擊該選項卡上,顯示的內容來初始化地圖。

$("a.tab").click(function() { 
    $(".active").removeClass("active"); 
    $(this).addClass("active"); 
    $(".tab_block").slideUp(); 

    var content_show = $(this).attr("title"); 

    $("#"+content_show).slideDown(400, function(){ 
     // execute this code after tab content has been displayed 
     if ($(this).find('#map').children().length === 0) { 
      // find a #map element within the content area 
      // if the #map element has no children initialize the map 

      // code to initialize the map/map scripts here 
     } 
    }); 
}); 
+0

OK,可以請你寫我的代碼? (JS是不是我最好的一面...) – Roi

+0

希望有所幫助。 –