我安装了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>
只是一个疯狂的猜测,但从看[源](https://github.com/trigun117/gmaps4rails/blob/8b5dfa0a418be99318e1e10923fc75778011321a/app/views/users/index.html.erb#L1),也许你忘了设置API密钥?虽然它应该仍然显示控制台中的错误.... –