Search code examples
ruby-on-railsrubyruby-on-rails-3google-mapsgmaps4rails

Gmaps4rails : zoom not working?


I have the following view in my Rails code :

<%= gmaps4rails(@map, { "processing" => 'json', 'auto_adjust' => false, 'auto_zoom' => false, 'zoom' => 10 }) %>

I have only one marker on my map. When I display the map, the zoom is always set to the maximum, despite the options I set above. Did I forget an option ?


Solution

  • Try this instead (the gmaps method lets you pass in options, whereas the gmaps4rails method does not):

    <%= gmaps("markers" => {"data" => @map}, "map_options" => {"processing" => "json", "auto_adjust" => false, "auto_zoom" => false, "zoom" => 10}) %>
    

    See http://rubydoc.info/gems/gmaps4rails/0.8.1/ApplicationHelper for documentation on these two methods (gmaps vs gmaps4rails)