Join Bill Weinman for an in-depth discussion in this video Continuous tracking with watchPosition(), part of HTML5: Geolocation.
Sometimes, especially in a mobile application, you may want to continuously…update your location instead of just reading it once.…This is accomplished by using watchPosition in place of the getCurrentPosition…that we have been using to get the coordinates.…Here we have 04-continuous-working.html.…This is a working copy of 04-continuous-start.html, and I suggest you work…with the working copy.…It's pretty much where we left off in the last movie on error testing.…
So here we have our geo_error function right there, and you can see in the init…function it's getting called back along with show_coords and the…getCurrentPosition call, and there is HTML down at the bottom.…So in order to make this continuously update the position, all we need to do is…change this getCurrentPosition call to use watchPosition instead.…When I save this, all this will do is instead of calling this show_coords…function once, it will call it once, and then it will wait and see until the…coordinates change and when the coordinates change it will call it again.…
- Understanding how geolocation works
- Detecting geolocation support
- Getting coordinates
- Continuous tracking with watchPosition()
- Integrating geolocation with Google Maps