我正在編寫一個Cordova/Phonegap應用程序,我想使用Geolocation插件來獲取經度和緯度。這是我的代碼:科爾多瓦/ Phonegap地理定位
$scope.showCoord = function() {
var onSuccess = function(position) {
console.log("Latitude: "+position.coords.latitude);
console.log("Longitude: "+position.coords.longitude);
};
function onError(error) {
console.log("Code: "+error.code);
console.log("Message: "+error.message);
};
navigator.geolocation.getCurrentPosition(onSuccess, onError, { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true });
}
當我嘗試這個插件用它工作得很好,但是當我嘗試沒有GPS我收到超時......我更改超時100000但不工作的GPS。此外在我的config.xml中添加了以下代碼:
<feature name="Geolocation">
<param name="android-package" value="org.apache.cordova.GeoBroker" />
</feature>
我該如何解決?
對不起,我想獲取GPS時,它是積極的,當它關閉時我想接收來自網絡 – Ragnarr
的座標它不工作對我來說......如果我設置了超時1分鐘,我總是獲得超時...我正在測試我的android設備 – Ragnarr
此外,如果我關閉連接,我必須收到POSITION_UNAVAILABLE時收到超時 – Ragnarr