Home Android Finding distance between two points – Android GPS

Finding distance between two points – Android GPS

Currently I am working on GPS related project. and every day I am exploring new things. Now I realize that GPS is very interesting technology and we can make lot of useful things by using GPS.

The new thing today I learned is, finding distance between two points. Previously I was thinking that, it may be difficult but, thankfully there is a much simpler way to figure out distances between two points on a map: the distanceTo() method in the Location class. Using this handy little method, we can quickly find out the distance between two locations:

double distance;

Location locationA = new Location("point A");


Location locationB = new Location("point B");


distance = locationA.distanceTo(locationB);

One thing to note is that the distanceTo() method returns the distance in meters, so you will need to do the appropriate calculations if you want your distances in other units.

 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
3 Comments  comments 

3 Responses

  1. Do you know if distanceTo takes into account the different altitude between both points?

  2. on this example, the location have only latitude and longitude, so I don’t think so.

  3. jacko

    i f possiable explain all the parameters u have passed.and where u get all these parameter value.this is half done work….

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>