Geolocation

suggest change

Syntax

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

More descriptive error codes

Get updates when a user's location changes

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents