getCurrentGeolocation( )


Returns the current geolocation of the user.

The getCurrentGeolocation() function returns a Promise that resolves to an object containing the current geolocation of the user.

The getCurrentGeolocation() function has the following limitations:

  • On Chrome, the function only works on HTTPS sites.
  • On Chrome, Firefox, and Safari, the function only works if the user approves a popup. If they do not approve, the promise is rejected.
  • Run getCurrentGeolocation() with a setTimeout() in case the browser is set to not detect the locale. Adding the timeout lets you handle the unfulfilled promise.
Method Declaration
Copy
Request
This method does not take any parameters
Returns
Return Type:Promise<CurrentGeolocation>
Was this helpful?
Yes
No