Google Maps API v3 in IE Not Displaying Map or Mar

2019-07-09 13:45发布

问题:

We recently upgraded from Google Maps v2 to v3 and now the Markers and Map will not display in any version of IE. It works in every other browser.

The console is showing Stack Overflow errors, and we think it has something to do with the markers and/or creation of markers. We disabled the fitbounds command, and the map displayed but with no markers in IE. However, the same map in Firefox and Chrome has markers which puzzled us.

I've been trying to figure out a solution to this issue for a few hours, debugging in IE and doing searches on Google, but have yet to find anything that resembles our issue.

I am new to the Google Map API, and just discovered stackoverflow, so I thought maybe somebody here could spot something I am missing?

Example map: http://tinyurl.com/bt7tvj3

回答1:

Install IE9, try it out in normal mode first.

If that works, try out compatibility mode.

The reason is: IE9 has far better JS support and a far better debugger than the previous versions.

Also, run your code through jshint.com or jslint.org - that always helps.

Usually IE has problems with missing semicolons and , in the end of arrays and objects, like

var arr = [1,2,3,];
var obj = {a:1, b:2,};

jslint and jshint will take care of additional commas for you. If your code passes jshint, and it still doesn't work in IE7+, come back, let's see what else can be missing.