0

I'm having a little trouble understanding this function:

Location.distanceBetween(lat1, lon1, lat2, lon2, results);

I have two points at my map, my current position and one other. Which should be approximatly 30 meters away from where I am.

But still the results I get is:

results[0] = 6935649.5
results[1] = 121.08577
results[2] = 154.8537

Which doesn't make sence to me, the function tells me it should return in meters, so I expect something like 29.345345, my goal is to use this to check if my location is within say. 100 meters from another marker.

EDIT: Here are my the values I use

LatLng currentPosition; //My current position
//For all points
    LatLng position; //Set to the current point
    double lon1 = position.longitude;
    double lat1 = position.latitude;
    double lon2 = currentPosition.longitude;
    double lat2 = currentPosition.latitude;
j0k
  • 22,600
  • 28
  • 79
  • 90
Aleksander Fimreite
  • 1,439
  • 2
  • 18
  • 31
  • Hey check [this](http://stackoverflow.com/questions/8049612/calculating-distance-between-two-geographic-locations) out. Hope it helps – Rick Royd Aban Dec 15 '13 at 02:34
  • I saw my outputs was rather strange! The longitude and latitude for my location was swapped when i passed it somehow x) I'm getting closer answers now. But not very accurat yet though. – Aleksander Fimreite Dec 15 '13 at 03:26
  • The problem is not in Location.distanceBetween method, but in accuracy of your position – ramaral Dec 15 '13 at 15:12

0 Answers0