在Google Maps中,getBoundingClientRect在IE中给出未指定的错误 [英] In Google Maps getBoundingClientRect gives Unspecified Error in IE

查看:184
本文介绍了在Google Maps中,getBoundingClientRect在IE中给出未指定的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与问题相关:
来自Google的未指定错误在IE8上的Maps API



函数
函数Mp(a,b){..}
下面这行代码触发器错误
var e = a.getBoundingClientRect();


  1. 复制这个错误


    1. 制作Google地图页面(确保页面高度足以让您腾出空间滚动页面,不要将地图全屏显示)。

    2. 放置标记

    3. 以调试模式在IE中打开应用程序(我在10中测试过)

    4. 当页面加载时,点击标记这样它就会显示信息窗口,即弹出窗口尝试滚动页面


      你会得到



getBoundingClientRect(),它是一个返回容器位置的IE特性。这些问题可能与工具提示有关,例如信息窗口。

更多内容: http://ejohn.org/blog/getboundingclientrect-is-awesome/



尝试了解决方案:google.maps.event.clearListeners(window,'resize');
它不起作用。


示例应用程序: https://googledrive.com/host/0B-Y3wXhWdoQebnBUV2RNRWhJZE0/test-shell.html
礼貌:@ user2250544



解决方案

如果您遇到这种情况,这似乎是一种肮脏的黑客行为:

  HTMLElement.prototype.getBoundingClientRect =(function(){
var oldGetBoundingClientRect = HTMLElement。 prototype.getBoundingClientRect;
return function(){
try {
return oldGetBoundingClientRect.apply(this,arguments);
} catch(e){
return {
left:'',
right:'',
top:'',
bottom:''
};
}
};
})();


Relating to question in: Unspecified Error from Google Maps API on IE8

In function function Mp(a,b){ .. } the following line of code triggers an error var e=a.getBoundingClientRect();

  1. To replicate this error

    1. Make a Google Map page (make sure it is tall enough that you've spare space to scroll the page, don't make the map full-screen)
    2. Place a Marker
    3. Open the app in IE ( I tested in 10) in debug mode
    4. When page loads, click on a marker such that it shows the info-window i.e. the pop-over
    5. Try scrolling the page

      You'll get the error.

getBoundingClientRect(), an IE feature which returns positions of containers. The issues may be related to tool-tips i.e. info-windows.

Look more at : http://ejohn.org/blog/getboundingclientrect-is-awesome/

Tried the solution: google.maps.event.clearListeners(window, 'resize'); It din't work.

Sample App: https://googledrive.com/host/0B-Y3wXhWdoQebnBUV2RNRWhJZE0/test-shell.html Courtesy: @user2250544

解决方案

Here's a filthy hack that seems to work, if you're into that kinda thing:

HTMLElement.prototype.getBoundingClientRect = (function () { 
    var oldGetBoundingClientRect = HTMLElement.prototype.getBoundingClientRect; 
    return function() { 
        try { 
            return oldGetBoundingClientRect.apply(this, arguments); 
        } catch (e) { 
            return { 
                left: '', 
                right: '', 
                top: '', 
                bottom: '' 
            }; 
        } 
    }; 
})();

这篇关于在Google Maps中,getBoundingClientRect在IE中给出未指定的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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