0

How to get complete address from latitude and longitude?

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

Street Address

City / State

Zip

Complete Address

How to achieve this?

  • 4
    Does this answer your question? [How to get complete address from latitude and longitude?](https://stackoverflow.com/questions/9409195/how-to-get-complete-address-from-latitude-and-longitude) – javdromero Apr 03 '21 at 04:31

3 Answers3

0

maybe using google map api can help you to get location detail

Tutuy
  • 9
  • 3
0
    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();

For more info of available details, Look at Android-Location-Address

0

I have got a reference from and almost I have use this method - 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
axar
  • 479
  • 2
  • 17