Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

203
Visualizações
Ask geolocation permission

I'm trying to get user's geolocation in development environment. I believe I'm fulfilling every requirements, though I still don't see any prompt asking for my position.

Here's what I'm using:

  • navigator.geolocation

The Geolocation API is accessed via a call to navigator.geolocation; this will cause the user's browser to ask them for permission to access their location data.

  • ngrok to have a SSL tunnel

Secure context: This feature [Geolocation API] is available only in secure contexts (HTTPS), in some or all supporting browsers.

  • Firefox 99.0.1 (able to be located on other websites, no domain-specific rules)

PermissionState is always prompt, which mean a prompt is currently asking for the permission right ?

Am I missing something, or is there specific requirements when asking for localhost geolocation ?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Somehow I'd to call navigator.geolocation.getCurrentPosition(callback) in order to have a prompt displayed.

If it can help anyone, here's my test code:

// inside a Stimulus controller

connect() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(this.showPosition)
  } else {
    // I believe it may also mean geolocation isn't supported
    alert('Geolocation denied') 
  }
}

showPosition(position) {
  alert(`${position.coords.longitude} - ${position.coords.latitude}`)
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda