【问题标题】:Get Local Cities names using Google Map API使用 Google Map API 获取本地城市名称
【发布时间】:2013-11-19 05:17:27
【问题描述】:

在我的 android 应用程序中,我必须使用我当前的位置和 Google Map API 列出所有本地城市名称

输入

  1. 当前坐标
  2. 当前地名。

输出

当前地点的当地城市。

【问题讨论】:

  • 请先发布您尝试过的步骤,所以不是让人们为您编码的地方。

标签: android web-services google-maps google-maps-api-3


【解决方案1】:

您必须先收集纬度和经度。 然后您可以使用地理编码器来获取它。喜欢:-

Geocoder gcd = new Geocoder(context, Locale.getDefault());
List<Address> addresses = gcd.getFromLocation(lat, lng, 1);
if (addresses.size() > 0) 
    System.out.println(addresses.get(0).getLocality());

【讨论】:

    【解决方案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;
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-15
      • 1970-01-01
      • 2022-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多