Android 如何在google Maps API V2中获取从当前位置到纬度目的地的英里/公里和分钟数

Android 如何在google Maps API V2中获取从当前位置到纬度目的地的英里/公里和分钟数,android,google-maps,Android,Google Maps,如何在google maps API V2中获取从当前位置到纬度/经度目的地的英里/公里和负数。如果我得到这个值,我想存储在textview中 我的代码是: import android.os.Bundle; import com.actionbarsherlock.app.SherlockActivity; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.G

如何在google maps API V2中获取从当前位置到纬度/经度目的地的英里/公里和负数。如果我得到这个值,我想存储在textview中

我的代码是:

import android.os.Bundle;

import com.actionbarsherlock.app.SherlockActivity;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class DetailMapActivity extends SherlockActivity {
    private GoogleMap map;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_detail_map);

        map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
                .getMap();
        map.setMyLocationEnabled(true);

        LatLng LOC_DESTINATION = new LatLng(-6.33438, 106.74316);

        map.addMarker(new MarkerOptions().position(LOC_DESTINATION)
                .title("Destination Title").snippet("Destination Description"));

        map.moveCamera(CameraUpdateFactory.newLatLngZoom(LOC_DESTINATION, 40));

        map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);

        String miles = "what this code?";
        Log.d("HaichalMap", miles);
    }
}

谢谢你的回答。

谷歌地图不提供方向。您需要查看

您需要根据新旧坐标(纬度和经度)计算距离。这将以米为单位返回结果。然后需要将其转换为英里/公里。就计算与初始坐标和最终坐标之间的距离而言,任何方法都可能对您有所帮助。希望这能回答您的问题。

使用
位置
类尝试此操作

Location locationA = new Location("Location A");
locationA.setLatitude(lat_a);
locationA.setLongitude(lon_a);

Location locationB = new Location("Location B");
locationB.setLatitude(lat_b);
locationB.setLongitude(lon_b);

int metres = Math.round(locationA.distanceTo(locationB)); // Returns in Metres

将米转换为所需的输出

是否要获取两个位置之间的距离?感谢回复,是否可以使用API2与google maps android集成?谢谢