如何找到两个geopoints之间的距离?距离、两个、geopoints

2023-09-13 00:00:17 作者:小小、思绪

double distance;  

Location locationA = new Location("point A");  

locationA.setLatitude(latA);  
locationA.setLongitude(lngA);  

Location locationB = new Location("point B");  

locationB.setLatitude(latB);  
LocationB.setLongitude(lngB);  

distance = locationA.distanceTo(locationB);  

以上code不工作,我得到0.0公里的距离是多少? 另外在位置类的构造函数,什么是字符串提供商的意思。 在上述$ C $词现在用PointA和PointB作为供应商。

the above code is not working and i am getting 0.0 Km as distance? Also in the constructor of the location class, what does the string provider mean. In the above code i am using PointA and PointB as the providers.

为什么上面的code不工作?

why is the above code not working?

感谢你在前进。

的logcat     05-09 17:48:56.144:信息/电流LOC(1573):北纬0.0 LNG 0.0     05-09 17:48:56.155:信息/ checklocation LOC(1573):纬度54.4288665 LNG 10.169366

LOGCAT 05-09 17:48:56.144: INFO/current loc(1573): lat 0.0 lng 0.0 05-09 17:48:56.155: INFO/checklocation loc(1573): lat 54.4288665 lng 10.169366

推荐答案

尝试Location.distanceBetween(..)

更新:

如果您是从的GeoPoint越来越纬度/经度,然后他们在microdegrees。您必须通过1e6个繁殖。

If you are getting lat/lon from GeoPoint then they are in microdegrees. You must multiply by 1e6.