Ionic 2 + Cordova Geolocation- Problem when GPS is OFF


#1

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:

  1. Should the Cordova Geolocation use the Phone Network (or Wifi) to get the user position when the GPS is offline?
  2. 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,


#2

I have the same problem, and nothing seems to work.