谷歌地图:如何在android系统获得地址地址、地图、如何在、系统

由网友(染九)分享简介:如何获得来自谷歌地图的位置或地址,当我点击一个特定的地址。是否有可能使用地图叠加从地图上看收集的地址。 How to get the location or address from the google map when i am click on a particular address. IS it possi...

如何获得来自谷歌地图的位置或地址,当我点击一个特定的地址。是否有可能使用地图叠加从地图上看收集的地址。

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中使用谷歌地图

阅读全文

相关推荐

最新文章