我从以下链接中获取了以下演示代码: http://docs.phonegap.com/en/3.0.0/cordova_geolocation_geolocation.md.html
当我使用Adobe PhoneGap Build编译为IOS设备并将其安装在我的iPhone上时,没有任何反应。我得到的只是“寻找地理位置......”。我从未被提示接受位置服务或看到警报已执行。
我的配置文件包含以下相关行:
<preference name="phonegap-version" value="3.0.0" />
<gap:plugin name="org.apache.cordova.geolocation" />
<feature name="Geolocation">
<param name="ios-package" value="CDVLocation" />
</feature>
有没有人让这个工作?
<html>
<head>
<title>Device Properties Example</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.5.0.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
//
function onDeviceReady() {
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
// onSuccess Geolocation
//
function onSuccess(position) {
var element = document.getElementById('geolocation');
element.innerHTML = 'Latitude: ' + position.coords.latitude + '<br />' +
'Longitude: ' + position.coords.longitude + '<br />' +
'Altitude: ' + position.coords.altitude + '<br />' +
'Accuracy: ' + position.coords.accuracy + '<br />' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '<br />' +
'Heading: ' + position.coords.heading + '<br />' +
'Speed: ' + position.coords.speed + '<br />' +
'Timestamp: ' + position.timestamp + '<br />';
}
// onError Callback receives a PositionError object
//
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
</script>
</head>
<body>
<p id="geolocation">Finding geolocation...</p>
</body>
</html>
答案 0 :(得分:0)