本文介紹了獲取兩個地理點之間的距離的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我想制作一個應用程序來檢查用戶最近的位置.我可以輕松獲取用戶的位置,并且我已經有了一個經緯度的地點列表.
I want to make an app which checks the nearest place where a user is. I can easily get the location of the user and I have already a list of places with latitude and longitude.
根據當前用戶位置了解列表中最近位置的最佳方法是什么.
What would be the best way to know the nearest place of the list against the current user location.
我在谷歌 API 中找不到任何東西.
I could not find anything in the google APIs.
推薦答案
Location loc1 = new Location("");
loc1.setLatitude(lat1);
loc1.setLongitude(lon1);
Location loc2 = new Location("");
loc2.setLatitude(lat2);
loc2.setLongitude(lon2);
float distanceInMeters = loc1.distanceTo(loc2);
參考:http://developer.android.com/參考/android/location/Location.html#distanceTo(android.location.Location)
這篇關于獲取兩個地理點之間的距離的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!