【问题标题】:How to get complete address from latitude and longitude in android? [duplicate]如何从android中的纬度和经度获取完整的地址? [复制]
【发布时间】:2021-06-29 19:34:40
【问题描述】:

如何获取经纬度的完整地址?

我想从 android 中的纬度和经度中获取以下值

街道地址

城市/州

邮编

完整地址

如何做到这一点?

【问题讨论】:

标签: android


【解决方案1】:

也许使用 google map api 可以帮助您获取位置详细信息

【讨论】:

    【解决方案2】:
        Geocoder geocoder;
        List<Address> addresses;
        geocoder = new Geocoder(this, Locale.getDefault());
        addresses = geocoder.getFromLocation(latitude, longitude, 1);
        String address = addresses.get(0).getAddressLine(0);
        String city = addresses.get(0).getLocality();
        String state = addresses.get(0).getAdminArea();
        String country = addresses.get(0).getCountryName();
        String postalCode = addresses.get(0).getPostalCode();
        String knownName = addresses.get(0).getFeatureName();
    

    更多详情,请关注Android-Location-Address

    【讨论】:

      【解决方案3】:

      我有一个参考,几乎我已经使用过这个方法 - How to get complete address from latitude and longitude?

       Geocoder geocoder;
          List<Address> addresses;
          geocoder = new Geocoder(this, Locale.getDefault());
          
          addresses = geocoder.getFromLocation(latitude, longitude, 1); // Here 1 represent max location result to returned, by documents it recommended 1 to 5
          
          String address = addresses.get(0).getAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex()
          String city = addresses.get(0).getLocality();
          String state = addresses.get(0).getAdminArea();
          String country = addresses.get(0).getCountryName();
          String postalCode = addresses.get(0).getPostalCode();
          String knownName = addresses.get(0).getFeatureName(); // Only if available else return NULL
      

      【讨论】:

        猜你喜欢
        • 2012-03-13
        • 2017-04-09
        • 2016-03-26
        • 1970-01-01
        • 2019-10-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-07-24
        相关资源
        最近更新 更多