gmaps4rails disable scroll wheel

2019-06-10 19:29发布

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条回答
虎瘦雄心在
2楼-- · 2019-06-10 20:30

"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 }) %>
查看更多
登录 后发表回答