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

98
Visualizações
Force geolocation update from mobile browser

I created a small POC of showing a marker at the actual geolocation in Google Maps Javascript API. It works in general, but I realise that the interval of geolocation updates is very high. I mean, it takes a lot of trys until a new geolocation updated.

Then I realised that I don't have this problem in Google Maps Android App. Here, the geolocation is updated nearly simultaniously. And: After it is updated in Google Maps App, also the Javascript API in the browser receives a new value. You can see it here in a video of my Phone: https://gfycat.com/calmspiffyamericanbittern

So, it seams to me that the Android App has a possibility to force geolocation updates in really short intervals, while the Javascript API from the Browser doesn't.

  1. Is that correct?
  2. Is there a way to change that behaviour (force update from browser)?
  3. If not, might creating a native App with WebView be a solution?

You can try the POC yourself on https://michaelfirges.de/maps/

This is the code:

(() => {
    const message = document.querySelector('#message');

    // check if the Geolocation API is supported
    if (!navigator.geolocation) {
        message.textContent = `Your browser doesn't support Geolocation`;
        message.classList.add('error');
        return;
    }

    // handle click event
    const btn = document.querySelector('#show');
    btn.addEventListener('click', function () {
        // get the current position
        
        navigator.geolocation.getCurrentPosition(onSuccess, onError, {  
            maximumAge: 0, timeout: 5000, enableHighAccuracy:true} );
    });


    // handle success case
    function onSuccess(position) {
        const {
            latitude,
            longitude
        } = position.coords;
        
        var markerpos = new google.maps.LatLng(latitude, longitude);

        const marker = new google.maps.Marker({
            position: markerpos,
            map: map,
            draggable: true,
        });

        message.classList.add('success');
        message.textContent = `Your location: (${latitude},${longitude})`;
    }

    // handle error case
    function onError() {
        message.classList.add('error');
        alert('Failed to get your location!');
    }
})();

Big thanks for any input!

about 4 years ago · Juan Pablo Isaza
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