0% found this document useful (0 votes)
17 views

Geocoding&Reverse Geocoding

Geocoding is the process of converting addresses into geographic coordinates like latitude and longitude. Reverse geocoding is converting coordinates into a human readable address. The document provides code examples for geocoding and reverse geocoding using the Geocoder class.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Geocoding&Reverse Geocoding

Geocoding is the process of converting addresses into geographic coordinates like latitude and longitude. Reverse geocoding is converting coordinates into a human readable address. The document provides code examples for geocoding and reverse geocoding using the Geocoder class.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Geocoding and reverse Geocoding

Geocoding is the process of converting addresses (like a street address) into geographic coordinates (like
latitude and longitude), which you can use to place markers on a map, or position the map.
Reverse geocoding is the process of converting geographic coordinates into a human readable address.

Geocoding is the process of finding the geographical coordinates (latitude and longitude) of a given address or location.
Reverse Geocoding is the opposite of geocoding where a pair of latitude and longitude is converted into an address or
location.
For achieving Geocode or Reverse Geocode you must first import the proper package.
import android.location.Geocoder;

The geocoding or reverse geocoding operation needs to be done on a separate thread and should never be used on
the UI thread as it will cause the system to display an Application Not Responding (ANR) dialog to the user.
To Achieve Geocode, use the below code
Geocoder gc = new Geocoder(context);
if(gc.isPresent()){
List<Address> list = gc.getFromLocationName(“155 Park Theater, Palo Alto, CA”, 1);
Address address = list.get(0);
double lat = address.getLatitude();
double lng = address.getLongitude();
}

To Achieve Reverse Geocode, use the below code


Geocoder gc = new Geocoder(context);
if(gc.isPresent()){
List<address> list = gc.getFromLocation(37.42279, -122.08506,1);
Address address = list.get(0);
StringBuffer str = new StringBuffer();
str.append(“Name: ” + address.getLocality() + “\n”);
str.append(“Sub-Admin Ares: ” + address.getSubAdminArea() + “\n”);
str.append(“Admin Area: ” + address.getAdminArea() + “\n”);
str.append(“Country: ” + address.getCountryName() + “\n”);
str.append(“Country Code: ” + address.getCountryCode() + “\n”);
String strAddress = str.toString();
}

You might also like