In the distanceTo()
method what is the parameter used?I do know that its the location parameter that is used, but my question is that if I am making an app which has to calculate the distance from a particular location say a particular landmark, then what do I enter in the parameter set of the distanceTo()
function, I do know the latitude and longitude of the place, but the distanceTo()
function only accepts one parameter.
Asked
Active
Viewed 284 times
0

Kazekage Gaara
- 14,972
- 14
- 61
- 108

Salman Ahmad Khan
- 33
- 2
- 6
2 Answers
1
You need to use the distanceBetween()
method if you know the latitude and longitude of the place. Take a look at the docs.

Kazekage Gaara
- 14,972
- 14
- 61
- 108
-
That was helpful, thanks. But is there a way to use the distanceTo() method for achieving the same result? – Salman Ahmad Khan Jun 11 '12 at 15:27
-
I'm not pretty sure. You can try `location1.distanceTo(location2)` ? But I think `distanceBetween()` is a better way. Why are you so insistent about using `distanceTo()` method? – Kazekage Gaara Jun 11 '12 at 16:22
0
Method Name: distanceTo
public float distanceTo (Location dest)
Since: API Level 1
Description
Returns the approximate distance in meters between this location and the given location. Distance is defined using the WGS84 ellipsoid.
Parameters
dest ,the destination location
Returns
the approximate distance in meters
source Google android docs

swiftBoy
- 35,607
- 26
- 136
- 135
-
I know all that. All I want to know is, say I want to measure the distance of a device from a particular place, say with latitude X and longitude Y, so what do I have to put in place of dest? – Salman Ahmad Khan Jun 09 '12 at 13:41
-
check [this](http://stackoverflow.com/questions/5936912/how-to-find-the-distance-between-two-geopoints) in the 3rd ans he mentioned code how to use distanceTo() method – swiftBoy Jun 09 '12 at 14:35