Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Getting Address using Latlong

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 308
    Comment on it

    Below is the code to find an address in String by using latitude and longitude.

    I am using Geocoder class and method getFromLocation() of Geocoder class.

    We need to pass latitude, longitude in double format and integer value of the maximum number of addresses that we want.

     List<Address> locationAddresses;
            Geocoder gCoder = new Geocoder(this, Locale.getDefault());
    // 1 is maximum location address
            locationAddresses = gCoder.getFromLocation(lat, lng, 1);
    
            String locationAddress = locationAddresses.get(0).getAddressLine(0);
            String locationCity = locationAddresses.get(0).getLocality();
            String locationState = locationAddresses.get(0).getAdminArea();
            String locationCountry = locationAddresses.get(0).getCountryName();
            String locationPostalCode = locationAddresses.get(0).getPostalCode();
            String locationKnownName = locationAddresses.get(0).getFeatureName();
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: