-
Messing around with
geolocation
andpermissions
web API for supa meet. -
Both the APIs can work hand in hand. You might want to check the state of permissions API for geolocation up front so you have control of the UX of when the GPS browser prompt happens.
navigator.permissions.query({ name: 'geolocation' }).then((result) => {
if (result.state === 'granted') {
enableGeolocation();
//
} if (result.state === 'prompt') {
showButtonToEnablesGeolocation();
} if (result.state === 'denied'){
// fallback behaviour
}
// Don't do anything if the permission was denied.
});
-
https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query
-
Once permissions are granted we can confidently use the geolocation API which may prompt the user with a browser notification without it being too intrusive.
-
Geolocation accepts three arguments. A success callback, an error callback and an options object.
getCurrentPosition(success, error, options)