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

97
Views
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
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!