Google地图导航控件在IE11中失真/扭动

时间:2015-02-18 16:10:43

标签: javascript google-maps internet-explorer

这个问题与我在此问到的另一个问题松散相关:Google Maps API v3.19 Broken in Internet Explorer Quirks Mode。在尝试找到针对该问题的修补程序时Pointy建议进行更改,这为我提供了可用的地图,但该建议引发了左上角的Google地图导航控件的另一个问题。当我在IE11中拖动地图时,导航控件会摆动' wiggle'周围看起来很奇怪。这个问题也发生在之前的(冻结的)谷歌地图3.18版本中,因此似乎是另一个问题,而不是我提到的另一个问题,因此我在这个问题中提出了这个问题&#39自己的。

此页面演示了IE11中的问题。 Chrome和Firefox工作正常:

<!DOCTYPE html>
<head>
    <title>Google Maps Test Page</title>
</head>
<body style="margin:0; padding:0">
    <script src='http://maps.googleapis.com/maps/api/js?v=3.18' 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>

我还没有能够在任何其他版本的Internet Explorer中对此进行测试,但问题在IE11中非常明显。有谁知道如何克服这个显示问题?

1 个答案:

答案 0 :(得分:0)

我在一段时间后也遇到过这个问题,经过各种论坛的狩猎后发现以下样式更改解决了这个问题,至少在我的情况下是这样:

<script>
    var doc = document.documentElement;
    doc.setAttribute('data-useragent', navigator.userAgent);
</script>
<style type="text/css">
html[data-useragent*='Trident/7.0'] div[title^="Zoom"]
 {
        opacity: 0 !important;
 }
 html[data-useragent*='Trident/7.0'] div[title^="Pan"]
 {
        opacity: 0 !important;
 }
</style>

尝试一下,看看它是否有帮助,我希望它能做到,我现在已经太好了,这导致了多少痛苦以及花在寻找工作解决方案上的时间!