获得使用谷歌地图API当地城市名称 [英] Get Local Cities names using Google Map API

查看:317
本文介绍了获得使用谷歌地图API当地城市名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用程序,我用我的当前位置在谷歌地图API列出所有地方城市的名字

In my android app, I have to list all local cities names using my current location with Google Map API

输入


  1. 当前坐标

  2. 现在的地方名称。

输出

当前位置的地方城市。

推荐答案

试试这个方法。

public  List<Address> getAddressListFromLatLong(double lat, double lng) {

        Geocoder geocoder = new Geocoder(this);

        List<Address> list = null;
        try {
            list = geocoder.getFromLocation(lat, lng, 20);

                    // 20 is no of address you want to fetch near by the given lat-long

            for (Address address : list) {
                System.out.println(address);
            }
        } catch (Throwable e) {
            e.printStackTrace();
        }
        return list;
    }

这篇关于获得使用谷歌地图API当地城市名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆