繁体   English   中英

必应地图不会显示在index.cshtml上?

[英]bing maps will not display on index.cshtml?

我正在尝试使用Microsoft在其网站上提供的标准文档示例将Bing映射添加到我的ASP.NET Core MVC网站中

我已经包含了API密钥,并发现该地图确实已加载到标准HTML文档中,但未加载到我的index.cshtml视图中。 我尝试了各种解决方案,例如在body标签中包含onload="GetMap()" ,但到目前为止没有任何效果。

<div class="col-md-5">
    <h2>test</h2>
    <div id="myMap" style="position:relative;width:600px;height:600px; background-color: red;"></div>
    <script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=[My API KEY]' async defer></script>
    <script type='text/javascript'>
        function GetMap() {
            var map = new Microsoft.Maps.Map('#myMap');
            //Add your post map load code here.
        }
    </script>
</div>

没有错误消息,只有空白页

示例代码中的Bing Maps javascript通过http加载-如果托管网站改为使用https,则由于内容混合,请求将被阻止。 将Bing Maps的src更新为https也可以解决此问题。

 <script type='text/javascript'>
        var map;
    function GetMap() {
         map = new 
          Microsoft.Maps.Map(document.getElementById('myMap'), {});
    }
</script>

暂无
暂无

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

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