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

Postby Rommy » Tue Jun 14, 2011 6:30 am

everyone... I have something to ask about using a MapView in Android with Google Maps API..

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
http://maps.google.com/maps?f=d&source=s_d&saddr=-7.963292,%20112.608129&daddr=-7.96583,%20112.607633&hl=en&geocode=FWR9hv8dgUO2Bg;FXpzhv8dkUG2Bg&mra=ls&sll=-7.963899,112.608469&sspn=0.002614,0.005284&ie=UTF8&ll=-7.964308,112.608774&spn=0.002614,0.005284&z=18

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
Junior Developer
 
Posts: 17
Joined: Tue Oct 19, 2010 10:21 am

Top

Re: How Calculate Distance Between Points in Driving Directi

Postby CoolEagel » Tue Jun 28, 2011 5:42 pm

Same problems, waiting for the solution~
CoolEagel
Freshman
Freshman
 
Posts: 2
Joined: Tue Jun 28, 2011 4:32 pm

Re: How Calculate Distance Between Points in Driving Directi

Postby Rommy » Thu Jun 30, 2011 7:41 am

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... :lol:
Rommy
Junior Developer
Junior Developer
 
Posts: 17
Joined: Tue Oct 19, 2010 10:21 am

Re: How Calculate Distance Between Points in Driving Directi

Postby Thames Jones » Thu Jun 30, 2011 11:16 am

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
Freshman
 
Posts: 4
Joined: Fri Jun 17, 2011 11:57 am

Re: How Calculate Distance Between Points in Driving Directi

Postby venkatraman7 » Fri Jul 08, 2011 7:24 am

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
Developer
 
Posts: 41
Joined: Tue Nov 16, 2010 6:47 am
Location: Puducherry

Re: How Calculate Distance Between Points in Driving Directi

Postby Rommy » Sat Jul 09, 2011 7:16 am

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
Junior Developer
 
Posts: 17
Joined: Tue Oct 19, 2010 10:21 am

Top

Return to Map Problems

Who is online

Users browsing this forum: Google Feedfetcher and 1 guest