Adjust Zoom Gmaps4Rails

邮差的信 提交于 2019-12-03 16:21:14

You're simply missing that seeing the whole map means providing a very small number, not a big one!

<%= gmaps({
  "map_options" => {"auto_adjust" => false, "zoom" => 0 },
  "markers"     => {"data" => @json }
 })
%>

I'm on gmaps4rails 1.3.2 and these are the best settings I could find:

<%= gmaps({
  "map_options" => {"auto_zoom" => false, "zoom" => 10 },
  "markers" => {"data" => @json }
})
%>
  • I did not set auto_adjust to false, because the map would not be centered on the marker anymore.

  • The 10 value for the zoom is nice to display approximatively a 50km-wide map.

what helped me in this case was this:

Gmaps4Rails.callback = function() {
    setTimeout("Gmaps4Rails.map.setZoom(13);", 100);
};
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!