The PhoneGap Geolocation API
The Geolocation API is not a part of the HTML5 specification, but it is tightly integrated with mobile development. The PhoneGap Geolocation API and the W3C Geolocation API mirror each other; both define the same methods and relative arguments. There are several devices that already implement the W3C Geolocation API; for those devices, you can use native support instead of the PhoneGap API.
Note
As per the HTML specification, the user has to explicitly allow the website or the app to use the device's current position.
The Geolocation API is exposed through the geolocation
object child of the navigator
object and consists of the following three methods:
getCurrentPosition()
: This returns the device positionwatchPosition()
: This watches for changes in the device positionclearWatch()
: This stops the watcher for the device's position changes
The watchPosition()
and clearWatch()
methods work in the same way that the setInterval()
and clearInterval()
methods work; in...