I utilized the NativeScript Geolocator plugin with an Accuracy.high option (see code extract below) to obtain the longitude & latitude of my location on an Android device (version 7.0). The horizontal/vertical accuracy of the location returned was a range of 500 - 1,500:
// Import Section
import { Component, ElementRef, OnInit, ViewChild } from "@angular/core";
import { View } from "ui/core/view";
import * as geolocation from "nativescript-geolocation";
import * as camera from "nativescript-camera";
import { Image } from "ui/image";
import { Accuracy } from "ui/enums";
// Function to get the current location
buttonGetLocationTap() {
geolocation.isEnabled().then(function (isEnabled) {
if (!isEnabled) {
geolocation.enableLocationRequest().then(function () {}, function (e) {
console.log("Error: " + (e.message || e));
});
}
}, function (e) {
console.log("Error: " + (e.message || e));
});
if(geolocation.isEnabled()) {
var location = geolocation.getCurrentLocation({desiredAccuracy: Accuracy.high, updateTime: 5000, timeout: 20000}).
then(function(loc) {
if (loc) {
console.log("Current location is: Longitude => " + loc.longitude + "; Latitude => " + loc.latitude +
"; Hor.Accuracy: "+loc.horizontalAccuracy+"; Ver.Accuracy: "+loc.verticalAccuracy);
}
}, function(e){
console.log("Error: " + e.message);
});
}
}
When I put the location obtained on Google Map (using the required Latitude,Longitude pair), the location is very far from my actual location (corresponding to the horizontal/vertical accuracy).
However, when I use the Google Map mobile app on the same device to obtain my current location it is very accurate (as displayed by the blue marker/indicator).
I would have thought that the accuracy of the location provided by the NativeScript Geolocator plugin (using the Accuracy.high option) should be about the same as that of Google Map mobile app on the same device since they use the same Google Play Services.
Could someone help with this.