getCurrentPosition
getCurrentPosition is a method of the Geolocation interface in the Web Geolocation API. It retrieves the device’s current geographic position and delivers it to a success callback if the position can be determined. The call is asynchronous and may fail for various reasons, in which case an error callback is invoked.
- successCallback: a function that is called with a Position object when the location is obtained. The
- errorCallback (optional): a function that is called with a PositionError object if the location cannot be
- options (optional): an object with properties to influence the request. Common options are enableHighAccuracy (boolean), timeout
- The method does not return a value; it relies on callbacks to provide results.
- Location data may be sourced from GPS, Wi‑Fi, or other sensors, depending on device capability and
- Permission is typically required; the user may be prompted to grant access to location data.
- The request may time out or be denied, depending on device, browser, and user decision.
- Secure origins (HTTPS) are usually required for geolocation to function.