Geolocation API Methods

The geolocation API exists inside the navigator object and contains only three methods to determine the user’s current position and also get notified of changes to their position.

  1. getCurrentPosition
  2. watchPosition
  3. clearWatch

getCurrentPositiona one-shot method for grabbing the user’s current location.
watchPositionReturns the user’s current location but continues to monitor their position and keeps polling at regular intervals to see if their location has changed and invoke the appropriate callback every time the position changes.
clearWatchThis method ends the watchPosition method's monitoring of the current

The watchPosition and clearWatch are paired methods. watchPosition returns a unique identifier that is passed in to clearWatch to clear that particular watch.
Related Tutorial
Follow Us #