Gmaps is not defined
I´m developing an website in ROR
I am using gem 'gmaps4rails'.
In localhost the map is showed, but when i put on a production server (DigitalOcean) gives me this error: Uncaught ReferenceError: Gmaps is not defined
i have this script in my index.html.erb:
<div id="map_show" ></div>
</div>
<script type="text/javascript">
handler = Gmaps.build('Google');
handler.buildMap({ provider: {}, internal: {id: 'map_show'}}, function(){
markers = handler.addMarkers(<%=raw @hash.to_json %>);
handler.bounds.extendWith(markers);
handler.fitMapToBounds();
});
</script>
My application.js is this:
//= require jquery
//= require bootstrap-sprockets
//= require jquery_ujs
//= require turbolinks
//= require underscore
//= require gmaps/google
//= require highcharts
//= require chartkick
//= require_tree .
Anyone know how can i resolve my problem?
this is turbolinks related, try to disable turbolinks and you'll be fine, or load the gmaps in head/allpages.
Did you ever fix this problem, I'm facing this problem and I cannot find my way out.
Yep. I need to use the CDN:
<script src='//cdn.jsdelivr.net/gmaps4rails/2.1.2/gmaps4rails.js'> </script>
<script src='//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore.js'> </script>
I ask the same question in StackOverflow:
https://stackoverflow.com/questions/44704324/gmaps-is-not-defined