# Cordova geolocation always getting timeout

**URL:** <https://forum.ionicframework.com/t/cordova-geolocation-always-getting-timeout/15841>\
**Category:** ionic-v1\
**Created:** [January 16, 2015, 3:40pm UTC](https://forum.ionicframework.com/t/cordova-geolocation-always-getting-timeout/15841 "2015-01-16T15:40:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajul885](https://avatars.discourse-cdn.com/v4/letter/r/cab0a1/32.png) [@rajul885](https://forum.ionicframework.com/u/rajul885)\
**Post date:** [January 16, 2015, 3:40pm UTC](https://forum.ionicframework.com/t/cordova-geolocation-always-getting-timeout/15841/1 "2015-01-16T15:40:00Z")

</div>

In browser this plugin is working but on real android device it is keep on getting timeout error.  
I am using redmi and android 4.3  
This is my code:

```
   $ionicPlatform.ready(function() {
    
    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
        console.log("navigator.geolocation works well");
        var posOptions = {
        enableHighAccuracy: true,
        timeout: 20000,
        maximumAge: 0
};
    $cordovaGeolocation
    .getCurrentPosition(posOptions)
    .then(function (position) {
      var lat = position.coords.latitude
      var long = position.coords.longitude
    }, function(err) {
      // error
    });

    }

```

I am using following option.  
var posOptions = {  
enableHighAccuracy: true,  
timeout: 20000,  
maximumAge: 0  
};

How to fix this problem.

---

<div class="post-metadata">

**Author:** ![jimibi](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/jimibi/32/7945_2.png) [@jimibi](https://forum.ionicframework.com/u/jimibi)\
**Post date:** [January 17, 2015, 11:51am UTC](https://forum.ionicframework.com/t/cordova-geolocation-always-getting-timeout/15841/2 "2015-01-17T11:51:48Z")

</div>

I think your Gps not synchronize 20s.  
The Browser uses the IP address to locate, if you want to be in the same condition changes enableHightAccuracy to false. Indoor GPS take more time to synchronize and often this is not possible.

---

<div class="post-metadata">

**Author:** ![rajul885](https://avatars.discourse-cdn.com/v4/letter/r/cab0a1/32.png) [@rajul885](https://forum.ionicframework.com/u/rajul885)\
**Post date:** [January 17, 2015, 12:50pm UTC](https://forum.ionicframework.com/t/cordova-geolocation-always-getting-timeout/15841/3 "2015-01-17T12:50:36Z")

</div>

Is there any other way to get current location . I want current location coordinates.

---

<div class="post-metadata">

**Author:** ![syrope](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/syrope/32/100275_2.png) [@syrope](https://forum.ionicframework.com/u/syrope)\
**Post date:** [November 30, 2015, 5:46pm UTC](https://forum.ionicframework.com/t/cordova-geolocation-always-getting-timeout/15841/4 "2015-11-30T17:46:48Z")

</div>

I get the same error. It is always error code = 3 . TIMEOUT. I use this setup:  
var posOptions = {timeout: 20000, enableHighAccuracy: false};

anyone knows the reason?

---

<div class="post-metadata">

**Author:** ![syrope](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/syrope/32/100275_2.png) [@syrope](https://forum.ionicframework.com/u/syrope)\
**Post date:** [September 29, 2016, 7:40pm UTC](https://forum.ionicframework.com/t/cordova-geolocation-always-getting-timeout/15841/5 "2016-09-29T19:40:47Z")

</div>

If the app starts with GPS on from the beginning. it works perfectly.  
In case the App starts with GPS off , and later you turn GPS on, the plugin gets always timeout . error code = 3. no solution for this issue until now.  
I share code example  
[https://scontent-mad1-1.xx.fbcdn.net/v/t1.0-9/13700084\_10209030231046316\_8844560510473254080\_n.jpg?oh=feba842834f96f29b33b6ad402fac9ae&oe=586D9D7F](https://scontent-mad1-1.xx.fbcdn.net/v/t1.0-9/13700084_10209030231046316_8844560510473254080_n.jpg?oh=feba842834f96f29b33b6ad402fac9ae&oe=586D9D7F)
