Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的 android 应用程序中,我试图将用户位置与商店坐标列表进行比较。
我已经知道如何获取用户坐标,并且我已经将列表作为数组。
如何比较两者并找到最近的商店?
float shortestDistance = Float.MAX_VALUE; Location closestLocation = null; for(Location loc : locations){ if(yourLocation.distanceTo(loc) < shortestDistance){ shortestDistance = yourLocation.distanceTo(loc); closestLocation = loc; } }