Search code examples
javascriptrubyruby-on-rails-3google-maps-api-3gmaps4rails

Gmaps4rails too close zoom when showing single marker


Possible Duplicate:
gmaps4rails single marker auto zoom

I am using gmaps4rails with Google Maps API v3 and often display a single marker. gmaps4rails then zooms in, in order that all markers – here 1 – are visible on the map. However, it takes the closest zoom level available in Google Maps and I haven't found a way to change the zoom level for this single marker only.

I am displaying my maps like this:

gmaps(markers: {data: @events, options: {raw: '{animation: 
google.maps.Animation.DROP}'}}, map_options: {auto_adjust: 
true, center_on_user: true, auto_zoom: true, zoom: 14})

The marker is replaced with Gmaps.map.replaceMarkers(...);


Solution

  • The problem it that for setting an custom zoom yor auto_zoom should be false.

    I use this setting to get my custom zoom:

    gmaps(:map_options => {"auto_zoom" => false, "zoom" => 17}, :markers => { "data" => @json })

    Hope this helps.