3
我实现一个应用程序来搜索当地就近场馆从GPS坐标数据库。distanceTo()返回距离不以米为单位!
我使用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米。
是否有此问题的任何解释或解决方案。
谢谢大家。
首先仔细检查你的价值观,以保证它们是正确的。然后进行一次测试呼叫,在距离可能有一秒的经度差异的情况下进行测试。走着瞧吧。 – 2011-04-30 00:17:26
可能重复的[Android:Location.distanceTo工作不正常?](http://stackoverflow.com/questions/531324/android-location-distanceto-not-working-correctly) – 2011-04-30 00:18:41
想知道如何可能错过其他重复的问题在你问之前,SO在回顾现有问题? – 2011-04-30 00:20:04