Search code examples
javascriptruby-on-railsherokugmaps4rails

Heroku production : Gmaps is not defined - works in local


On a simple page, I show a google map with one marker.

In local, everythings works perfectly but, on Heroku I got an error in console :

 Uncaught ReferenceError: Gmaps is not defined

this is related to

handler = Gmaps.build('Google'); //and some other stuff

Localy, this is working. But when I deployed this on heroku, it's like it can't load the JS.

this is on the top of my file

<script src="//maps.google.com/maps/api/js?v=3.13&amp;sensor=false&amp;libraries=geometry"type="text/javascript"></script>
<script src='//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js'type='text/javascript'></script>
<script src='//google-maps-utility-library-v3.googlecode.com/svn/trunk/richmarker/src/richmarker-compiled.js' type='text/javascript'></script>

and the application.js

//= require underscore
//= require gmaps/google

I'ts probably a simple error, maybe related to assets precompiled, but I'm not really an expert in this area


Solution

  • Actually, I solved my problem :

    My console showed me that JQuery was not defined. I didn't really pay much attention to it. But this was the problem. So I change the order of the requires in my application.js and i put gmaps in the top

    //= require gmaps/google
    //= require jQuery.headroom.min.js
    //= require headroom.min.js    
    //= require underscore
    //= require template.js
    

    so gmaps in the top of the file, When JQuery is declared undefined It didn't block gmaps to load. So now I have to fix the jquery problem, but this gmaps problem is solved