如何计算距离两点的距离,A点是用户位置,B点是Placepicker.getlatlang()

时间:2017-10-12 16:49:32

标签: android latitude-longitude google-latitude gmsplacepicker

{    @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == Place_Picker_Request){
        place_Picket = PlacePicker.getPlace(data,this);
        String nama = String.format("%s",place_Picket.getName());
        _txplaceName.setText("Name : "+nama);
        String address = String.format("%s",place_Picket.getAddress());
        _txplaceAddres.setText("Addres : "+address);
        String latlang = String.format("%s",place_Picket.getLatLng());
        _txplacePhoneNumber.setText("LatLng :"+latlang);

        "I will calculate distance betwen my location with latlang from placepicker"
        "and show in toast"


        Toast.makeText(MainActivity.this,"",Toast.Length_short).show();
        String url = String.format("%s",place_Picket.getWebsiteUri());
        _txplaceWebsite.setText("Alamat Website : "+url);


    }
    super.onActivityResult(requestCode, resultCode, data);
}}

1 个答案:

答案 0 :(得分:0)

从PlacePicker获得LatLang,如

final LatLng location = place.getLatLng();

并且你可以从LatLng获得纬度和经度,如

double lat = LatLng.latitude;
double lng = LatLng.longitude;

请参阅this了解更多信息。