gmaps4rails禁用缩放

时间:2014-03-31 17:06:26

标签: javascript ruby-on-rails gmaps4rails

我在制作地图时尝试禁用滚动,但它似乎无法正常工作。

:javascript
var handler = Gmaps.build('Google', { map_options: { scrollwheel: false, zoomControl:   false }, markers: { maxRandomDistance: null }, builders: { Marker: InfoBoxBuilder} });
  handler.buildMap({ internal: {id: 'geolocation'} }, function(){
...
});

2 个答案:

答案 0 :(得分:5)

根据to the doc,您可以在创建处理程序时更改全局设置。

您可以在构建函数中更改对象选项。

所以:

var handler = Gmaps.build('Google', { markers: { maxRandomDistance: null }, builders: { Marker: InfoBoxBuilder} });

handler.buildMap({ provider: { scrollwheel: false, zoomControl: false }, internal: {id: 'geolocation'} }, function(){
...
});

答案 1 :(得分:0)

this

可能重复
  <%= gmaps("map_options" => { :raw => "{scrollwheel: false}", "zoom" => 17, "auto_zoom" => false },"markers" => { "data" => event.to_gmaps4rails }) %>

This might help too..