0

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});

1 Answer 1

1

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().

1
  • Glad to have helped although I only confirmed what you already knew!
    – Ian Devlin
    Oct 24, 2012 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.