## How Calculate Distance Between Points in Driving Direction

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

### How Calculate Distance Between Points in Driving Direction

I've read about how to make a Geopoint or more and find a distance between 2 points..

One thing that still makes me confuse is about calculating a distance between 2 points. I've tried and find the result but it's applied if the condition is when I want to make a straight line between those points. But, when I crosscheck with maps.google.com, the result (distance) is different with the same latitude and longitude of those points. And I realize that its a kind of a Driving Direction..

The ilustration of the Google Map

If you see the picture, it's not a straight line so of course the distance is different. So how can I calculate this distance in Android in this case?
And please show me the code to make it...
Rommy
Junior Developer

Posts: 17
Joined: Tue Oct 19, 2010 10:21 am

### Re: How Calculate Distance Between Points in Driving Directi

Same problems, waiting for the solution~
CoolEagel
Freshman

Posts: 2
Joined: Tue Jun 28, 2011 4:32 pm

### Re: How Calculate Distance Between Points in Driving Directi

Ok, I got the solution..
It looks like I have to send the longitude and latitude to Google Map via API Direction...

After that, I have to parse it since the output is XML and JSON.
You can use XML Parser or JSON Parser.
That's all I got and it works...
Rommy
Junior Developer

Posts: 17
Joined: Tue Oct 19, 2010 10:21 am

### Re: How Calculate Distance Between Points in Driving Directi

I think you can get Latitude & Longitude through GPS for current location using methods in Andriod.

Then after get Latitude & Longitude of the place entered by user. Then calculate difference between them and you can get distance. JSON is more preferable then XML & ATOM, as it responds faster.

Thanks...
Thames Jones
Freshman

Posts: 4
Joined: Fri Jun 17, 2011 11:57 am

### Re: How Calculate Distance Between Points in Driving Directi

Hi all,
I m also trying to display distance between two points I got the lattitude and longtitude of the entered location using forward geo coding and i am able to point out in map too!!!! but how to find distance I tried haversine's formula but i didn't work ##### is there any API available???
venkatraman7
Developer

Posts: 41
Joined: Tue Nov 16, 2010 6:47 am
Location: Puducherry

### Re: How Calculate Distance Between Points in Driving Directi

venkatraman7 wrote:Hi all,
I m also trying to display distance between two points I got the lattitude and longtitude of the entered location using forward geo coding and i am able to point out in map too!!!! but how to find distance I tried haversine's formula but i didn't work ##### is there any API available???

actually you can use haversine formula...
or you can use distanceTo(), it's similar with haversine formula..

but if you want to calculate the distance in real way, you have to use API Direction, not from point to point..
Rommy
Junior Developer

Posts: 17
Joined: Tue Oct 19, 2010 10:21 am