slimkrazy / python-google-places

Simple wrapper around the new 'experimental' Google Places API
MIT License
474 stars 167 forks source link

formatted_address is unavailable before get_details() #122

Open danFromTelAviv opened 6 years ago

danFromTelAviv commented 6 years ago

Hi, Thanks for this amazing wrapper. It is so much better than google's api.

using the following code :

query_result = google_places.text_search(
            query="random place", lat_lng={"lat": 33.5, "lng": -86.8}, radius=100)

for idx, place in enumerate(query_result.places)
    print(place.formatted_address) 

give the following error :

googleplaces.GooglePlacesAttributeError: The attribute requested is only available after an explicit call to get_details() is made.

When using google's api directly this information is available without the additional get_details(). I worked around this by adding self.place_data = place_data to the Place class. I then call place.place_data.formatted_address instead of place.formatted_address and that works fine.

How would you suggest to implement this in a more proper way.

Thanks again