-2

My app is running fine but only the fluctuation in the GPS current location will jump from one point to new point.I think this is a GPS issue but i want to know how can i improve this in android.

Shubham
  • 158
  • 1
  • 1
  • 7
  • Have a look at [this](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/Using_geolocation) documentation. Why do you think that fluctuation of the position is not allowed? – Jeroen Heier Aug 12 '16 at 05:42
  • I know that their will be some fluctuation but i want to know can i reduce that using code. Or i had to switch for a mobile whose GPS works more accurate. – Shubham Aug 13 '16 at 04:06

1 Answers1

0

You can determine the accuracy as follows:

function geo_success(position) {
  var lat = position.coords.latitude;
  var long = position.coords.longitude;
  var alt = position.coords.altitude;
  var acc = position.coords.accuracy;
  var accAlt = position.coords.altitudeAccuracy;
  var time = position.timestamp;
}

function geo_error(error) {
  var code = error.code;
  var message = error.message;
}

var geo_options = {
  enableHighAccuracy: true, 
  maximumAge        : 0, 
  timeout           : 0
};

var wpId = navigator.geolocation.watchPosition(geo_success, geo_error, geo_options);
  • accuracy/altitudeAccuracy: The accuracy in metres of the returned result. Based on this value you can determine if the returned result is accurate enough for the purpose it is intended for.
  • Only the coords.latitude, coords.longitude and coords.accuracy position attributes are guaranteed to be returned; all others may be null.
  • enableHighAccuracy: provides a hint that the application would like the best possible results. This may cause a slower response time and in the case of a mobile device, greater power consumption as it may use GPS. With a default setting of false.
  • maximumAge: denotes the maximum age of a cached position that the application will be willing to accept. This is in milliseconds, with a default value of 0, which means that an attempt must be made to obtain a new position object immediately.
  • timeout: indicates the maximum length of time to wait for a response. In milliseconds with a default of 0 – infinite.
Jeroen Heier
  • 3,520
  • 15
  • 31
  • 32