代码之家  ›  专栏  ›  技术社区  ›  Chaddeus

为什么Internet Explorer会中断“Pegman”在谷歌地图API v3中的显示?

  •  0
  • Chaddeus  · 技术社区  · 14 年前

    On my site here SteetView控件,又名“Pegman”,在Firefox下工作得很好。在IE(本例中为7,但在8上测试结果相同)下,它会破坏Pegman控件的显示。

    这是我的地图代码:

    var directionsDisplay;
    var directionsService = new google.maps.DirectionsService();
    var map;
    
    directionsDisplay = new google.maps.DirectionsRenderer();
    var milBase = new google.maps.LatLng(35.79648921414565, 139.40663874149323);
    var mapOpts = {
        streetViewControl: true,
        zoom: 12,
        center: milBase,
        mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.DROPDOWN_MENU },
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map($("#dirMap").get(0), mapOpts);
    directionsDisplay.setMap(map);
    
    var basePoly = new google.maps.Polygon({
        paths: [new google.maps.LatLng(35.724496338474104, 139.3444061279297), new google.maps.LatLng(35.74748750802863, 139.3363380432129), new google.maps.LatLng(35.75765724051559, 139.34303283691406), new google.maps.LatLng(35.76545779822543, 139.3418312072754), new google.maps.LatLng(35.767547103447725, 139.3476676940918), new google.maps.LatLng(35.75835374997911, 139.34955596923828), new google.maps.LatLng(35.755149755962755, 139.3567657470703), new google.maps.LatLng(35.74679090345495, 139.35796737670898), new google.maps.LatLng(35.74762682821177, 139.36294555664062), new google.maps.LatLng(35.744422402303826, 139.36346054077148), new google.maps.LatLng(35.74860206266584, 139.36946868896484), new google.maps.LatLng(35.735644401200986, 139.36843872070312), new google.maps.LatLng(35.73843117306677, 139.36174392700195), new google.maps.LatLng(35.73592308277646, 139.3531608581543), new google.maps.LatLng(35.72686543236113, 139.35298919677734), new google.maps.LatLng(35.724496338474104, 139.3444061279297)],
        strokeColor: "#ff0000",
        strokeOpacity: 0.8,
        strokeWeight: 2,
        fillColor: "#FF0000",
        fillOpacity: 0.35
    });
    basePoly.setMap(map);
    
    var marker = new google.maps.Marker({
        position: new google.maps.LatLng(35.79648921414565, 139.40663874149323),
        map: map,
        title: "Ruby International"
    });
    
    function calcRoute() {
        var start = new google.maps.LatLng(35.74005964772476, 139.37083393335342);
        var end = new google.maps.LatLng(35.79648921414565, 139.40663874149323);
        var request = {
            origin: start,
            destination: end,
            travelMode: google.maps.DirectionsTravelMode.DRIVING
        };
        directionsService.route(request, function(result, status) {
            if (status == google.maps.DirectionsStatus.OK) {
                directionsDisplay.setDirections(result);
            }
        });
    }
    

    与我的代码和谷歌代码唯一的区别是,我使用jquery的document ready函数而不是body onload事件来初始化我的地图。但无法想象这就是原因(适用于地图的第2版)。

    我是否发现了一个错误,或者我的代码有什么问题?

    事先谢谢!

    1 回复  |  直到 14 年前
        1
  •  1
  •   Chaddeus    14 年前

    结果发现谷歌地图API代码中有一个错误。他们已经发布了解决方案,问题已经解决了。