Search code examples
ruby-on-railsgmaps4rails

How to center map in gmaps4rails?


i want to display a map centered to a specific location. In my controller, I use

@gmapsoptions = {
     "map_options" => {"center_latitude" => 40, 
                       "center_longitude" => 73,
                       "detect_location" => false,
                       "center_on_user" => false,
                       "auto_adjust" => false,
                       "auto_zoom" => false,
                       "zoom" => 8 }
                 }

and in my view i use

<%= gmaps(@gmapsoptions) %>

It renders the map just fine, but it is not centered on the location specified above but on "0/0" aka the dateline. How can I fix this?


Solution

  • Just checked your repo, you should simply have auto_zoom set to true (or remove it since it's the default value).