我的电话间隙期只有两个月左右。我一直在谷歌波纹模拟器中测试该应用程序,并且谷歌地图的一切都运行良好。
但是,当我将此项目上传到phonegap build 并将其安装到我的Android 设备中时,谷歌地图不会显示。
这是我的index.html
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script src="lib/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<link href="css/all.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" charset="utf-8">
window._cordovaNative = true;
</script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady()
{
//navigator.geolocation.getCurrentPosition(onSuccess, onError);
var map = new GoogleMaped();
map.initialize();
}
function GoogleMaped()
{
this.initialize = function(){
var map = showMap();
}
var showMap = function(){
var mapOptions =
{
zoom: 4,
center: new google.maps.LatLng(55.689403, 12.521281),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
return map;
}
}
$(document).ready(function(){
alert("hi al");
});
</script>
</head>
<body>
<div id="phonegapWrapper" style="">
<div id="map_canvas">
</div>
</div>
<script type="text/javascript" src="phonegap.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</body>
</html>
这是我的 config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.empatix.app"
versionCode = "10"
version = "1.0.0" >
<plugin name="cordova-plugin-whitelist" />
<plugin name="com.indigoway.cordova.whitelist.whitelistplugin" spec="1.1.1" source="pgb" />
<!-- versionCode is optional and Android only -->
<feature name="http://api.phonegap.com/1.0/network"/>
<feature name="http://api.phonegap.com/1.0/device"/>
<feature name="http://api.phonegap.com/1.0/geolocation"/>
<feature name="http://api.phonegap.com/1.0/notification"/>
<access origin="*"/>
<access origin="http://google.com" />
<access origin="https://google.com" />
<access origin="http://maps.google.com" />
<access origin="http://maps.google.com/*" />
<access origin="http://*.google.com" />
<access origin="http://dev.hospitalku.com/*" />
<access origin="http://code.jquery.com/*" />
<access origin="https://maxcdn.bootstrapcdn.com/*" />
<access origin="https://maxcdn.bootstrapcdn.com/*" />
<access origin="*" />
<access origin="*.google.com"/>
<access origin="*.googleapis.com"/>
<access origin="*.gstatic.com"/>
<allow-navigation href="*" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="data:*" />
<allow-intent href="geo:*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="*" />
<name>Empatix App</name>
<description>
An example for phonegap build docs.
</description>
<author href="https://dev.hospital.com" email="[email protected] /cdn-cgi/l/email-protection">
Hardeep Shoker
</author>
<access origin="http://phonegap.com" subdomains="true" />
</widget>
我在phonegap调试服务中收到的唯一控制台消息是:
未找到内容安全策略元标记。使用cordova-plugin-whitelist插件时请添加一项。
有人可以帮我解决这个问题吗?
提前谢谢了。
您必须在您的index.html(头部部分)中添加这一行:
<meta http-equiv="Content-Security-Policy" content="default-src ...">
有关详细说明,请查看此文档:
https://github.com/apache/cordova-plugin-whitelist#content-security-policy https://github.com/apache/cordova-plugin-whitelist#content-security-policy
这里有一篇关于SO的帖子:“找不到内容安全策略元标记。”我的phonegap应用程序出现错误 https://stackoverflow.com/questions/30212306/no-content-security-policy-meta-tag-found-error-in-my-phonegap-application
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)