谷歌地图显示在FF罚款,但不是IE

时间:2011-11-03 15:33:46

标签: jquery html google-maps

我迷失了为什么它没有出现

这是谷歌地图,并遵循本教程。

http://code.google.com/apis/maps/articles/phpsqlajax.html

问题是IE中的地图显示但是没有标记?任何人都有任何想法

这是现在正在运行的页面Took out页面。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Barefoot Runners User Map</title>
    <script src="http://maps.google.com/maps?file=api&v=2&key=key" 
       type="text/javascript"></script>
    <script type="text/javascript">
    //<![CDATA[

    var iconBlue = new GIcon(); 
    iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png';
    iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
    iconBlue.iconSize = new GSize(12, 20);
    iconBlue.shadowSize = new GSize(22, 20);
    iconBlue.iconAnchor = new GPoint(6, 20);
    iconBlue.infoWindowAnchor = new GPoint(5, 1);

    var iconRed = new GIcon(); 
    iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
    iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
    iconRed.iconSize = new GSize(12, 20);
    iconRed.shadowSize = new GSize(22, 20);
    iconRed.iconAnchor = new GPoint(6, 20);
    iconRed.infoWindowAnchor = new GPoint(5, 1);

    var customIcons = [];
    customIcons["restaurant"] = iconBlue;
    customIcons["bar"] = iconRed;

    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        //map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(38.323272, -95.712891), 4);

        // Change this depending on the name of your PHP file
        GDownloadUrl("phpsqlajax_genxml3.php", function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
            var name = markers[i].getAttribute("name");
            var address = markers[i].getAttribute("street");

            var point = new GLatLng(parseFloat(markers[i].getAttribute("latitude")),
                                    parseFloat(markers[i].getAttribute("longitude")));
            var marker = createMarker(point, name, address);
            map.addOverlay(marker);
          }
        });
      }
    }

    function createMarker(point, name, address, type) {
      var marker = new GMarker(point, customIcons[type]);
      var html = "<b>" + name + "</b> <br/>" + address;
      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html);
      });
      return marker;
    }
    //]]>
  </script>
  </head>

  <body onload="load()" onunload="GUnload()">
    <div id="map" style="width: 800px; height: 600px"></div>
  </body>
</html>

1 个答案:

答案 0 :(得分:1)

它在var xml = GXml.parse(data)失败,所以phpsqlajax_genxml3.php

返回的xml显然有问题
<marker name="Olle Albinsson" street="Professorsvägen" latitude="65.617922" longitude="22.152571" />

好像很特别?

<强>更新

要在Internet Explorer中调试这些错误,您可以使用“开发人员工具”。当您在IE中按F12时,您会获得一些firebug / chrome调试工具。当出现javascript错误时,检查控制台会给你提供相应的信息。

在您的情况下,我检查了Network标签,并将xml的内容复制粘贴到文档中。 IE开发人员工具控制台说我们在线 * 上遇到的问题似乎是上面指定的标记。

祝你好运