Google Map API V3 Zoom 仅适用于长时间聚焦
我在我的网站中使用谷歌地图 api3,此时,如果您向下滚动页面,并且碰巧滚动谷歌地图(虽然不是故意的),则地图会获得焦点并开始放大。据我所知,这是标准行为,而不是错误或任何东西。我只是想以某种方式改变它......
我希望有一种方法可以修改谷歌地图识别鼠标悬停所需的时间,并在较长一段时间后赋予它焦点/缩放功能?或者一些其他选项让它获得焦点,即 setTimeout(focus, 300);
或其他东西。
I'm using a google map api3 in my website and at the moment if you're scrolling down the page, and happen to scroll over the google map (while not intending to), the map gets focus and starts to zoom in. As far as I'm aware, this is standard behaviour and not a bug or anything. I just would like to change it somehow...
I'm hoping there's a way to modify how long it takes the google map to recognise the mouseover and give it focus/zooming-capability after a longer period of time? Or some other option to make it gain focus i.e. setTimeout(focus, 300);
or something.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过在设置地图选项时设置scrollwheel:false来禁用滚轮缩放,例如,
这将完全禁用地图的滚轮缩放并纠正加载页面时遇到的问题
You can disable the scroll wheel zoom by setting scrollwheel:false when setting the map options for example
this will completely disable the scroll wheel zoom for the map and correct the problem you are having when you load the page
恐怕 Google Maps API 不提供任何方法来禁用默认滚动行为。虽然您可以取消地图缩放,但滚动事件不会到达页面。好吧,我错过了
scrollwheel
地图选项,它正是您所需要的。要实现您想要的行为:map.setOptions(options)
并将滚轮选项设置为 true。实现所需行为的另一种方法是使用一个小技巧:
I'm afraid Google Maps API doesn't offer any way to disable the default scroll behaviour. Although you can cancel zooming in the map, the scroll event doesn't reach the page.Ok, I missed the
scrollwheel
map option, it does exactly what you need. To achieve your desired behaviour:map.setOptions(options)
with scrollwheel option set to true.Another way to achieve the desired behaviour is to use a small trick: