簡體   English   中英

gmaps4rails沒有顯示地圖

[英]gmaps4rails are not displaying map

我已經安裝了gmaps4rails gem,但是我不確定這里發生了什么,但是我什至無法使演示代碼正常工作。 什么也沒有加載。

我有一個滑軌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>

您需要從Google獲得API密鑰才能使用截至2016年的地圖。請轉到此處注冊您的應用並獲取密鑰。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM