Hi, guys!
What I’m doing:
I’m developing an app using Ionic v2, Google Maps API v3 and Cordova Geolocation for tracking user position.
The problem:
When I run the app on the Android device with the GPS OFF, I always get a “Code 3: Timeout expired” error.
My questions are:
- Should the Cordova Geolocation use the Phone Network (or Wifi) to get the user position when the GPS is offline?
- If not, there is another way to find the user location using the Network or Wifi?
The code:
getCurrentPosition (callback: (result: any) => any) {
Geolocation.getCurrentPosition({timeout: 5000}).then((resp) => {
console.log('Getting location:');
console.log('Lat ' + resp.coords.latitude);
console.log('Lng ' + resp.coords.longitude);
callback(resp.coords); // send the results to the
}).catch((error) => {
alert('Error getting location'+JSON.stringify(error));
alert(' Code: '+ error.code + ' Message: ' +error.message);
});
}
Best,