2016-12-23 104 views
1

我安裝了gmaps4rails gem,我不確定這裏發生了什麼,但我甚至無法獲得演示代碼的工作。什麼都沒有被加載。gmaps4rails不顯示地圖

我有一個Rails 5.0.1紅寶石2.3.3p222

我已經按照下面列出的GitHub的頁面上的基本演示教程:https://github.com/apneadiving/Google-Maps-for-Rails

有在控制檯中沒有錯誤,當我運行。以下是代碼。我不知道爲什麼這不起作用,它只是演示代碼,我沒有試圖做任何棘手的事情。有沒有人有任何想法或有這發生在任何人?

我把它上傳在GitHub上:https://github.com/trigun117/gmaps4rails

的application.js

//= require jquery 
//= require jquery_ujs 
//= require turbolinks 
//= require underscore 
//= require gmaps/google 
//= require_tree . 

顯示

<div style='width: 800px;'> 
<div id="map" style='width: 800px; height: 400px;'></div> 
</div> 

<script type="text/javascript"> 
    handler = Gmaps.build('Google'); 
    handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){ 
    markers = handler.addMarkers(<%=raw @hash.to_json %>); 
    handler.bounds.extendWith(markers); 
    handler.fitMapToBounds(); 
}); 
</script> 
+0

只是一個瘋狂的猜測,但從看[源](https://github.com/trigun117/gmaps4rails/blob/8b5dfa0a418be99318e1e10923fc75778011321a/app/views/users/index.html.erb#L1),也許你忘了設置API密鑰?雖然它應該仍然顯示控制檯中的錯誤.... –

回答

0

你需要從谷歌API密鑰使用地圖爲2016年圍棋here來註冊您的應用程序並獲得一個密鑰。

+1

dam txn你解決我的問題 – trigun117