11

It seems phonegap does not use GPS satellite instead geolocation from cellular network. I am not satisfied with the accuracy, always between 150-1000 meters. GPS activity logo is not displayed as well.

Is there any way to force an android app to use GPS satellites even if other methods are available? Is there any way to override the default function to activate the GPS sat usage?

Thanks in advance

slmglr
  • 188
  • 1
  • 2
  • 9
  • 1
    This has been asnwered here http://stackoverflow.com/questions/7518468/phonegap-gps-without-internet – Andy Nov 25 '11 at 09:44
  • 2
    Have you found a solution ? Its the same for me with Cordova 3.0.0, The gps icon doesn't show even with enableHighAccuracy : true . – arlg Oct 22 '13 at 14:32

1 Answers1

12

PhoneGap actually uses GPS satellite geolocation just as Android platform does. You should be receiving locations with a more precise accuracy than 150m if your phone's GPS is enabled. Whenever you call the geolocation.getCurrentPosition() or geolocation.watchPosition() methods, PhoneGap's GeoListener class asks for a GPS provider and a NETWORK provider, then it creates a listener for both providers, if they exist. This is the reason you are getting a wide range of accuracies.

So in case you want to force high accuracy locations, you could set it to true on the geolocationOptions parameter passed to the above methods. Check the API: geolocationOptions

navigator.geolocation.watchPosition(
    onSuccess, onError, 
    { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true });

In case you want to have more control and a more accurate behaviour of location requests you can extend PhoneGap's API to do so.

Oliver
  • 9,239
  • 9
  • 69
  • 100
sgimeno
  • 1,883
  • 1
  • 22
  • 35
  • 6
    Its the same for me with Cordova 3.0.0, The gps icon doesn't show even with enableHighAccuracy : true, and the app doesn't get the good position. – arlg Oct 22 '13 at 14:33
  • 1
    Same problem, the GPS provider seems to get ignored, only the network provider is uses. If I set network provider off (GPS on) no positioing is performed. PLUS, when I set the Network provider back on, it seems like the app ignores it, it is not detected any more and I have to close the app and restart it. – smarques Jan 07 '14 at 14:06
  • I have the same problem with the geolocation API and an android device. Setting enableHighAccuracy to true still seems to prefer cell or network based location. If I turn AIRPLANE MODE on, GPS seems to be used, and a truly exact location is returned. I can hardly expect my users to turn airplane mode on though to use this app, so I'm still looking for a solution. – Fingel Jul 25 '14 at 15:57
  • If you want to have more control on which provider is using Android you can write your own plugin extending that functionality. Anyways is a common error to think GPS is always giving a more accurate position than CELL or NETWORK providers. Imagine your user is inside a building, NETWORK provider is likely giving a more precise position than GPS. – sgimeno Jul 28 '14 at 13:14