Google Maps Not Working in jQuery Tabs

前端 未结 13 1839
滥情空心
滥情空心 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:24

    Give this a try:

    Change

  • Map Tab
  • to

  • Map Tab
  • Then add this javascript

    $(document).ready(function(){
      $('#maptab').bind('onClick', function() {
        google.maps.event.trigger(map, 'resize');
      });
    });
    

    In a script tag at the top of the page. What this should do for you:

    By adding the id attribute to the tab link, you're explicitly specifying there's a map in there. You're then listening for the onClick event provided by the jQuery tabs library that fires when a tab is selected, which triggers re-sizing the map.

提交回复
热议问题