Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 位置。不返回仪表的点之间的距离?_Android_Google Maps_Location_Distance - Fatal编程技术网

Android 位置。不返回仪表的点之间的距离?

Android 位置。不返回仪表的点之间的距离?,android,google-maps,location,distance,Android,Google Maps,Location,Distance,我在理解这个函数时有点困难: Location.distanceBetween(lat1, lon1, lat2, lon2, results); 我的地图上有两个点,我的当前位置和另一个。离我现在的位置大概有30米远 但我得到的结果仍然是: results[0] = 6935649.5 results[1] = 121.08577 results[2] = 154.8537 这对我来说没有意义,函数告诉我它应该以米为单位返回,所以我希望是29.345,我的目标是用它来检查我的位置是否在范围

我在理解这个函数时有点困难:

Location.distanceBetween(lat1, lon1, lat2, lon2, results);
我的地图上有两个点,我的当前位置和另一个。离我现在的位置大概有30米远

但我得到的结果仍然是:

results[0] = 6935649.5
results[1] = 121.08577
results[2] = 154.8537
这对我来说没有意义,函数告诉我它应该以米为单位返回,所以我希望是29.345,我的目标是用它来检查我的位置是否在范围内。距离另一个标记100米

编辑:以下是我的数据和我使用的值

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;

嘿,退房。希望它能帮助我,我看到我的输出是相当奇怪的!我的位置的经度和纬度在我通过它时被交换了(x)我现在离答案越来越近了。但还不是很准确。问题不在于位置。方法之间的距离,而在于你位置的准确性