javascript Google Maps API v3.19 在 Internet Explorer Quirks Mode 中损坏
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28587238/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Google Maps API v3.19 Broken in Internet Explorer Quirks Mode
提问by Elliveny
Version 3.19 of the Google Maps API became the default maps 'release' on the 17th Feb 2015 (See https://code.google.com/p/gmaps-api-issues/wiki/JavascriptMapsAPIv3Changelog). The release appears to be causing issues in Internet Explorer when using quirks mode, as is demonstrated by the following test page that I produced from an application which is affected by this issue (and so this may include more code than is necessary here):
Google Maps API 3.19 版于 2015 年 2 月 17 日成为默认地图“发布”(请参阅https://code.google.com/p/gmaps-api-issues/wiki/JavascriptMapsAPIv3Changelog)。使用quirks mode 时,该版本似乎会导致 Internet Explorer 出现问题,正如我从受此问题影响的应用程序生成的以下测试页面所示(因此这可能包含比此处所需的更多代码):
<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>
Both Firefox and Chrome will properly show a useable map, while IE raises an error deep in the Google Maps code which reads 'Could not get the display property. Invalid argument.' I've tried debugging the code but it is obfuscated, making it a painful challenge.
Firefox 和 Chrome 都可以正确显示可用的地图,而 IE 会在谷歌地图代码深处引发错误,内容为“无法获取显示属性”。无效的论点。' 我试过调试代码,但它被混淆了,使它成为一个痛苦的挑战。
Forcing the version back to the last 'frozen' release (3.18) fixes the issue for the time being, but this is only a temporary resolution.
强制版本回到上一个“冻结”版本 (3.18) 暂时解决了这个问题,但这只是一个临时解决方案。
Can anyone suggest a resolution other than report this to Google and hope they fix it?
除了向谷歌报告这个问题并希望他们解决这个问题之外,任何人都可以提出一个解决方案吗?
Additional note:
补充说明:
As I write I note that the information here https://code.google.com/p/gmaps-api-issues/wiki/JavascriptMapsAPIv3Changelogsays the releases are:
在我写这篇文章时,我注意到这里的信息https://code.google.com/p/gmaps-api-issues/wiki/JavascriptMapsAPIv3Changelog说这些版本是:
Experimental: 3.20
Release: 3.19
Frozen: 3.18
Version 3.17 will be removed. Requests for 3.17 or any prior version will now be served version 3.18'
版本 3.17 将被删除。对 3.17 或任何先前版本的请求现在将在 3.18 版中提供
While this page https://developers.google.com/maps/documentation/javascript/basics#Versioningsays (at the bottom of the page):
虽然此页面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.
This is rather confusing but I would think the Changelog link to be the more up to date source of information. This difference confused me so I thought it worth sharing the observation.
这相当令人困惑,但我认为 Changelog 链接是最新的信息来源。这种差异让我感到困惑,所以我认为值得分享观察结果。
Update 20-Feb-15:
15 年 2 月 20 日更新:
Yesterday Google confirmed this as a Bug - see https://code.google.com/p/gmaps-api-issues/issues/detail?id=7675- and advised 'We're looking into a fix.'
昨天谷歌确认这是一个错误 - 请参阅https://code.google.com/p/gmaps-api-issues/issues/detail?id=7675- 并建议“我们正在研究修复”。
Thanks for the comments and suggestions, but so far I haven't been able to find a work around which allows my application to work fully as other page components depend on quirks mode, creating a good deal of work to get the whole thing working again. I'm hopeful that Google's attention will resolve this for me.
感谢您的意见和建议,但到目前为止,我还没有找到一种解决方法,使我的应用程序能够完全工作,因为其他页面组件依赖于怪癖模式,因此需要做大量工作才能使整个事情再次工作. 我希望谷歌的关注能为我解决这个问题。
Update 21-Feb-15:
15 年 2 月 21 日更新:
https://code.google.com/p/gmaps-api-issues/issues/detail?id=7675now indicates 'A fix will be deployed in the coming week.'
https://code.google.com/p/gmaps-api-issues/issues/detail?id=7675现在表示“将在下周部署修复程序”。
采纳答案by Elliveny
I'm glad to say that Google responded to this issue in a very positive way; they quickly categorised it as a bug, advised they were working on it and today I'm testing again and see that the 'quirks' issue is no more and my application is again behaving.
我很高兴地说,谷歌以非常积极的方式回应了这个问题;他们很快将其归类为错误,并建议他们正在处理它,今天我再次进行测试,发现“怪癖”问题不再存在,我的应用程序再次运行。
The question I asked was 'Can anyone suggest a resolution other than report this to Google and hope they fix it?'. The application where I saw this issue is (evidently) heavily dependent on quirks mode and so I saw a number of issues with other components on the page when trying to remove that dependency - i.e. the issue became much bigger. Hence Google fixing this issue was indeed the only answer which really worked for me and I'm glad that they did.
我问的问题是“除了向 Google 报告并希望他们修复它之外,还有人可以提出解决方案吗?”。我看到此问题的应用程序(显然)严重依赖于怪癖模式,因此在尝试删除该依赖项时,我看到页面上的其他组件存在许多问题 - 即问题变得更大。因此,谷歌解决这个问题确实是唯一对我有用的答案,我很高兴他们做到了。
Thanks for everyone's help and contribution.
感谢大家的帮助和贡献。
回答by ajg
Found the same issue today with a web app I've just inherited. For some reason the previous devs were forcing IE into quirks (ie7) mode and the google api issue started today. I've updated the main html page to use IE edge mode by changing the html head section from
今天在我刚刚继承的一个网络应用程序中发现了同样的问题。出于某种原因,以前的开发人员强迫 IE 进入 quirks (ie7) 模式,而 google api 问题从今天开始。我已经更新了主 html 页面以使用 IE 边缘模式,方法是将 html head 部分从
<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" />
.....
to
到
<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" />
.....
(if you are missing it add the ie-edge meta... line)
(如果您缺少它,请添加 ie-edge meta... 行)
and its fixed it so far.
到目前为止它已经修复了。
Now to find out why the previous devs were forcing IE7 mode....
现在找出为什么以前的开发人员强制使用 IE7 模式....
回答by Joseph
SOLVED:Had same problem with IE8 (XP), IE9 (Win7) and compatibility mode in Win 7 and XP. I added the version number and voila! Fixed.
已解决:与 IE8 (XP)、IE9 (Win7) 和 Win 7 和 XP 中的兼容模式有相同的问题。我添加了版本号,瞧!固定的。
http://maps.googleapis.com/maps/api/js?v=3&key=...
http://maps.googleapis.com/maps/api/js ?v=3&key=...
Specifying v=3forces the stable release. My old code without this version flag was interpreted by Google as I wanted the experimental version which I never want for my production server.
指定v=3强制稳定版本。我没有这个版本标志的旧代码被谷歌解释为我想要我的生产服务器永远不需要的实验版本。
FYI, I use <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
仅供参考,我使用 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
回答by Chris Fox
We are using the GMLib Google Maps delphi component and we had the same problem. The GMLib component uses the TWebBrowser component inside.
我们正在使用 GMLib Google Maps delphi 组件,我们遇到了同样的问题。GMLib 组件内部使用了 TWebBrowser 组件。
Within the resource files of the GMLib component we found a map.html file. We added the following line to the section of the html file.
在 GMLib 组件的资源文件中,我们找到了一个 map.html 文件。我们将以下行添加到 html 文件的部分。
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
We then recompiled the resource files into the component, recompiled the delphi project and it worked.
然后我们将资源文件重新编译到组件中,重新编译delphi项目并且它工作了。
I suppose this is one of the downsides of using relatively unsupported free components.
我想这是使用相对不受支持的免费组件的缺点之一。
We are now considering moving to a commercial paid for google maps component to reduce the risk of this happening again.
我们现在正在考虑转向商业付费谷歌地图组件,以降低这种情况再次发生的风险。
回答by Laurent
In my case (.net 4 visual c# with a webbrowser integrated) to fix this issue I just add &v=3 It seems that if you don't specify the version it will use the experimental one ... strange.
在我的情况下(.net 4 visual c# 与 webbrowser 集成)来解决这个问题我只是添加 &v=3 似乎如果你不指定版本它将使用实验版本......奇怪。
回答by Armando Cordova
In my case, IE 11 not response with Google Maps .... My solution is: point one:
就我而言,IE 11 不响应 Google Maps .... 我的解决方案是:第一点:
Add header :
添加标题:
Point two:
要点二:
Add JS V3:
添加JS V3:
Regards
问候
回答by Bernardo
I have an application in Delphi using TWebBroser, this was the temporary solution that I found, but is not 100% because to solve this I had to add a Key on Windows, using regedit. Forcing IE to emulate in the version informed on the Key I created, for better understanding look at the item Browser Emulation inside this link https://msdn.microsoft.com/en-us/library/ee330730(v=vs.85).aspx. This solution only works if the IE version stated in the Key is installed.
我在 Delphi 中有一个使用 TWebBroser 的应用程序,这是我找到的临时解决方案,但不是 100%,因为要解决这个问题,我必须使用 regedit 在 Windows 上添加一个密钥。强制 IE 在我创建的密钥上的版本中进行仿真,为了更好地理解,请查看此链接中的浏览器仿真项https://msdn.microsoft.com/en-us/library/ee330730(v=vs.85) .aspx。此解决方案仅在安装了密钥中所述的 IE 版本时才有效。
回答by Graffito
We also faced the same issue in a C# program using the standard .net WebBrowser control.
我们在使用标准 .net WebBrowser 控件的 C# 程序中也遇到了同样的问题。
We also solved the problem by adding the line
我们还通过添加行解决了这个问题
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Note that it didn't work on a Vista configuration with Internet Explorer 7, but it was OK after installation of IE 9 (more than 3 hours for installing Service pack1, service pack 2, 2 microsoft corrective patches and finally IE9 itself).
请注意,它在带有 Internet Explorer 7 的 Vista 配置上不起作用,但在安装 IE 9 后就可以了(安装 Service Pack1、Service Pack 2、2 个微软修正补丁和最后 IE9 本身需要 3 个多小时)。
回答by enpelolo
This works fine
这工作正常
< script src="https://maps.googleapis.com/maps/api/js&v=3.18" type="text/javascript"></script>
This don't
这不
< script type="text/javascript" src="https://maps.googleapis.com/maps/api/js&v=3.18"</script>