查找Android的两个位置之间的距离?

问题描述:

可能重复:结果
  Distance从我的位置计算到目标位置的Andr​​oid

我很新的谷歌Android地图我希望两地之间的距离显示。对于我写两个autocompletedtextview我得到的往返位置。通过使用

I am very new to android google maps i want display distance between two places .for that i write the two autocompletedtextview i get the from and to Locations .by using the

public String host = "https://maps.googleapis.com";
public String searchPath = "/maps/api/place/autocomplete/json";
public String detailsPath = "/maps/api/place/details/json";

我得到了地方的名称作为字符串我想使用两个字符串的地方我怎么能实现它计算两地之间的距离
    先谢谢了。

I got the places names as string i want calculate the distance between two places using that two string places how can i achieve it Thanks in Advance.

我认为这code有用的你:

i think this code usefull for you :

double distance

Location locationA = new Location("point A")

locationA.setLatitude(latA)

locationA.setLongitude(lngA)

Location locationB = new Location("point B")

locationB.setLatitude(latB)

LocationB.setLongitude(lngB)

distance = locationA.distanceTo(locationB)