我想要你的帮助来计算两个经度的距离。任何人都可以告诉我如何找到距离?我是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时间 –