gpt4 book ai didi

ruby-on-rails - Google Maps for Rails - 标记中心始终最大缩放

转载 作者:行者123 更新时间:2023-12-04 07:29:25 26 4
gpt4 key购买 nike

我正在为 rails 使用谷歌地图,我已经正确设置了所有内容,但我似乎无法弄清楚如何设置默认缩放数字。我尝试在 gmaps4rails.base.js.coffee 中设置它:

@default_map_options = 
id: 'map'
draggable: true
detect_location: false # should the browser attempt to use geolocation detection features of HTML5?
center_on_user: false # centers map on the location detected through the browser
center_latitude: 0
center_longitude: 0
zoom: 7
maxZoom: null
minZoom: null
auto_adjust : true # adjust the map to the markers if set to true
auto_zoom: true # zoom given by auto-adjust
bounds: [] # adjust map to these limits. Should be [{"lat": , "lng": }]
raw: {} # raw json to pass additional options

但我认为这不能正常工作。有没有办法在创建 map 时添加缩放数字:

<%= gmaps(:markers => {:data => @json, 
:options => {:raw => '{ animation: google.maps.Animation }' } },
:map_options => { :raw => '{ disableDefaultUI: false,
scrollwheel: true }' }) %>

我所做的一切似乎都无济于事,它总是一直放大。谢谢!

最佳答案

这是我的解决方案,它有效(注意我使用 haml 。使用 <%= %> 代替 erb):

= gmaps("map_options" => { "detect_location" => true, "center_on_user" => true, "auto_zoom" => false, "zoom" => 16},"markers" => { "data" => @json })

关于ruby-on-rails - Google Maps for Rails - 标记中心始终最大缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7949412/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com