In my current android application, I would like to get the geocordinates based on an entered city name, street name or zip code. How can I accomplish this?
Best Rega
searchedAddress --> Can be (city name/address/Zipcode).
public boolean getLatitudeAndLongitudeFromGoogleMapForAddress(String searchedAddress){
Geocoder coder = new Geocoder(IPlant.iPlantActivity);
List 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;
}
}