Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gmaps is not defined #549

Open
MiguelFCoelho opened this issue Jun 23, 2017 · 3 comments
Open

Gmaps is not defined #549

MiguelFCoelho opened this issue Jun 23, 2017 · 3 comments

Comments

@MiguelFCoelho
Copy link

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?

@buncis
Copy link

buncis commented Aug 29, 2017

this is turbolinks related, try to disable turbolinks and you'll be fine, or load the gmaps in head/allpages.

@LindaKadz
Copy link

Did you ever fix this problem, I'm facing this problem and I cannot find my way out.

@MiguelFCoelho
Copy link
Author

MiguelFCoelho commented Nov 27, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants