简体   繁体   English

Bing Maps v8不显示

[英]Bing Maps v8 doesn't show

I am trying the new Bing Maps v8. 我正在尝试新的Bing Maps v8。 I follow one of the firsts examples: http://www.bing.com/api/maps/sdk/mapcontrol/isdk#loadMapSync+HTML 我遵循第一个示例: http : //www.bing.com/api/maps/sdk/mapcontrol/isdk#loadMapSync+HTML

It works. 有用。 But when I add a text, like test , it stops showing the map: 但是当我添加文本(如test ,它将停止显示地图:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
    </head>
    <body>
        test
        <div id='printoutPanel'></div>
        <div id='myMap'></div>


        <script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol'></script>
        <script type='text/javascript'>
            function loadMapScenario()
            {
                var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
                    credentials: 'Your Bing Maps Key'
                });

            }

            window.onload = loadMapScenario;
        </script>
    </body>
</html>

The word test in the 7th line makes it to stop working. 第7行中的单词test使其停止工作。 Any idea? 任何想法?

The doctype shouldn't be the cause for failure here, in fact it should reduce issues as that is the doctype used for HTML5, which the map uses. doctype不应成为此处失败的原因,实际上,它应该减少问题,因为地图使用的HTML5就是doctype。

The code you provided should work. 您提供的代码应该可以使用。 Looking into this I found that the width of the map is never being set, and as such it ends up being 0. When no width or height is specified for the map, the map tries to use the dimensions of it's parent. 对此进行调查后发现,地图的宽度从未设置过,因此最终为0。当未为地图指定宽度或高度时,地图会尝试使用其父级的尺寸。 It appears that adding the text into body is causing the calculation to be incorrect. 似乎将文本添加到正文中会导致计算不正确。 I'll have the dev team look into this. 我将让开发团队对此进行研究。

Also, I would only use the Sync method of loading the map if you were migrating old code that needed to run synchronously. 另外,如果您要迁移需要同步运行的旧代码,则只会使用Sync方法来加载地图。 If you are creating a new app you should load the map control asynchronously as it will allow your page to load faster. 如果要创建新应用,则应异步加载地图控件,因为它将使您的页面加载速度更快。 http://www.bing.com/api/maps/sdk/mapcontrol/isdk#loadMapAsync+HTML http://www.bing.com/api/maps/sdk/mapcontrol/isdk#loadMapAsync+HTML

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM