【问题标题】:Some Google Map Markers not showing up in Internet Explorer but show up in all other browsers某些 Google 地图标记未显示在 Internet Explorer 中,但显示在所有其他浏览器中
【发布时间】:2011-06-13 12:31:29
【问题描述】:

我在我们的网站上有一个谷歌地图,其中包含使用以下代码引入的标记列表:

$(".map-overlay-right").click(function () {
    var map = new GMap2(document.getElementById('map-holder'));
    $("#map-holder").fadeOut('slow', function(){                                    
        var gmarkers = [];  
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());

        $.get("http://afid.staging.dante-studios.com/xml-feed-google-maps",{},function(xml) {
            $('marker',xml).each(function(i) {
                html = $(this).text();
                lat = $(this).attr("lat");
                lng = $(this).attr("lng");
                label = $(this).attr("label");
                var point = new GLatLng(lat,lng);
                var marker = createMarker(point,label,html);
                map.addOverlay(marker);
            });
        });

    });
    $("#map-holder").fadeIn('slow');    
    var Asia = new GLatLng(23.684774, 90.087891);
    map.setCenter(Asia, 4); 
});

引入它们的 XML 文件如下所示:

<?xml version="1.0"?>
<markers> 
    <marker id="1" lat="11.547812" lng="104.915957" label="Foo"> 
        <infowindow> 
            <![CDATA[HTML GOES HERE]]>
        </infowindow> 
    </marker> 
    <marker id="2" lat="11.547812" lng="104.915957" label="Bar"> 
        <infowindow> 
            <![CDATA[HTML GOES HERE]]>
        </infowindow> 
    </marker> 
    <marker id="3" lat="11.547812" lng="104.915957" label="Baz"> 
        <infowindow> 
            <![CDATA[HTML GOES HERE]]>
        </infowindow> 
    </marker>  
</markers>

由于某些原因,并非所有标记都显示在 Internet Explorer 中。 IE 抛出此错误:

网页错误详情

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.4; OfficeLivePatch.1.3)
Timestamp: Thu, 17 Dec 2009 12:39:16 UTC


Message: Invalid argument.
Line: 143
Char: 18
Code: 0
URI: http://maps.gstatic.com/intl/en_ALL/mapfiles/193c/maps2.api/main.js

但其他浏览器似乎还可以,并且表现良好。抛出错误的部分代码是这个位:

map.addOverlay(marker);

可以在此处查看该站点:http://afid.staging.dante-studios.com/ 并单击 Asia 会最好地显示错误,因为 india 底部的标记会显示在所有浏览器上,但不会在 IE 中显示。

我花了一段时间试图解决这个问题,但我没有得到任何结果。如果有人能对此有所了解,我将不胜感激。

【问题讨论】:

    标签: javascript internet-explorer google-maps cross-browser


    【解决方案1】:

    标记 XML 中的标记 42 的纬度格式错误:

    <marker id="42" lat="-12.968270," lng="28.633699" label="Ndola, Zambia">
    

    注意lat 属性中的尾随逗号。

    【讨论】:

    • 实际上,当我在 IE 中打开它并显示它时,它允许我使用 Visual Studio 对其进行调试。我认为这是一个伪造的标记,所以经过一些堆栈导航后,我发现了有问题的纬度值,然后在 XML 中搜索它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-05
    • 2014-07-18
    • 1970-01-01
    • 2012-02-13
    • 1970-01-01
    • 2010-11-01
    • 2011-01-31
    相关资源
    最近更新 更多