Reputation: 1588
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
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
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