2
我試圖讓我的位置座標與HTML5,但它每次都給我錯誤。phonegap HTML5地理位置
這是手機的差距Android項目
我用電話差距地理位置的文檔,相同的代碼的代碼我有寫。 並添加號召功能設備準備就緒()知道,如果這個代碼運行
,這讓我
error 2 : messege 2 : the last location provider was disabled
這是我使用得上我的位置的代碼android設備!
<!DOCTYPE html>
<html>
<head>
<title>Device Properties Example</title>
<script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for PhoneGap to load
//
document.addEventListener("deviceready", onDeviceReady, false);
var watchID = null;
// PhoneGap is ready
//
function onDeviceReady() {
// Update every 3 seconds
var options = { frequency: 3000 };
watchID = navigator.geolocation.watchPosition(onSuccess, onError, options);
}
// onSuccess Geolocation
//
function onSuccess(position) {
var element = document.getElementById('geolocation');
element.innerHTML = 'Latitude: ' + position.coords.latitude + '<br />' +
'Longitude: ' + position.coords.longitude + '<br />' +
'<hr />' + element.innerHTML;
//alert("the lang is : "+position.coords.latitude);
document.write("the lang is : "+position.coords.latitude);
}
// clear the watch that was started earlier
//
function clearWatch() {
if (watchID != null) {
navigator.geolocation.clearWatch(watchID);
watchID = null;
}
}
// onError Callback receives a PositionError object
//
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
</script>
</head>
<body>
<p id="geolocation">Watching geolocation...</p><br>
<button onclick="onDeviceReady();">onDeviceReady()</button> <br>
<button onclick="clearWatch();">Clear Watch</button> <br>
<a href="index2.html"> index 2 </a>
</body>
</html>
我從這裏得到了本教程http://docs.phonegap.com/en/1.7.0/cordova_geolocation_geolocation.md.html#Geolocation!
希望建議我該做什麼!
這個問題可以幫助你找出問題:http://stackoverflow.com/questions/5407973/navigator-geolocation-getcurrentposition-throws-the-last-location-提供者 - 是 – Arnab
它仍然不與我合作,沒有什麼變化,我啓用了位置! –