Google Maps API Tutorial© 2006, 2007, 2009 Mike Williams
|Translate this page:|
DistancesThe API provides a function that calculates the straight line distance between two points.
To use it to calculate the distance in metres between two GLatLng objects, we write P1.distanceFrom(P2).
Here's an example of the code in use.
For the bearing, I've used an algorithm by Vincenty which is claimed to produce better results than using atan2() when the distances are large.