September 13th, 2011, 10:18 AM
|
#3 (permalink)
|
|
Junior Member
Join Date: Jul 2011
Posts: 27
Device(s):
Thanks: 9
Thanked 2 Times in 2 Posts
|
Hi,
I got my answer, I put my answer here and I hope it will help others too.
Note: Here, pass address and will get Latitude and Longitude of that address. It is working fine for me.
searchedAddress --> Can be (city name/address/Zipcode).
================================================== ==============
public boolean getLatitudeAndLongitudeFromGoogleMapForAddress(Str ing searchedAddress){
Geocoder coder = new Geocoder(IPlant.iPlantActivity);
List<Address> address;
try {
address = coder.getFromLocationName(searchedAddress,5);
if (address == null) {
Log.d(TAG, "############Address not correct #########");
}
Address location = address.get(0);
Log.d(TAG, "Address Latitude : "+ location.getLatitude();+ "Address Longitude : "+ location.getLongitude());
return true;
}catch(Exception e){
Log.d(TAG, "MY_ERROR : ############Address Not Found");
return false;
}
}
================================================== ================
Enjoy !!!
Andy
|
|
|