Mobile Web Wearable Web

Geolocation API Specification

Geolocation defines a location information interface. Common sources of location information are GPS, location inferred from the network (such as IP address), RFID, Wi-Fi, Bluetooth MAC address, and GSM/CDMA cell IDs. The Geolocation interface is implemented by the Navigator object instances. The location information is represented by the latitude and longitude coordinates.

The Geolocation interface allows you to retrieve position information with "one-shot" position requests (with the getCurrentPosition() method) or repeated position updates (with the watchPosition() method). Both methods take the following parameters:

  • Success event handler, which is a function invoked when an attempt to obtain the current location is successful.
  • Error event handler, which is a function invoked when an attempt to obtain the current location fails (optional).
  • Options object, which holds additional properties (optional):
    • enableHighAccuracy enables high accuracy of the location information.
    • timeout defines the maximum length of time that is allowed to pass from the call until the corresponding success event handler is invoked.
    • maximumAge indicates that the application can accept cached location information whose age is no greater than the specified time.
Note
In almost all cases, the location information reveals the location of the device user. To provide privacy for the user, a confirmation mechanism is provided for the geolocation features.
Go to top