Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6782963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:48:25+00:00 2026-05-26T16:48:25+00:00

Looking at the web GeoLocation API documentation there are two ways to get location

  • 0

Looking at the web GeoLocation API documentation there are two ways to get location – getCurrentPosition to get a quick reading of location and watchPosition to monitor the changes to the position.

What I’m looking for is a way to get a location reading which is quite accurate, as quickly as possible. I think the ideal would be to use an accuracy threshold on the getCurrentPosition call – and the success handler would be called when the threshold is reached or the timeout exceeded (with as accurate as possible a result).

This doesn’t already exist, right? Presumably it would be fairly straightforward to implement this by just wrapping the watchPosition method to stop checking after a timeout or the threshold is reached. I will use this approach (and intend to post the code) if no-one is aware of a built in method to do this…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:48:26+00:00Added an answer on May 26, 2026 at 4:48 pm

    No built in function. I’ve found that a timeout is better than a set accuracy. Often times on an iPhone the accuracy will be no better than around 100 meters, so continuing to check for better is wasteful. Using watchPosition() has worked best and it seems to triangulate, so after three readings it rarely gets better. I just wait five seconds and stop.

    Demo: http://jsfiddle.net/ThinkingStiff/3k859/

    HTML:

    <div id="result"></div>
    

    Script:

    function setGeolocation() {
    
        var geolocation = window.navigator.geolocation.watchPosition( function ( position ) {
    
                document.getElementById( 'result' ).innerHTML += 
                      'lat: ' + position.coords.latitude + ', '
                    + 'lng: ' + position.coords.longitude + ', '
                    + 'accuracy: ' + position.coords.accuracy + '<br />';
    
            },
            function () {
                //error
            },
            {
                maximumAge: 250, 
                enableHighAccuracy: true
            } 
    
        );
    
        window.setTimeout( function () {
    
            window.navigator.geolocation.clearWatch( geolocation ) 
    
        }, 5000 );
    
    };
    
    setGeolocation();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking at a web application with a Response.Redirect between two Https pages. I
I'm looking to embed web content in my Windows application. Is there a class
I´ve recently started looking a web service calls using PHP. I can´t get the
I'm a web developer looking to get my feet wet with coding up a
Possible Duplicate: HTML 5 Geo Location Prompt in Chrome I've been looking at geolocation
As a web developer looking to move from hand-coded PHP sites to framework-based sites,
I'm looking for a web player with the following features : - Play h264
I'm looking for a web application to manage tasks (not necessary programming-oriented) for a
I've been looking into different web statistics programs for my site, and one promising
I was recently looking at some web hosting solutions and some of the providers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.