How to get complete address from latitude and longitude?

前端 未结 21 2122
深忆病人
深忆病人 2020-11-22 09:07

I want to get following values from Latitude and Longitude in android

  1. Street Address
  2. City / State
  3. Zip
  4. Complete Address
<
21条回答
  •  有刺的猬
    2020-11-22 09:39

    City & Country are not Always getting in address Line 1 & Line 2...

    Example is here

    So,

    Geocoder geocoder = new Geocoder(context, Locale.getDefault());
    
    List
    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 zip = addresses.get(0).getPostalCode(); String country = addresses.get(0).getCountryName();

提交回复
热议问题