gmaps4rails are not displaying map

219 views Asked by At

I have the gmaps4rails gem installed and I'm not sure what's going on here, but I can't even get the demo code to work. Nothing at all is being loaded.

I have a rails 5.0.1 ruby 2.3.3p222

I've followed the tutorial for the basic demo on the github page listed below: https://github.com/apneadiving/Google-Maps-for-Rails

There are no errors in the console when I run it. Below is the code. I have no idea why this isn't working, it's just the demo code and I didn't try to do anything tricky yet. Does anyone have any idea or has this happened to anyone?

I upload it on github: https://github.com/trigun117/gmaps4rails

application.js

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

show

<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>
1

There are 1 answers

0
The Whiz of Oz On BEST ANSWER

You need to get an API key from Google to use maps as of 2016. Go here to register your application and get a key.