Google Places API can return details about a particular place, given its ID:
Places.GeoDataApi.getPlaceById(mGoogleApiClient, placeId)
The data returned in the callback implements the Place
interface, providing access to the address as a comma-separated string using method:
Place.getAddress()
Parsing this string into fields for street, suburb, province, town etc is not reliable as string is not in a consistent format:
- Ranelagh Rd, Cape Town, South Africa (street, suburb, country)
- 1st Ave, Kenilworth, Cape Town, 7708, South Africa (street, suburb, town, post code, country)
- SW 23rd Terrace, Cape Coral, FL 33991, USA (street, town, post code, country)
Is there a reliable way to get parsed address info from Google?
getCountryName()
andgetPostalCode()
methods etc. – TestudoAddress
by reverse geocoding a lat/lng pair? I see you have a fair amount of Google Maps experience. – SanborneGeocoder
object by doingGeocoder geocoder = new Geocoder(this, Locale.getDefault());
, then calladdresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
You put1
here, so that it will only return 1 result, you can see this documentation for more details. – Testudo