-3
我是一名Android初學者,我的問題是關於google map api v2.I使用我目前的位置和我的目的地繪製了一條路徑,並且我得到了一些正在通過我的路徑旅行的公共汽車位置。如何檢查buse的位置LatLng值與我的路徑LatLng值匹配?如何使用LatLng值檢查位置?
我是一名Android初學者,我的問題是關於google map api v2.I使用我目前的位置和我的目的地繪製了一條路徑,並且我得到了一些正在通過我的路徑旅行的公共汽車位置。如何檢查buse的位置LatLng值與我的路徑LatLng值匹配?如何使用LatLng值檢查位置?
試試這個,
Location crntLocation=new Location("crntlocation");
crntLocation.setLatitude(currentLatitude);
crntLocation.setLongitude(currentLongitude);
Location newLocation=new Location("newlocation");
newLocation.setLatitude(server_latitude);
newLocation.setLongitude(server_longitude);
float distance = crntLocation.distanceTo(newLocation); in meters
//distance =crntLocation.distanceTo(newLocation)/1000; // in km
if(distance<200){
//You are within 200 meter range
}
在一個循環將這個。
你的問題並沒有引起共鳴,基本上它是非常不清楚的,請非常精確 – Msk
你想通過編程方式檢查它還是隻想在地圖上顯示它? – Apurva
@apurva我想在地圖上顯示它。但我不知道檢查它並顯示的機制。請幫幫我 – Baveen