gpt4 book ai didi

javascript - 谷歌地图 JS API Windows Phone Cordova

转载 作者:太空宇宙 更新时间:2023-11-03 11:06:52 24 4
gpt4 key购买 nike

所以我正在尝试制作这个使用 Google map API 的应用程序。它适用于 android,但当我在 Windows Phone 模拟器上尝试它时,它说“应用程序无法在本地上下文中加载远程 Web 内容”。现在,我搜索了一下,这是意料之中的(我还尝试了使用 iframe 的解决方案 - 没有用。)。问题是我该如何解决这个问题。是否可以将 Google map 与 Windows Phone 和 Cordova 一起使用,或者我必须使用不同的 map API?

适用于 android 但不适用于 WP 的代码:-- 谢谢大家。

    <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Security-Policy" content=" ">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>BlankCordovaApp1</title>

<!-- BlankCordovaApp1 references -->
<link href="css/index.css" rel="stylesheet" />
<link href="css/jquery.mobile-1.4.5.css" rel="stylesheet" />

<script src="scripts/jquery-2.1.4.js"></script>
<script src="scripts/jquery.mobile-1.4.5.js"></script>

<script>
$(document).on("pagecreate","#map-page", getMaps);

function createMap() {
console.log("Reached createMap() ")
var mapOptions = {
center: new google.maps.LatLng(37.98392, 23.71889),
zoom: 11
};
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
}

function getMaps() {
$.getScript('http://maps.googleapis.com/maps/api/js?callback=createMap');
console.log("Got Maps");
}

</script>


</head>
<body>
<!--Page 1-->
<div data-role="page" id="login" data-theme="b">
<div data-role="content">
<p>Page 1</p>
<a href="#map-page" class="ui-btn">Page 2</a>
</div>
</div>

<!--Page 2-->
<div data-role="page" id="map-page">
<div data-role="header">
<h1> Header </h1>
</div>
<div data-role="content">
<div id="map" style="height: 400px;width: 100%"></div>
<a href="#" class="ui-btn" data-rel="back">Go Back</a>
</div>
<div data-role="footer" style="text-align:center" data-position="fixed">
<p> Footer </p>
</div>
</div>

<!-- Cordova reference, this is added to your app when it's built. -->
<script src="cordova.js"></script>
<script src="scripts/platformOverrides.js"></script>

<script src="scripts/index.js"></script>
</body>
</html>

最佳答案

确保您的 list 文件中具有正确的功能。我不使用 windows phpne 8,但大多数时候您的应用需要用户的许可才能访问互联网。

Properties/WPAppManifest.xml

<Capabilities>
<Capability Name="ID_CAP_NETWORKING" />
</Capabilities>

关于javascript - 谷歌地图 JS API Windows Phone Cordova,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31880615/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com