【发布时间】:2014-06-24 13:15:06
【问题描述】:
我目前正在尝试在 Visual Studio 中提供的新“多设备混合应用”模板中使用 Bing Maps AJAX API v7,该模板使用 Apache Cordova 提供跨平台兼容性。我按照模板编写了以下代码在http://msdn.microsoft.com/en-us/library/gg427624.aspx:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta charset="utf-8" />
<title>Wand</title>
<!-- Wand references -->
<link href="css/index.css" rel="stylesheet" />
<script charset="UTF-8" type="text/javascript" src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&s=1">
</script>
<script type="text/javascript">
function GetMap() {
var map = new Microsoft.Maps.Map(document.getElementById("map"), { credentials: "AgegeewHkb9iTTQDLseMTuQyxQyZybs7uUv7aqIgKu6U8CiaflVNApy5WtDXqtHr " });
}
</script>
</head>
<body onload="GetMap();">
<div id='map' class="mainview"></div>
<div class="menu">This is the menu</div>
<!-- Cordova reference, this is added to your app when it's built. -->
<script src="cordova.js"></script>
<script src="scripts/index.js"></script>
</body>
</html>
但是当我在 Windows 8.1 中调试它时,它说 Microsoft 没有定义(在 GetMap 函数中)。我假设图书馆来自
https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&s=1
未正确加载。我的代码有什么问题吗?我应该使用 AJAX WEB API,还是有另一个用于应用程序(我看到的唯一一个仅适用于 Windows 8)?
我认为我的应用无法加载网络库,因为它没有适当的权限。在 config.xml 中有一个域访问部分,但它说它不适用于 windows 平台,那么我该如何设置它以允许从 https://ecn.dev.virtualearth.net 加载页面?
编辑:从 Web 上下文 (ms-appx-web) 加载脚本使脚本运行,但如果我希望代码是多平台的,我不能使用它。解决方案是在 Windows 8 清单中包含 Bing 地图 URL 的权限,我该怎么做?
【问题讨论】:
标签: visual-studio cordova windows-8 bing-maps visual-studio-cordova