如何在android ecillipse项目和php上找到两个位置之间的距离。该项目基于在线良好的运输系统。需要找出承运人的票价,因此需要找到源和目的地之间的距离。Harversine公式是用于寻找该地区最短的车辆
问问题
42 次
2 回答
0
float[] results = new float[1];
Location.distanceBetween(source.latitude, source.longitude,
destination.latitude, destination.longitude,
results);
计算两个位置之间的近似距离(以米为单位),以及它们之间最短路径的初始和最终方位(可选)。距离和方位角是使用 WGS84 椭球定义的。计算出的距离存储在 results[0] 中。如果 results 的长度为 2 或更大,则初始方位存储在 results[1] 中。如果 results 的长度为 3 或更大,则最终方位存储在 results[2] 中。
@param startLatitude the starting latitude @param startLongitude the starting longitude @param endLatitude the ending latitude @param endLongitude the ending longitude @param results an array of floats to hold the results @throws IllegalArgumentException if results is null or has length < 1
于 2017-04-13T09:03:33.857 回答
0
试试这个代码
double _distance = Location.distanceBetween(
_firstLatitude,
_firstLongitude,
_secondLatitude,
_secondLongitude,
_results);
于 2017-04-13T09:04:13.620 回答