Google 地图 API v3.19 在 Internet Explorer Quirks 模式下损坏

Google Maps API v3.19 Broken in Internet Explorer Quirks Mode

Google 地图 API 的 3.19 版在 2015 年 2 月 17 日成为默认地图 'release'(参见 https://code.google.com/p/gmaps-api-issues/wiki/JavascriptMapsAPIv3Changelog). The release appears to be causing issues in Internet Explorer when using quirks mode,如下面的测试页面所示我从受此问题影响的应用程序生成的(因此这可能包含比此处所需的代码更多的代码):

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Google Maps Test Page</title>
</head>
<body style="margin:0; padding:0">
    <!-- Adding ?v=3.18 onto the end of this URL will 'fix' the problem -->
    <script src='http://maps.googleapis.com/maps/api/js' type='text/javascript'></script>
    <script type='text/javascript'>
    function initialize() {
        top.google.maps.visualRefresh=true;
        var mapOptions = {
            zoom: 13,
            center: new google.maps.LatLng(51.5072, 0.1275),
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            scaleControl: true,
            overviewMapControl: true
        };
        this._map = new google.maps.Map(document.getElementById('myMap'), mapOptions);  
    }

    google.maps.event.addDomListener(window, 'load', initialize);
    </script>

    <div id="myMap" style="width:500px;height:500px;position:relative;"></div>
 </body>
 </html>

Firefox 和 Chrome 都会正确显示可用的地图,而 IE 会在 Google 地图代码深处引发错误,该代码显示为 'Could not get the display property. Invalid argument.' 我已经尝试调试代码但是它被混淆了,使它成为一个痛苦的挑战。

强制将版本恢复到最后一个 'frozen' 版本 (3.18) 暂时解决了这个问题,但这只是一个临时解决方案。

除了向 Google 报告此问题并希望他们修复它之外,任何人都可以提出解决方案吗?


补充说明:

在我写的时候,我注意到这里的信息 https://code.google.com/p/gmaps-api-issues/wiki/JavascriptMapsAPIv3Changelog 说版本是:

Experimental: 3.20
Release: 3.19
Frozen: 3.18 

版本 3.17 将被删除。对 3.17 或任何先前版本的请求现在将提供 3.18 版'

虽然此页面 https://developers.google.com/maps/documentation/javascript/basics#Versioning 说(在页面底部):

Version 3.18 Reference (Release)
Version 3.19 Reference (Experimental)
Version 3.17 Reference (Frozen)
Versions 3.0 - 3.16 have been retired.

这相当令人困惑,但我认为更新日志 link 是最新的信息来源。这种差异让我感到困惑,所以我认为值得分享观察结果。


2015 年 2 月 20 日更新:

昨天 Google 确认这是一个错误 - 请参阅 https://code.google.com/p/gmaps-api-issues/issues/detail?id=7675 - 并建议“我们正在研究修复”。

感谢您的意见和建议,但到目前为止,我还没有找到一个解决方法来让我的应用程序完全工作,因为其他页面组件依赖于 quirks 模式,因此需要做大量工作才能获得整个事情又开始了。我希望 Google 的关注能为我解决这个问题。


2015 年 2 月 21 日更新:

https://code.google.com/p/gmaps-api-issues/issues/detail?id=7675 现在表示 'A fix will be deployed in the coming week.'

今天在我刚刚继承的网络应用程序中发现了同样的问题。出于某种原因,以前的开发人员迫使 IE 进入怪癖 (ie7) 模式,google api 问题从今天开始。我更新了主 html 页面,通过将 html 头部部分从

更改为使用 IE 边缘模式
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
 <head>
    <meta http-equiv="X-UA-Compatible" content="IE=7" /> 
 .....

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
 <head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 
.....

(如果您遗漏了它,请添加 ie-edge meta... 行)

目前已修复。

现在找出为什么以前的开发者强制使用 IE7 模式....

我们正在使用 GMLib Google 地图 delphi 组件,我们遇到了同样的问题。 GMLib组件使用了里面的TWebBrowser组件。

在 GMLib 组件的资源文件中,我们发现了一个 map.html 文件。 我们将以下行添加到 html 文件的部分。

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

然后我们将资源文件重新编译到组件中,重新编译 delphi 项目并成功。

我想这是使用相对不受支持的免费组件的缺点之一。

我们现在正在考虑转向为 google 地图组件付费的商业广告,以降低再次发生这种情况的风险。

在我的例子中(.net 4 visual c# 与 webbrowser 集成)解决这个问题我只是添加 &v=3 好像不指定版本就用实验版的。。。奇怪。

这很好

< script src="https://maps.googleapis.com/maps/api/js&v=3.18" type="text/javascript"></script>

这不

< script type="text/javascript" src="https://maps.googleapis.com/maps/api/js&v=3.18"</script>

我在 Delphi 中有一个使用 TWebBroser 的应用程序,这是我找到的临时解决方案,但不是 100% 因为要解决这个问题,我必须使用注册表编辑器在 Windows 上添加一个密钥。强制IE在版本中模拟 了解我创建的密钥,为了更好地理解查看此项目中的浏览器仿真 link https://msdn.microsoft.com/en-us/library/ee330730(v=vs.85).aspx 。 此解决方案仅在安装密钥中指定的 IE 版本时有效。

我们在使用标准 .net WebBrowser 控件的 C# 程序中也遇到了同样的问题。

我们也通过添加行

解决了这个问题
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

请注意,它在 Internet Explorer 7 的 Vista 配置上不起作用,但在安装 IE 9 后就可以了(安装 Service pack1、service pack 2、2 超过 3 小时微软修正补丁,最后是 IE9 本身).

已解决: IE8 (XP)、IE9 (Win7) 和 Win 7 和 XP 中的兼容模式有同样的问题。我添加了版本号,瞧!固定的。

http://maps.googleapis.com/maps/api/js?v=3&key=...

指定v=3 强制稳定版本。 Google 解释了我没有这个版本标志的旧代码,因为我想要实验版本,而我的生产服务器从来不想要它。

仅供参考,我使用

我很高兴地说 Google 以非常积极的方式回应了这个问题;他们很快将其归类为错误,并建议他们正在处理它,今天我再次进行测试,发现 'quirks' 问题不再存在,我的应用程序再次正常运行。

我问的问题是'Can anyone suggest a resolution other than report this to Google and hope they fix it?'。我看到这个问题的应用程序(显然)严重依赖于 quirks 模式,所以我在尝试删除该依赖项时看到页面上其他组件的许多问题 - 即问题变得更大。因此 Google 解决这个问题确实是对我真正有用的唯一答案,我很高兴他们这样做了。

感谢大家的帮助和贡献。

在我的例子中,IE 11 没有响应 Google 地图.... 我的解决方案是: 第一点:

添加header:

第二点:

添加 JS V3:

此致