gmaps4rails disable scroll wheel

懵懂的女人 提交于 2019-12-10 12:09:13

问题


I'm using gmaps4rails like so:

  <%= gmaps("map_options" => { "scrollwheel" => false, "zoom" => 17, "auto_zoom" => false },"markers" => { "data" => event.to_gmaps4rails }) %>

This is generating:

<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>

What am I doing wrong that is ignoring the scrollwheel = false option?


回答1:


"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.

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 }) %>


来源:https://stackoverflow.com/questions/10567014/gmaps4rails-disable-scroll-wheel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!