0
我有一個html和js文件(maps_scripts.js),我已經定義了所有與提到的html頁面相關的谷歌地圖功能。 這兩個工作真的很好。谷歌沒有定義在軌道上的紅寶石錯誤
我已經被分配到包含這些文件jruby在其他人開發的rails項目。
到目前爲止,這些是我採取的步驟。
- 複製maps_scripts.js文件\ APP \資產\ JavaScript的
- 複製相關的標誌圖像\ APP \資產\圖像
添加
<%= javascript_include_tag 'https://maps.googleapis.com/maps/api/js?key=my_key&libraries=places' %> "
我html.erb頁
包括
<%= javascript_include_tag 'map_scripts.js', 'data-turbolinks-track' => true %>
我html.erb頁
問題
我越來越
Uncaught ReferenceError: google is not defined at map_scripts.self-09044ded37604e5a1f367207911e2c79370a307b67a4be3178923d19f555011c.js:4
注:我有幾個
google.maps.*
調用maps_scripts.js文件。對於一個實例
- google.maps.MarkerImage
- 爲google.maps.Size
- google.maps.Map 等
只要嘗試重新排序代碼,在使用前定義谷歌。 在此寫所有代碼以獲取更多幫助。 – easa
我通過改變我的步驟3來解決這個問題。不是把它放在html.erb中,而是將它放在application.html.erb中,它現在工作正常 –