GeolocationPosition

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The GeolocationPosition interface represents the position of the concerned device at a given time. The position, represented by a GeolocationCoordinates object, comprehends the 2D position of the device, on a spheroid representing the Earth, but also its altitude and its speed.

Instance properties

The GeolocationPosition interface doesn't inherit any properties.

GeolocationPosition.coords Read only

Returns a GeolocationCoordinates object defining the current location.

GeolocationPosition.timestamp Read only

Returns a timestamp, given as Unix time in milliseconds, representing the time at which the location was retrieved.

Instance methods

The GeolocationPosition interface doesn't inherit any methods.

GeolocationPosition.toJSON()

Returns a JSON representation of the GeolocationPosition object and enables serialization with JSON.stringify().

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android
GeolocationPosition 795–78 7912–79 723.5–71 16 13.15–13.1 7918–78 794–79 16 13.4≤3–13.4 12.01.0–12.0 79≤37–78
coords 5 12 3.5 16 5 18 4 16 ≤3 1.0 ≤37
secure_context_required 47 ≤18 55 34 10 47 55 34 10 5.0 47
timestamp 5 12 3.5 16 5 18 4 16 ≤3 1.0 ≤37
toJSON 126 126 129 112 18 126 129 83 18 No 126

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/GeolocationPosition