How to reload Google Map in Bootstrap jQuery Tab

前端 未结 2 574
情书的邮戳
情书的邮戳 2020-12-07 05:09

I\'m using gmaps.js to load 2 maps in Bootstrap tabs. What happens, is the first map loads fine, but when the second tab (hidden) is clicked, the map doesn\'t load properly.

2条回答
  •  时光说笑
    2020-12-07 05:09

    trigger the resize-event of the window when a tab is shown(shown fires later than click, when the tab is already visible):

    $('.nav-tabs').on('shown.bs.tab', function () {
        google.maps.event.trigger(window, 'resize', {});
    });
    

    http://jsfiddle.net/BAm69/

提交回复
热议问题