Google地图和jquery自定义标签触发器调整大小失败

时间:2013-12-02 06:02:11

标签: jquery

我试图在点击标签时触发调整大小的地图。我的地图在框的左上角看起来很小。

使用gmap.js加载地图

 $j(".tabbed-area a.tab").click(function (e) {  
    // switch all tabs off  
    $j(".tabbed-area .active").removeClass("active");  
    // switch this tab on  
    $(this).addClass("active");
    // save parent
    var thisEle = this;
     // Now figure out what the 'title' attribute value is and find the element with that id.  Then slide that down.  
     var content_show = $j(thisEle).attr("title");
    // slide all elements with the class 'content' up  
    var mapi;
    $j(".tabbed-area .tcontent[id!='"+content_show+"']").hide(0, function() {
        $j("#"+content_show).fadeIn(200, function(){
        if(mapi != undefined && mapi != null)
            google.maps.event.trigger(mapi, "resize");
    });

    });
    // prevent from scrolling up the page
    e.preventDefault();
}); 

它不起作用..

1 个答案:

答案 0 :(得分:0)

如果没有看到整个编码,就很难预测。但以下是我的猜测,

选项1

我怀疑此范围内的变量 mapi 未定义。因此,请尝试全局初始化mapi变量

选项2

最好使用像{/ 1>这样的delegate事件处理程序

$(document).on('click', '.tabbed-area a.tab', function() {
      //ToDos
});

与此question

密切相关