我正在使用phoneGap使用cordova.js脚本文件构建一个Web应用程序。但是当我尝试访问该位置时,我无法获取任何数据。我的html文件是:
<html>
<head>
<title>GeoLocation</title>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady(){
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
function onSuccess(position)
{
document.getElementById("latitude").innerHTML= position.coords.latitude;
document.getElementById("longitude").innerHTML= position.coords.longitude;
document.getElementById("altitude").innerHTML= position.coords.altitude;
document.getElementById('timestamp').innerHTML = new Date(position.timestamp);
}
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
</script>
</head>
<body>
<h1>GeoLocation</h1>
<table border="1">
<tr> <td>Latitude</td> <td id="latitude"></td> <tr>
<tr> <td>Longitude</td> <td id="longitude"></td> <tr>
<tr> <td>Altitude</td> <td id="altitude"></td> <tr>
<tr> <td>Timestamp</td> <td id="timestamp"></td> <tr>
</table>
</body>
</html>
我已经添加了manifest.xml文件中所需的所有必要权限,但它仍然无法在android模拟器上运行。