谷歌地图:如何在android系统获得地址 [英] google map: how to get address in android
本文介绍了谷歌地图:如何在android系统获得地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获得来自谷歌地图的位置或地址,当我点击一个特定的地址。是否有可能使用地图叠加从地图上看收集的地址。
How to get the location or address from the google map when i am click on a particular address. IS it possible to use map overlay to collect the address from the map view.
推荐答案
请使用下code为获取地址。
Please Use below code for get address.
try {
Geocoder geo = new Geocoder(youractivityclassname.this.getApplicationContext(), Locale.getDefault());
List<Address> addresses = geo.getFromLocation(latitude, longitude, 1);
if (addresses.isEmpty()) {
yourtextfieldname.setText("Waiting for Location");
}
else {
if (addresses.size() > 0) {
yourtextfieldname.setText(addresses.get(0).getFeatureName() + ", " + addresses.get(0).getLocality() +", " + addresses.get(0).getAdminArea() + ", " + addresses.get(0).getCountryName());
//Toast.makeText(getApplicationContext(), "Address:- " + addresses.get(0).getFeatureName() + addresses.get(0).getAdminArea() + addresses.get(0).getLocality(), Toast.LENGTH_LONG).show();
}
}
}
catch (Exception e) {
e.printStackTrace(); // getFromLocation() may sometimes fail
}
和见下面的链接了解更多信息和完整的例子。
And see below link for more information and complete example.
这篇关于谷歌地图:如何在android系统获得地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文