Google Maps Not Working in jQuery Tabs

前端 未结 13 1873
滥情空心
滥情空心 2020-12-09 22:56

Google maps not working when placed inside jQuery tabs is a question that\'s all over the web. In my research so far none of the solutions seem to work. Hopefully someone he

13条回答
  •  半阙折子戏
    2020-12-09 23:02

    I solved this for the bootstrap Tab. It is just the matter of calling resize map function right after the map container is displayed.

    I have added the following out side the initialize() function:

    jQuery('.nav-tabs a[href="#my-map"]').on('shown.bs.tab', function(){
             google.maps.event.trigger(map, 'resize');
             map.setZoom(15); //You need to reset zoom
             map.setCenter(myLatlng); //You need to reset the center
        });
    

提交回复
热议问题