简体   繁体   English

Google Maps不在Jquery标签中加载

[英]Google maps doesn't load in Jquery tabs

Its a very old question and I've tried all solutions available to go pass it without any success. 这是一个非常老的问题,我尝试了所有可用的解决方案,但都没有成功。 I tried all the accepted answers without any success which makes me believe that I must be doing something wrong. 我尝试了所有被接受的答案,但都没有成功,这使我相信我一定做错了什么。

Below are the details: 以下是详细信息:

Code looks something like this: 代码看起来像这样:

    // tab code example
        <li><a href="#tab1">Tab1</a></li>
        <li><a href="#tab2">Tab2</a></li>
        <li><a href="#tab3">Tab3</a></li>
        <li><a href="#tab4">Tab4</a></li>
        <li><a href="#tab5">Tab5</a></li>


        <div id="tab1" class="tab_content">
            <h2>Map1</h2>
        </div>
        <div id="tab2" class="tab_content">
            <h2>Map2</h2>
        </div>
        <div id="tab3" class="tab_content">
            <h2>Map3</h2>
        </div>
        <div id="tab4" class="tab_content">
            <h2>Map4</h2>
        </div>
         <div id="tab5" class="tab_content">
            <h2>Map5</h2>
        </div>
// tab example ends

I've already tried these answers: 我已经尝试过以下答案:

Loading Google Maps in jQuery tab 在jQuery标签中加载Google Maps
Google Maps Not Working in jQuery Tabs Google Maps在jQuery标签中不起作用
Google Map in Bootstrap Tab 引导标签中的Google Map
Google Maps and jQuery Tabs Google Maps和jQuery Tabs
Google Maps unable to fully load in jquery nav-tab Google Maps无法完全加载到jquery nav-tab中
Google Maps, Rails and Jquery Google Maps,Rails和Jquery
Google Maps and jQuery Tabs Google Maps和jQuery Tabs

[OP's solution converted to answer below] [OP的解决方案转换为下面的答案]

Finally what worked for me was including this in view specific js, so in my view.js i have :- 最后,对我有用的是在特定于视图的js中包括它,所以在我的view.js中,我有:-

 $( "#tabs" ).bind( "click", function() {
        Gmaps.loadMaps();
    });

In view.html.erb :- 在view.html.erb中:-

<%= gmaps(..)%> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM