javascript - Why does navigator.geolocation.getCurrentPosition() returns different coordinates even while standing at the same location? -
i have created app used calculate distance. works saving starting location , evaluates distance of current position position using logic working fine. problem navigator.geolocation.getcurrentposition() returns me varying coordinates while standing @ same point, coordinates range distance of 30 meters exact location. can suggest how can exact coordinates?
did try enablehighaccuracy
true
?
var options = { enablehighaccuracy: true, timeout: 5000, maximumage: 0 }; function success(pos) { var crd = pos.coords; console.log('your current position is:'); console.log(`latitude : ${crd.latitude}`); console.log(`longitude: ${crd.longitude}`); console.log(`more or less ${crd.accuracy} meters.`); }; function error(err) { console.warn(`error(${err.code}): ${err.message}`); }; navigator.geolocation.getcurrentposition(success, error, options);
source: https://developer.mozilla.org/en-us/docs/web/api/geolocation/getcurrentposition
Comments
Post a Comment