apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

Cannot set Zoom with single marker present #18

Closed joeytheman closed 13 years ago

joeytheman commented 13 years ago

If a single element is present in @json,the map shows fully-zoomed in, ignoring the zoom option. Works fine with 2 or more elements.

<%= gmaps({
"map_options" => { "type" => "SATELLITE", "center_longitude" => 180, "zoom" => 3, "auto_adjust" => true},
"markers"     => { "data" => @json } } )
%>
joeytheman commented 13 years ago

Passing auto_zoom => false fixes the issue.

apneadiving commented 13 years ago

:)

enricribas commented 13 years ago

Not sure if that really works. Yes it will override the condition for a single marker, but when there are multiple markers again, you really want the autozoom => true, no? Setting maxZoom and minZoom helps but it limits how far users can zoom. Neither is a perfect solution.

apneadiving commented 13 years ago

For archives, nice solution presented here:

http://stackoverflow.com/questions/5821997/google-maps-ruby-on-rails-zoom-level-with-one-marker