gmaps4rails 禁用滚轮 [英] gmaps4rails disable scroll wheel

查看:42
本文介绍了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 禁用滚轮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆