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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:42:28+00:00 2026-06-13T16:42:28+00:00

Possible Duplicate: How to track distance via GPS on Android? I have designed a

  • 0

Possible Duplicate:
How to track distance via GPS on Android?

I have designed a GPS application and its telling my location well. But Now I want to include more feature. How I will make a radius there? to have a surrounding area of 5 or 6 km! How I can mention the distance between a place on that area and my place?

  • 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-06-13T16:42:30+00:00Added an answer on June 13, 2026 at 4:42 pm

    I feel like this question is starting to turn into a lot of questions. I decided to tackle this answer by directing it towards your question title “Distance for GPS Application”.

    In my application, instead of using Google’s API’s I request the users distance from a list of GPS coordinates by doing the following:

    In my JJMath Class:

    Getting distance (Haversine Formula, in miles):

    /**
     * @param lat1
     * Latitude which was given by the device's internal GPS or Network location provider of the users location
     * @param lng1
     * Longitude which was given by the device's internal GPS or Network location provider of the users location 
     * @param lat2
     * Latitude of the object in which the user wants to know the distance they are from
     * @param lng2
     * Longitude of the object in which the user wants to know the distance they are from
     * @return
     * Distance from which the user is located from the specified target
    */
    public static double distFrom(double lat1, double lng1, double lat2, double lng2) {
        double earthRadius = 3958.75;
        double dLat = Math.toRadians(lat2-lat1);
        double dLng = Math.toRadians(lng2-lng1);
        double sindLat = Math.sin(dLat / 2);
        double sindLng = Math.sin(dLng / 2);
        double a = Math.pow(sindLat, 2) + Math.pow(sindLng, 2) * Math.cos(lat1) * Math.cos(lat2);
        double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
        double dist = earthRadius * c;
    
        return dist;
    }
    

    Then I round that number by:

    /** This gives me numeric value to the tenth (i.e. 6.1) */
    public static double round(double unrounded) {
        BigDecimal bd = new BigDecimal(unrounded);
        BigDecimal rounded = bd.setScale(1, BigDecimal.ROUND_CEILING);
        return rounded.doubleValue();
    }
    

    I don’t work with Map overlays, but I am sure there are great tutorials or answers to come.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: array_count_values for javascript instead Let's say I have simple JavaScript array like
Possible Duplicate: Datetime vs Timestamp? I have a Mysql table, which has a column
Possible Duplicate: setting up a database for tracking which users have clicked which links?
Possible Duplicate: jquery reading nested json I would really like to have a hard
Possible Duplicate: Is there some ninja trick to make a variable constant after its
Possible Duplicate: Timezone from geolocation I have a website where people can check in
Possible Duplicate: Linq help - Sql trace returns result, but datacontext returning null Question
Possible Duplicate: slow android emulator My tablet is not here yet, which is why
Possible Duplicate: Track started applications in Windows I' like to create a program or
Possible Duplicate: How to track mouse X/Y position and print it to a label?

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.