user929062
user929062

Reputation: 817

"Gmaps is not defined" using Google Maps for Rails (gmaps4rails) with Rails 3.1

I have a show page that should show a business and a google map of the business. I use google maps API v3. I have required //= require gmaps4rails/googlemaps.js in application31.js and added the following line into the model (business.rb):

  acts_as_gmappable

  def gmaps4rails_address
    "#{self.address}, #{self.city.name}, #{self.state.name}" 
  end

Stylesheets are also required (included). I also included gem 'gmaps4rails' into Gemfile and bundled. My model has latitude and longitude with correct values in the database.

In my business_controller.rb I have added

def show
  ...
  @json = Business.find(params[:id]).to_gmaps4rails
  ...
end

And on business show page I have added

%div
  = gmaps4rails(@json)

Footer contains

%footer
  = yield :scripts

Now the frame of google maps appears but it's empty. Here are the relevant lines concerning the error:

<footer>
225 <script type="text/javascript" src="//maps.google.com/maps/api/js?v=3.5&sensor=false&amp;libraries=geometry"></script>
226 <script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.9/src/infobox_packed.js"></script>
227 <script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.5/src/markerclusterer_packed.js"></script>
228 <script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/trunk/richmarker/src/richmarker-compiled.js"></script>
229
230 <script type="text/javascript" charset="utf-8">
231
232 Gmaps.map = new Gmaps4RailsGoogle();
233 Gmaps.load_map = function() {
234 Gmaps.map.map_options.auto_adjust = true;
235 Gmaps.map.initialize();
236 Gmaps.map.markers = [{"lng": "77.225", "lat": "28.6353"}];
237 Gmaps.map.markers_conf.do_clustering = true;
238 Gmaps.map.create_markers();
239 Gmaps.map.adjustMapToBounds();
240 Gmaps.map.callback();
241 };
242 window.onload = function() { Gmaps.loadMaps(); };

The errors now is:

 Gmaps is not defined" for line 232

Does anyone know what it can be? I also have installed geocoder, but I hope this can not create any issue.

Thanks!

Upvotes: 2

Views: 2893

Answers (1)

apneadiving
apneadiving

Reputation: 115511

As per my comment, rename application31.js to application.js

Upvotes: 2

Related Questions