[英]gmaps4rails: Uncaught ReferenceError: Gmaps is not defined
[英]Uncaught ReferenceError: Gmaps is not defined
我正在使用Gmaps4rails和Foundation 5.我關注了Gmaps4rails視頻教程並且地圖沒有顯示出來。 我收到了Uncaught ReferenceError: Gmaps is not defined
,違規行是自定義腳本的第一行:
handler = Gmaps.build('Google');
我認為與基金會存在某種沖突,因為我嘗試創建一個只有Gmaps4rails並且沒有基礎的Rails應用程序,一切正常。
根據示例應用程序,問題如下:在加載包含其定義的腳本之前調用Gmaps
...它無法工作。
解釋是你在html底部放置= javascript_include_tag "application"
,以滿足Foundation的期望。 因此,之前的每個javascript都會失敗:您必須在定義它們的文件之后放置腳本。
所以AFTER = javascript_include_tag "application"
,添加:
= yield :scripts
然后在視圖中需要時:
- content_for :scripts do
:javascript
// Gmaps can be called safely here...
謝謝本傑明!
我收錄了你的建議,現在顯示了地圖。 瞧!
結帳https://github.com/JonKernPA/gmaps_zurb查看完整的示例應用程序:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.