Reputation: 1944
I need some help in tracking the user continuously. According to the research I did, the watchPosition function will return the new position if there is a change in user's location. Is that correct? And also where should this snippet be placed, right after the getCurrentPosition function? If not so, do you have any solutions or suggestions how I can achieve continuous tracking.
navigator.geolocation.watchPosition(
function(position) {
calculateDistance(position.coords.latitude, position.coords.longitude);
}, function(err){
console.log(err);
}, {enableHighAccuracy:true, maximumAge:30000, timeout:27000});
Upvotes: 0
Views: 52
Reputation: 18870
Yes you are correct and you don't need to call getCurrentPosition()
at all as watchPosition()
does the same thing, only continously.
So call it instead of where you are currently calling getCurrentPosition()
.
Upvotes: 1