Navigator geolocation Property

Get the latitude and longitude of the user's position

Definition and Usage

The geolocation property returns a Geolocation object that can be used to locate the user's position.

The geolocation property is read-only.

The geolocation property is only available in secure contexts (HTTPS).

The geolocation property is only available if the user approves it.

Note

Geolocation is much more accurate for devices with GPS, like smartphones.

See Also:

HTML5 Gelocation Tutorial.

Syntax

navigator.geolocation

Return Value

Type Description
An objectA reference to a Geolocation object.

Browser Support

navigator.geolocation is supported in all browsers:
Chrome IE Edge Firefox Safari Opera
Yes Yes Yes Yes Yes Yes