滚动导致页面滚动和IE9中的地图缩放(Google Maps v2) [英] Scrolling causes page scroll AND map zoom in IE9 (Google maps v2)

查看:251
本文介绍了滚动导致页面滚动和IE9中的地图缩放(Google Maps v2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Internet Explorer 9中,使用Google Maps API v2(已弃用),使用滚轮进行缩放也会导致页面滚动.有人知道此问题的解决方法吗? (不幸的是,尚不可能将我们的代码库升级到v3.)在Internet Explorer的早期版本中不会发生此行为.

In Internet Explorer 9, using the Google Maps API v2 (which is deprecated), zooming with the scroll wheel also causes the page to scroll. Does anyone know of a workaround for this issue? (Upgrading our codebase to v3 is not yet possible, unfortunately.) This behavior does not occur in earlier versions of Internet Explorer.

这是一个测试页.

推荐答案

许多人似乎都在网络上遇到相同的问题,但是我发现没有解决方案.所以这是我的:

Many people seem to have the same problem around the net but I found no solutions posted. So here is mine:

由于不可滚动组件不会引发滚动事件,并且该事件在文档对象上不可取消,因此无法使用标准DOM.幸运的是,有一个名为"mousewheel"的jQuery小插件,它向jQuery添加了"mousewheel"和"unmousewheel"事件绑定函数. "mousewheel"事件调用的函数可以返回false来取消它,然后文档将不接收它.因此,我测试了IE9或更高版本,并在必要时下载了此小插件,并将其应用于保存地图的div.

Since non-scrollable components do not raise the scroll event and that event is non-cancelable on the document object, the standard DOM could not be used. Fortunately, there is a little jQuery plugin called "mousewheel", which adds "mousewheel" and "unmousewheel" event binding functions to jQuery. The function called by "mousewheel" event can return false to cancel it and the document then does not receive it. So I test for IE9 or bigger and download this little plugin if necessary, applying it to the div holding the map.

这篇关于滚动导致页面滚动和IE9中的地图缩放(Google Maps v2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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