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 7675883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:04:15+00:00 2026-05-31T17:04:15+00:00

I am currently producing a mobile web application which enables the user to walk

  • 0

I am currently producing a mobile web application which enables the user to walk with the application, and it will measure the distance covered (straight-line only). Obviously, using Haversine is fine and the computations work as expected. However, I have noticed a slight bug when testing on iOS 5 (iPhone 3GS, untested on 4 and 4G).

Here’s the JavaScript that I am using to watch their position:

var points = [ ]; // This will be an array holding all of the points we have recorded.

// Start watching the position:
navigator.geolocation.watchPosition(function(location) {
    var this_coords = { lat: location.coords.latitude, lng : location.coords.longitude };
    points.push(this_coords);
}, function() {  }, true);

// When we're done, I output them to the console:
var start = points[0],
end = points[points.length - 1];
console.log('Start: ' + start.lat + ', ' + start.lng);
console.log('End: ' + end.lat + ', ' + end.lng);

Essentially, all of the points are recorded into an array, and then the first and last lat / long pairs are used for the Haversine. However, the initial value entered into the array always seems to be incorrect (by a significant distance). The final value is always correct (within ~ 5m).

Does anyone know why the first reading may be so inaccurate, or how I can circumvent this? I thought about perhaps just ignoring the first, and taking the second reading, but this obviously isn’t very scientific.

  • 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-31T17:04:16+00:00Added an answer on May 31, 2026 at 5:04 pm

    The first location is the fastest to respond then it trys to narrow it down further. As it trys to connect via phone connection, wifi and gps they all come at different times.

    You could use position.coords.accuracy to narrow it down first before executing.

    e.g.

     if (position.coords.accuracy < 100){
               // if accuracy is less than 100m do something
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I'm prototyping search with Lucene.Net-2.0-004 on a web application. It's working very well,
I will try to get straight to the point. I am currently working with
I am currently working on producing the data model for my application and it
In the web application I am currently developing, I have quite a few database
Currently developing an application using the newest version of symfony, obtained through PEAR. This
Currently we're parsing arp request output from the command line. string cmd = arp
I'm currently dumping MySQL tables with mysqldump . The dump is currently producing: DROP
I have a simple piece of a program thats currently producing some memory leaks
I am currently running a command and it is producing the compressed file. I
I'm producing a hex file to run on an ARM processor which I want

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.