getCurrentPosition(options)

Gets the device’s current geolocation.

A Promise object that resolves as a Location object with the device location details.

A rejected promise returns a LocationServiceFailure object containing details about the error.

This function performs a one-time location request, and returns the device’s current location at that time.

When this function is called, a request to get the current location is submitted to the device’s location capabilities. When the device’s current location is determined, the promise resolves with a Location object. Determining the current location can take varying lengths of time, from nearly instant to many seconds, depending on a number of external factors.

There’s no user interface associated with a location request. To provide feedback while waiting for a response, update your Lightning web component code. We suggest that you display a lightning-spinner just before calling getCurrentPosition(). Then remove the spinner in the finally() clause of the getCurrentPosition() promise handler.

See Also