To convert latitude & longitude of location to Address using the method called Reverse Geo-coding.
using getFromLocation(latitude lat, longitude lng, intmaxlength x);
Below coding is used for getting address.
Geocoder geoCoder = new Geocoder(
getBaseContext(), Locale.getDefault());
try {
List
addresses = geoCoder.getFromLocation(lat,lng,1);
if (addresses.size() > 0 && addresses != null) {
StringBuilder result = new StringBuilder();
myLoc.setText("Now i'm in " +addresses.get(0).getFeatureName()+"-"+addresses.get(0).getLocality()+"-"+addresses.get(0).getAdminArea()+"-"+addresses.get(0).getCountryName() + " at " + dt);
}
}
catch (IOException e) {
e.printStackTrace();
}
using getFromLocation(latitude lat, longitude lng, intmaxlength x);
Below coding is used for getting address.
Geocoder geoCoder = new Geocoder(
getBaseContext(), Locale.getDefault());
try {
List
addresses = geoCoder.getFromLocation(lat,lng,1);
if (addresses.size() > 0 && addresses != null) {
StringBuilder result = new StringBuilder();
myLoc.setText("Now i'm in " +addresses.get(0).getFeatureName()+"-"+addresses.get(0).getLocality()+"-"+addresses.get(0).getAdminArea()+"-"+addresses.get(0).getCountryName() + " at " + dt);
}
}
catch (IOException e) {
e.printStackTrace();
}
0 comments:
Post a Comment