2014-10-28 74 views
1

我成功地使用這個(https://github.com/apache/cordova-plugin-geolocation)爲科爾多瓦實施地理位置,但GPS在手機中關閉onerror功能從未被調用。是否有任何其他方式檢查在打開GPS或off.Here是我的代碼在科爾多瓦檢查GPS狀態(開/關)android

navigator.geolocation.getCurrentPosition(function (position) { 
//getting location 
lat=position.coords.latitude; 
long=position.coords.longitude; 

}, function (error) { 
     //when gps is off it is never executed 
     alert('Unable to get location: ' + error.message); 

     }); 

UPDATE

onerrorSONY XPERIA執行Ť,而不是在其他設備(Micromax的,三水NG,Motog

回答

1

我不知道這是不是你想要的,但我使用這個插件,它爲我

https://github.com/mablack/cordova-diagnostic-plugin

我覺得地理位置API不給你一個運作良好如果GPS打開/關閉,錯誤如果在指定的時間限制內無法獲得鎖定,則只是一個超時錯誤,但前一段時間我測試了它,可能是錯誤的。

+0

我已經找到你的解決方案 – 2014-12-15 15:23:04

+0

任何方式謝謝你的回答:) – 2014-12-15 15:32:48

+0

不客氣;) – Mirko 2014-12-16 14:38:35