Geolocation Cordva ionic framework Timeout Expired Error

This post will help u come out of scenario where u get error code 3 or Timeout expired error message from

    alert('Latitude: '          + position.coords.latitude          + '\n' +
      'Longitude: '         + position.coords.longitude         + '\n' +
      'Altitude: '          + position.coords.altitude          + '\n' +
      'Accuracy: '          + position.coords.accuracy          + '\n' +
      'Altitude Accuracy: ' + position.coords.altitudeAccuracy  + '\n' +
      'Heading: '           + position.coords.heading           + '\n' +
      'Speed: '             + position.coords.speed             + '\n' +
      'Timestamp: '         + position.timestamp                + '\n');
  function(error) {
    alert('code: '    + error.code    + '\n' +
      'message: ' + error.message + '\n');

  },  {maximumAge: 0, timeout: 50000, enableHighAccuracy: false });

Now there are following prerequisites to solve out this error.



<!-- cordova script (this will be a 404 during development) -->

<!-- ionic/angularjs js -->


The order matters how to order your script files in index.html


<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />

This is my project config.xml. Notice that whitelist plugin is well installed and is configured by me to allow-intent to geo:*


We should install device, geolocation, network-information and test out that other plugins are working properly or not. We should that we are focused on geolocation not working error.

The timeout for geolocation code should be increased upto 50000 to make it test well that our code is working or not.

Finally lets work on your device. It might happen to you that your geolocation might be working on one device and not on other. So this should too be confirmed. Because if your code running well on one android device. Then problem is already solved. It might only be network issue on second.

While adding android platform to your project make sure that you have used following command. Because it will provide you latest cordova-android version. Other commands will never do out this job for you. Geolocation plugin always asks for cordova version > 5.0  To achieve this kindly use following code to add android platform to your project.

cordova platform add


ionic platform add


Ref :

Conclusion, if my post solved your problem. Kindly reply a comment. Or mail me if your need further help at


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s