问题描述
我需要知道的是有没有API,从那里我可以接收当前place.Using位置经理,我有接收当前位置的纬度和经度的地址,但我需要的地址。
I need to know is there any API ,from where i can receive the Address of the current place.Using location Manager i have receive the latitude and longitude of the current place ,but i need the address.
我已经尝试了下面的API。
I have tried the below api.
http://maps.googleapis.com/maps/api/geocode/json?latlng="+ lat + "," + lon + &sensor=true"
但它没有显示。可有人的确切位置帮助我。@谢谢
But it is not showing the exact place .Can somebody help me.@Thanks
推荐答案
从地理codeR 的对象,你可以调用<一href="http://developer.android.com/reference/android/location/Geo$c$cr.html#getFromLocation%28double,%20double,%20int%29">getFromLocation(double,双,INT)方法。
From a Geocoder object, you can call the getFromLocation(double, double, int) method.
如: -
private String getAddress(double latitude, double longitude) {
StringBuilder result = new StringBuilder();
try {
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
if (addresses.size() > 0) {
Address address = addresses.get(0);
result.append(address.getLocality()).append("\n");
result.append(address.getCountryName());
}
} catch (IOException e) {
Log.e("tag", e.getMessage());
}
return result.toString();
}
另外一个最好的答案就在这里How从纬度和经度坐标在谷歌地图获得城市的名字?
这篇关于获得使用经度和纬度的特定地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!