【发布时间】:2014-03-13 13:07:46
【问题描述】:
现在我从当前位置获取地址,现在我将从地址获取纬度和经度
Geocoder gcd = new Geocoder(getBaseContext(), Locale.getDefault());
List<Address> addresses;
try {
addresses = gcd.getFromLocation(location.getLatitude(),
location.getLongitude(), 1);
if (addresses.size() > 0)
java.lang.System.out.println(addresses.get(0).getLocality());
cityName = addresses.get(0).getAddressLine(0);
plz = addresses.get(0).getAddressLine(1);
Land = addresses.get(0).getAddressLine(2);
} catch (IOException e) {
e.printStackTrace();
}
String s = longitude + "\n" + latitude + "\n\n"
+ cityName+ "\n" + plz + "\n"+ Land;
// String l = "\n\nMy Current Land is: " + Land;
txt.setText(s);
我用这个来获取地址,但我不知道如何从地址中获取纬度和经度?
【问题讨论】:
-
只是代码中的一个小错误,正确的方法见我的answer。
-
我没有收到你的问题,要么你想要来自 Lat/Long 的地址,要么你想要来自地址的 Lat/Long?
-
@inef 这里也一样。所以你从lat/long获取地址,然后想要地址的lat/long?
-
@Kedarnath 谢谢你我尝试了我的代码来检查这个是否正确,直到现在我没有问题
-
@i.n.e.f 我想要地址的纬度/经度,我可以将 makrer 导航到这一点:/我的英语不太好
标签: android openstreetmap osmdroid