Unspecified Error from Google Maps API on IE8

房东的猫 提交于 2019-12-11 04:47:29

问题


My page is returning SCRIPT16389: Unspecified error in IE8. I think I have found the reason for it but no solution.

The error is coming from Google Maps API, function mq(a,b). The problem is that IE8 does not appear to be able to handle getBoundingClientRect() on asynchronously loaded content, and I'm loading content using jQuery.load(). The error doesn't occur if I create a page with the same content loading with the page rather than asynchronously.

The error occurs on page load and then any time the window is resized, no matter whether a map is displayed or not.

I discovered that people were having the same problem with jQuery a few years ago: http://bugs.jquery.com/ticket/4996 Is there a workaround for IE 6/7 "Unspecified Error" bug when accessing offsetParent

Does anybody know of a fix or workaround? Or am I doing something wrong?

Thanks very much.


回答1:


I figured it out. I am posting my answer in case someone else has the same problem.

To reproduce the error, I had to first load a page with a Places Autocomplete input. Then, I would load other content, replacing the field. The error was happening when the window resize event could not find the dimensions of the nonexistent input.

I solved the problem by calling

google.maps.event.clearListeners(window, 'resize');

before loading the new content.

I hope this helps somebody.




回答2:


The other answers did not work for me. After a dozen of ideas, I ended up with the following working(!) solution:

Before loading the content, destroy the object that the map is attached to.

e.g. if your map is set using:

map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

use this code before doing the ajax request:

$('#map-canvas').remove();



来源:https://stackoverflow.com/questions/15842886/unspecified-error-from-google-maps-api-on-ie8

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