我想要你的幫助來計算兩個經度的距離。任何人都可以告訴我如何找到距離?我是Android工作室的新手。我想在我的應用程序中找到距離。目標地址由mlat
和mlong
定義,當前地址通過GPS值計算,其值在經度和緯度。如何查找兩個經度位置之間的距離?
我的代碼是:
double mlat =30.726030;
double mlong=76.759268;
imgButton1 =(ImageButton)findViewById(R.id.imageButton1);
mgButton1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Location gpsLocation = appLocationService.getLocation(LocationManager.GPS_PROVIDER);
if (gpsLocation != null) {
double latitude = gpsLocation.getLatitude();
double longitude = gpsLocation.getLongitude();
String result = "Latitude: " + gpsLocation.getLatitude() +
" Longitude: " + gpsLocation.getLongitude();
tvAddress.setText(result);
} else {
showSettingsAlert();
}
}
});
告訴我如何找到兩個經度和緯度之間的距離。
thanx的用戶persious時間 –