当我在 phonegap 地理定位中尝试一个示例程序时。我在没有互联网或 GPS 的情况下在我的三星流行音乐中获取当前位置的纬度和经度。当我的设备中的 wifi 和 gps 被禁用时,我不知道它是如何获取当前位置的坐标、高度和时间戳的。请帮助我..
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org /TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>My Locator</title>
<script type="text/javascript" charset="utf-8" src="../plugins/phonegap-1.1.0.js"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
navigator.geolocation.getCurrentPosition(onSuccess,Error);
}
function onSuccess(position) {
var element = document.getElementById('geolocation');
element.innerHTML = 'Latitude: ' + position.coords.latitude
+ '<br />' + 'Longitude: ' + position.coords.longitude
+ '<br />' + 'Accuracy: ' + position.coords.accuracy
+ '<br />' + 'Timestamp: ' + new Date(position.timestamp) + '<br />';
}
function onError(error) {
alert('code: ' + error.code + '\n' + 'message: ' + error.message + '\n');
}
</script>
</head>
<body>
<p id="geolocation">
Finding geolocation...
</p>
</body>
</html>