Bing Maps V8 不适用于 IE、Chrome 和 Firefox

Bing Maps V8 not working with IE, Chrome, and Firefox

我正在尝试将 Bing 地图从 V7 升级到 V8。但是,当我将地图脚本 URL 更改为引用 V8 时,地图有时会在 Internet Explorer 浏览器中显示,而在 Chrome 和 Firefox 浏览器

中则根本无法使用

这是我用来加载 Bing 地图的代码

<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
        <script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol'></script>
        <!--<script type='text/javascript' src='http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0'></script>-->
    </head> 
    <body> 

        <div id="divMapView" style="width:800px;height:500px"></div>

         <script type="text/javascript">
            var map = new Microsoft.Maps.Map(document.getElementById('divMapView'), {
                credentials: 'My Bing Maps Key'
            });
        </script>

    </body> 
</html> 

我还应该怎么做才能使我的代码适用于所有浏览器?

对于这个问题,我有两个解决方案,一个用于同步负载,另一个用于异步负载

1- 对于同步加载:Load The map on "onload" page event

<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
        <script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol'></script>
        <!--<script type='text/javascript' src='http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0'></script>-->
    </head> 
    <body> 

        <div id="divMapView" style="width:800px;height:500px"></div>

         <script type="text/javascript">
             var loadMap = function () {
                 var map = new Microsoft.Maps.Map(document.getElementById('divMapView'), {
                     credentials: 'My Bing Maps Key'
                 });
             }

             window.onload = loadMap;
        </script>

    </body> 
</html> 

2- 对于异步加载:可以正常工作没有问题

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?callback=GetMap' async defer></script>
        <!--<script type='text/javascript' src='http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0'></script>-->
    </head>
    <body>

        <div id="divMapView" style="width:800px;height:500px"></div>

        <script type="text/javascript">
                    function GetMap() {
                        var map = new Microsoft.Maps.Map(document.getElementById('divMapView'), {
                            credentials: 'My Bing Maps Key'
                        });
                    }
        </script>

    </body>
</html>