Reputation: 5848
I am successfully implement the geolocation using this (https://github.com/apache/cordova-plugin-geolocation) for cordova,however the gps is turned off in the phone onerror
function is never called.Is there any another way to check the gps is turned on or off.Here is my code
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
onerror
is executed in SONY XPERIA T,but not in other devices (Micromax,Samsung,Motog)
Upvotes: 1
Views: 1725
Reputation: 5037
I do not know if this is what you want, but I am using this plugin which works well for me
https://github.com/mablack/cordova-diagnostic-plugin
I think the Geolocation API does not give you an error if the GPS is on/off, just a timeout error if it is not able to get a lock in the time limit you specify, but I tested it a while ago and I might be mistaking.
Upvotes: 1