Stack User 5674
Stack User 5674

Reputation: 1588

Gps accuracy in phonegap

In android native we can identify the accuracy of gps location obtained using

locationProvider.getAccuracy()

Ref: LocationProvider

Are there similar methods in phonegap to identify the accuracy of GPS location obtained by the geolocation.watchPosition and geolocation.getCurrentPosition Methodes.

Upvotes: 1

Views: 568

Answers (2)

Gjordis
Gjordis

Reputation: 2550

The returned position object holds the accurracy:

var onSuccess = function(position) {
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: '         + new Date(position.timestamp)      + '\n');

};

Upvotes: 3

Arjun T Raj
Arjun T Raj

Reputation: 3207

You can use watchPosition instead of getCurrentPosition. Then you your onSuccess function will be triggered everytime there is a change in the location(when it is more accurate). In this function you can check the accuracy and then stop the gps ensor with clearWatch

courtesy (Wilin )

Upvotes: 1

Related Questions