gmaps4rails 禁用滚轮

编程入门 行业动态 更新时间:2024-10-28 06:23:54
本文介绍了gmaps4rails 禁用滚轮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我像这样使用 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 禁用滚轮

本文发布于:2023-08-02 00:09:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1272932.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:滚轮   gmaps4rails

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!