android - 在 GPS 中获取最近的地方与我在 android 中的当前位置进行比较

标签 android gps locationmanager locationlistener

在android中我获取了当前位置的纬度和经度,我还有另外两个坐标,我需要将这两个坐标与我的坐标met进行比较,并动态地得到最近的一个。我试过了,但是动态如何获取?

最佳答案

您可以使用 distanceTo(Location dest) 比较位置或使用 distanceBetween(double startLatitude, double startLongitude, double endLatitude, double endLongitude, float[] results) 进行比较坐标。

这两种方法都会为您提供两点之间的距离。如果你动态地做,你只需要计算更小的。

关于它们的更多信息:Location Android

关于android - 在 GPS 中获取最近的地方与我在 android 中的当前位置进行比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8942210/

相关文章:

Java string.equals(string) 没有按预期运行

ios - iOS:如果没有GPS,是否可以检测用户是否在驾驶车辆?

java - 从 Android 设备获取实际位置(不是最后一个)

android每10分钟检测一次gps位置

Android LocationListener 没有命中 onLocationChanged

ANDROID locationManager.requestLocationUpdates无法解析?

Android BLE readCharacteristic 失败

android如何在canvas半透明上绘制位图

android - 有条件显示的 View 和布局元素

c# - 使用 WriteImageToSavedPhotosAlbum 时未保存 Gps exif 数据