Google地图无法在jQuery easytabs中使用

时间:2014-05-06 22:12:28

标签: jquery html css google-maps

当你点击联系人标签时,它会加载gmaps但不正确。(只有地图的左角)非常有趣......有什么想法吗?

here is the jsfiddle

我的HTML代码的结构:

        <div id="menu-container" class="section group">
        <div id="menuu" class="col span_8_of_12">
            <!-- Navigation Bar -->
            <div class="menu">
                <ul class='tabs'>
                    <li class='tab-biography'><a href="#aboutme">About Me</a></li>
                    <li class='tab-portfolio'><a href="#portfolio">Portfolio</a></li>
                    <li class='tab-photos'><a href="#photos">Photos</a></li>
                    <li class='tab-contact'><a href="#contact">Contact</a></li>
                </ul>
            </div>
        </div>
        <div id="social-icons" class="col span_4_of_12">
            <!-- Social Icons -->
            <ul class="social-icons">
                <li><a href="#"><img src "img/icons/rss.png" g" alt=""/></a></li>
                <li><a href="#"><img src "img/icons/twitter.png" g" alt=""/></a></li>
                <li><a href="#"><img src "img/icons/facebook.png" g" alt=""/></a></li>
            </ul>
            <!-- /Social Icons -->
        </div>
        <!-- /Navigation Bar -->
    </div>

gmaps:

function initialize() {
    var myLatlng = new google.maps.LatLng(41.00527, 28.97696);
    var mapOptions = {
        zoom: 16,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

    var marker = new google.maps.Marker({
        position: myLatlng,
        map: map,
    });
}

  google.maps.event.addDomListener(window, 'load', initialize);

1 个答案:

答案 0 :(得分:1)

在包含地图的标签可见后,您需要触发地图resize事件。查看the documentation,为此目的有一个事件钩子:

easytabs:after | Fires after a tab has been selected (and after the panel is completely finished transitioning in). | [event, $clicked, $targetPanel, settings]

$('#content').bind('easytabs:after', function() {
   google.maps.event.trigger(map, 'resize');     
});

working fiddle