In Google Maps getBoundingClientRect gives Unspecified Error in IE

妖精的绣舞 提交于 2019-12-04 16:05:15
phenomnomnominal

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

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);
}

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

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