如何从经纬度获得完整的地址?经纬度、完整、地址

2023-09-11 12:04:51 作者:抚弦思华年

我想下面的机器人从经度和纬度值

街道地址 在城市/州 邮编 完整地址

如何实现这一目标?

解决方案

 地理codeR地理codeR;
名单<地址>地址;
地理codeR =新的地缘codeR(这一点,Locale.getDefault());

地址=地理coder.getFromLocation(纬度,经度,1); //这里1重present最大值位置结果返回,由文件它建议1-5

串地址= addresses.get(0).getAddressLine(0); //如果有任何额外的地址线present不是仅通过getMaxAddressLineIndex检查,最大可用地址线()
串城市= addresses.get(0).getLocality();
字符串状态= addresses.get(0).getAdminArea();
字符串全国= addresses.get(0).getCountryName();
字符串邮政code = addresses.get(0).getPostal code();
串knownName = addresses.get(0).getFeatureName(); //只有当其他可用返回NULL
 

有关详细信息,提供更多的信息,请看Android-Location-Address

I want to get following values from Latitude and Longitude in android

Street Address City / State Zip Complete Address 微信小程序整合高德地图获取定位经纬度信息

How to achieve this?

解决方案

Geocoder geocoder;
List<Address> addresses;
geocoder = new Geocoder(this, Locale.getDefault());

addresses = geocoder.getFromLocation(latitude, longitude, 1); // Here 1 represent max location result to returned, by documents it recommended 1 to 5

String address = addresses.get(0).getAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex()
String city = addresses.get(0).getLocality();
String state = addresses.get(0).getAdminArea();
String country = addresses.get(0).getCountryName();
String postalCode = addresses.get(0).getPostalCode();
String knownName = addresses.get(0).getFeatureName(); // Only if available else return NULL

For more info of available details, Look at Android-Location-Address