Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

309
Views
How to ask permission for geolocation every time?

I would like to be asked every time for the permission to access to geolocation. How to do that? I thought to revoke the permission everytime and then ask it for again, but that doesn't work. According to documentation it has been deprecated.

navigator.permissions.query({name:'geolocation'}).then(function(result) {
  if (result.state === 'granted') {
   //to do things here 
  
  } else if (result.state === 'prompt') {
   //ask for permission
  
  } else if(result.state === 'denied'){
   //keep asking for permission
  
  }
  report(result.state);
});

/////

  if ('geolocation' in navigator) {
      console.log('there is geolocation')
      navigator.geolocation.getCurrentPosition((success) => {
        console.log('success geo', success.coords)
        
      }, (error) => {
        console.log(error, 'error')
      }, { maximumAge: 0});

    } else{
      alert('Please grant access to location')
    }
  }

From what I have been reading, it seems that once the user has given access to location, the browser remembers. That's why I added also maximumAge; I thought that adding that, I could have a mechanism to allow to ask for the geolocation permission every time the user loads a page.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!