In Google Maps getBoundingClientRect gives Unspecified Error in IE

蓝咒 提交于 2019-12-06 09:08:07

问题


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


回答1:


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: '' 
            }; 
        } 
    }; 
})();



回答2:


I fix the error by Despose GMap before postback:

unction fnGMap_initialize(strFrame) {
var divDealerMap = document.getElementById("divDealerMap");

var mapOptions = {
                zoom: 10,
                center: new google.maps.LatLng(50, 0), 
                mapTypeControl: true,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            }

        oGMap = new google.maps.Map(divDealerMap, mapOptions);
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(oGMap_Dispose);
}


function oGMap_Dispose() {
    var divDealerMap = document.getElementById("divDealerMap");   
    if (divDealerMap) divDealerMap.parentNode.removeChild(divDealerMap);
}



回答3:


Clearing the browser cache as mentioned here: https://support.google.com/maps/answer/21849?hl=en helped me to fix similar issues



来源:https://stackoverflow.com/questions/19275088/in-google-maps-getboundingclientrect-gives-unspecified-error-in-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!