我採取下面的演示代碼從以下鏈接時: http://docs.phonegap.com/en/3.0.0/cordova_geolocation_geolocation.md.htmlPhoneGap的地理位置不工作使用Adobe的PhoneGap構建
當我使用的Adobe的PhoneGap構建編譯爲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>
在腳本中進行了更改爲3.0.0,它仍然無效。 – user1218244