From 3ce6cf8b4101d04ad2aa65dbe36942656813101f Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 22 May 2018 21:43:21 +0000 Subject: [PATCH] Just use formatted_address from the Google geocode response instead of considering all the cases of address formatting --- platypush/plugins/google/maps.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/platypush/plugins/google/maps.py b/platypush/plugins/google/maps.py index 24daa49355..722e19deaf 100644 --- a/platypush/plugins/google/maps.py +++ b/platypush/plugins/google/maps.py @@ -33,27 +33,16 @@ class GoogleMapsPlugin(GooglePlugin): logging.info('Google Maps geocode response for latlng ({},{}): {}'. format(latitude, longitude, result)) + address['address'] = result['formatted_address'] for addr_component in result['address_components']: for component_type in addr_component['types']: - if component_type == 'street_number': - address['street_number'] = addr_component['long_name'] - elif component_type == 'route': - address['address'] = addr_component['long_name'] - elif component_type == 'locality': + if component_type == 'locality': address['locality'] = addr_component['long_name'] elif component_type == 'country': address['country'] = addr_component['short_name'].lower() elif component_type == 'postal_code': address['postal_code'] = addr_component['long_name'] - if 'address' in address and 'street_number' in address: - address['address'] = '{}{}{}'.format( - (address['address'] or ''), - (' ' if address['street_number'] else ''), - (address['street_number'] or '')) - - del(address['street_number']) - return Response(output=address)