Geolocation
suggest changeSyntax
- navigator.geolocation.getCurrentPosition(successFunc, failureFunc)
- navigator.geolocation.watchPosition(updateFunc, failureFunc)
- navigator.geolocation.clearWatch(watchId)
Remarks
The Geolocation API reports latitude and longitude. The page must be a secure context (https:// or localhost), and the user can refuse the request.
This API is defined in the W3C Geolocation API Specification. Features for obtaining civic addresses and to enable geofencing / triggering of events have been explored, but are not widely implemented.
To check if the browser supports the Geolocation API:
if(navigator.geolocation){
// Supported. The user can still deny the request.
} else {
// No support...
}
Get a user's latitude and longitude
Get updates when a user's location changes
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents