我会如何获取城市的名字在谷歌地图,如果我有一个城市或地区的纬度和经度坐标?
How might I obtain the city name in Google Maps if I have latitude and longitude coordinates of a town or area?
我试着用纬度,经度和我的国家,但我不知道如何让城市的名字。
I tried using the latitude, longitude and I got country but I don't know how to get city name.
从Geo$c$cr对象,你可以调用getFromLocation(double,双,INT) 方法。它会返回 地址
名单具有方法getLocality().
Geocoder gcd = new Geocoder(context, Locale.getDefault());
List<Address> addresses = gcd.getFromLocation(lat, lng, 1);
if (addresses.size() > 0)
System.out.println(addresses.get(0).getLocality());