在我当前的 android 应用程序中,我想根据输入的城市名称、街道名称或邮政编码获取地理坐标.我怎样才能做到这一点?
In my current android application, I would like to get the geocordinates based on an entered city name, street name or zip code. How can I accomplish this?
最好的问候,罗尼
查看方法Geocoder.getFromLocationName(cityName, maxResults)
.
像这样使用它:
List<Address> addressList = geoCoder.getFromLocationName(cityName, 1);
Address address = addressList.get(0);
if(address.hasLatitude() && address.hasLongitude()){
double selectedLat = address.getLatitude();
double selectedLng = address.getLongitude();
}
这篇关于根据城市、邮编或街道名称获取纬度和经度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!