Prevent Google maps JS executing multiple times caused by Rails Turbolinks

前端 未结 5 1295
盖世英雄少女心
盖世英雄少女心 2021-02-19 07:30

I\'m currently working on Rails app that is getting the following error:

You have included the Google Maps API multiple times on this page. This may ca

5条回答
  •  执笔经年
    2021-02-19 08:08

    I had faced the same problem, unfortunately this might be of no help to you after so many months.

    I moved:

    
    

    in head tag after <%= csrf_meta_tags %>, and moved the:

    <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
    

    after /body tag.

    By doing so I resolved this issue:

    You have included the Google Maps API multiple times on this page. This may cause unexpected errors.

    Added data-no-turbolink to the link in navigation bar, the page where I have map. This helped me keep using turbolinks in all pages without that error and as well as let me generate the map when that page was accessed.

提交回复
热议问题