phonegapを使用してAndroidデバイスでgpsがオンになっていることを知りたいです。
のようにしてみました
navigator.geolocation.getCurrentPosition(function onSuccess(position){
console.log("The gps is availabile");
},
function geolocationError(error){
console.log("The geo error : " + error.code +"code : " + PositionError.PERMISSION_DENIED);
if( error.code == PositionError.PERMISSION_DENIED ){
alert("Please turn on your gps to start the trip");
}else{
console.log("Gps is turned on. but not availabile");
}
},{enableHighAccuracy: true , timeout:10000 });
しかし、GPSがオフになっていると、PositionError.PERMISSION_DENIED
エラーは発生しません。常に表示されますPositionError.POSITION_UNAVAILABLE
。GPSがオン/オフになっていることをどのように識別できますか?.(GPSが利用可能かどうかではありません)