我像这样使用 gmaps4rails:
I'm using gmaps4rails like so:
<%= gmaps("map_options" => { "scrollwheel" => false, "zoom" => 17, "auto_zoom" => false },"markers" => { "data" => event.to_gmaps4rails }) %>这是生成:
<script type="text/javascript" charset="utf-8"> Gmaps.map = new Gmaps4RailsGoogle(); Gmaps.load_map = function() { Gmaps.map.map_options.scrollwheel = false; Gmaps.map.map_options.zoom = 17; Gmaps.map.map_options.auto_zoom = false; Gmaps.map.initialize(); Gmaps.map.markers = [{"lat":38.6419,"lng":-90.2646}]; Gmaps.map.create_markers(); Gmaps.map.adjustMapToBounds(); Gmaps.map.callback(); }; window.onload = function() { Gmaps.loadMaps(); }; </script>忽略 scrollwheel = false 选项,我做错了什么?
What am I doing wrong that is ignoring the scrollwheel = false option?
推荐答案从历史上看",我在地图选项中添加了一些来自提供商的功能.这是一个坏主意,因为我没有提取所有内容,而且我开始收到一些关于其余部分的拉取请求......
"Historically", I added in the map options some features from the providers. This was a bad idea since I didn't extract everything and I started to receive some pull requests for the rest of it...
代码太多,附加值很低.
Too much code for very low added value.
就您而言,scrollwheel 未包含在列表中 这里.所以最好的选择是使用 raw 键(也在上面的链接中描述).
In your case, scrollwheel isn't included in the list here. So the best options is to use the raw key (also described in the link above).
这将引导您到以下代码:
This would lead you to the following code:
<%= gmaps("map_options" => { :raw => "{scrollwheel: false}", "zoom" => 17, "auto_zoom" => false },"markers" => { "data" => event.to_gmaps4rails }) %>更多推荐
gmaps4rails 禁用滚轮
发布评论