Android has a distanceTo method that does this for you, it's in the
Location class (see
http://developer.android.com/reference/android/location/Location.html#distanceTo%28android.location.Location%29)
So, for instance:
Location amsCentral = new Location("Amsterdam CS");
amsCentral.setLatitude(52.3791);
amsCentral.setLongitude(4.9002);
Location histMuseum = new Location("Historical Museum");
histMuseum.setLatitude(52.370247);
histMuseum.setLongitude(4.889731);
float distanceInMeters = histMuseum.distanceTo(amsCentral);
(P.S. The distance between the above two locations is 1216.0496
meters ;-)
On Sep 17, 7:42 am, "Maps.Huge.Info (Maps API Guru)"
<[email protected]> wrote:
> The "Haversine" formula computes distance between two points along a
> spheroid (such as Earth). You will need to know the coordinates of
> each city to use this formula. Coordinates for nearly all cities in
> the world can be downloaded from the geonames.org website for free.
> The Google geocoder will also return those coordinates but you'll have
> to obey the terms in order for you to use that service. For the exact
> formula, try searching Google.
>
> -John Coryat
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en