google-maps - 在 Google map 中 getBoundingClientRect 在 IE 中给出未指定的错误

标签 google-maps google-maps-api-3 internet-explorer-8 google-maps-markers

与以下问题相关: Unspecified Error from Google Maps API on IE8

在函数中 函数 Mp(a,b){ .. } 以下代码行会触发错误 var e=a.getBoundingClientRect();

  1. 要复制此错误
    1. 制作一个 Google map 页面(确保页面足够高,以便有足够的空间滚动页面,不要使 map 全屏显示)
    2. 放置标记
    3. 在 IE 中以 Debug模式打开应用(我在 10 中进行了测试)
    4. 页面加载时,单击标记以显示信息窗口,即弹出窗口
    5. 尝试滚动页面

      You'll get the error.

getBoundingClientRect(),一种返回容器位置的 IE 功能。这些问题可能与工具提示(即信息窗口)有关。

查看更多:http://ejohn.org/blog/getboundingclientrect-is-awesome/

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

Sample App: https://googledrive.com/host/0B-Y3wXhWdoQebnBUV2RNRWhJZE0/test-shell.html Courtesy: @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: '' 
            }; 
        } 
    }; 
})();

关于google-maps - 在 Google map 中 getBoundingClientRect 在 IE 中给出未指定的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19275088/

相关文章:

javascript - 谷歌地图自定义图层与可点击标记

javascript - 如何使用下拉菜单中的地点库在 Google map 上显示标记?

php - 脚本 php artisan 优化处理返回错误代码 1 的 post-update-cmd 事件

jquery - 谷歌地图消失

javascript - 如何将谷歌地图定位到特定位置?

google-maps-api-3 - Google map 多边形调整事件

ios - 用于 MKMapKit 的谷歌自动完成 API

css - 显示 : Table-cell not setting height constantly xbrowser (ie8 table bug)

css - html5shiv 不能在 IE8 中工作?

javascript - IE8 正在使用 jQuery 抛出错误