android - distance To() 返回的距离不是米!

标签 android gps location coordinates distance

我正在实现一个应用程序来从 gps 坐标数据库中搜索最近的本地场所。

我正在使用 Location 类 distanceTo() 函数来计算两个位置之间的距离,即当前位置和数据库中的位置。

currentloc.setLatitude(loc.getLatitude());
currentloc.setLongitude(loc.getLongitude());

dbcurrent.setLatitude(C.getDouble(latindex));
dbcurrent.setLongitude(C.getDouble(lonindex));
distance = currentloc.distanceTo(dbcurrent);

这个工作正常,我可以使用这个距离来计算我应用程序其余部分的接近度,但它自己的距离显然不是以米为单位我得到的结果像 4134801.4 我确信这个距离是 3200 米案例。

这个问题有什么解释或者解决办法吗

谢谢大家

最佳答案

distanceTo() 工作正常,这是你的错。 如果您提供 (0,0) 作为其他点,则可能会发生如此远的距离。

关于android - distance To() 返回的距离不是米!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4068742/

相关文章:

android - 如何在约束布局上实现重叠/负边距?

java - Android GPS 应用程序有时会崩溃

algorithm - 如何制作GPS交通应用程序?

javascript - 您如何使用 javascript(基于接近度)对经纬度点进行排序或切换显示

android - SettingsApi 已弃用

android - NfcA.transceive(byte[] data) 抛出 TagLostException

android - 在 Mupdf 上以横向模式显示两页

android - getRight、getLeft、getTop 返回零

.net - .NET 紧凑框架的 GPS 库

ios - 当 MKMapView 显示 UserLocation == YES 时隐藏 MKUserLocation