The Cordova Geolocation API allows an application to leverage the GPS capabilities of a mobile device and determine the device’s location on the surface of the Earth. Using this API, an application can either manually check the device’s current position or it can create a location watch that will cause the application to be periodically notified of the device’s physical location.

The Geolocation API is implemented in the same manner as the Accelerometer (Chapter 2) and Compass (Chapter 5) APIs. All three APIs expose a way to query the particular metric individually or by defining a watch and measuring the metric repeatedly over time. The differences between the implementations for the different APIs is in what options are available to control the measurement and what data is returned to the Cordova application through the appropriate success callback function.

An application would use this API to capture the device’s location and use the associated data with other data elements in the application (such as recording where the device was when a particular piece of data was entered into the application) or passed to a server for geo-fencing (http://en.wikipedia.org/wiki/Geo-fencehttp://en.wikipedia.org/wiki/Geo-fence) purposes.