google / libaddressinput

Google’s postal address library, powering Android and Chromium
Apache License 2.0
579 stars 104 forks source link

Reconciling with Places API #138

Open jbredice opened 7 years ago

jbredice commented 7 years ago

Hi,

I'm trying to use metadata to validate addresses which may be populated from Autocomplete using the Google Places API. There are some challenging inconsistencies, such as Córdoba, Argentina.

Assuming the reference in this DB is the province (which includes a city by the same name): https://chromium-i18n.appspot.com/ssl-address/data/AR/Córdoba

Places API and the corresponding JavaScript widget, however, returns a version without the accent on the province name: "Córdoba, Cordoba, Argentina" like here: https://www.google.com/maps/place/C%C3%B3rdoba,+Cordoba,+Argentina

This is just one example. Has anyone successfully validated addresses returned from Places Autocomplete using this library?

Thanks!

sockix commented 7 years ago

How are you determining what to pass as the state using the Autocomplete API?

Presuming that you're parsing the description or structured_formatting elements, the problem might be the language that you specify in the requests to Places API.

In English: https://maps.googleapis.com/maps/api/place/autocomplete/xml?input=C%C3%B3rdoba,Cordoba,%20Argentina&language=en&key=YOUR_KEY

In Spanish: https://maps.googleapis.com/maps/api/place/autocomplete/xml?input=C%C3%B3rdoba,Cordoba,%20Argentina&language=es&key=YOUR_KEY

The service (and widget) currently only has state names specified for Argentina in Spanish (not English). You can see the languages available by looking at the 'languages' attribute of: https://chromium-i18n.appspot.com/ssl-address/data/AR

If you look at Canada, you'll see how two languages are represented. https://chromium-i18n.appspot.com/ssl-address/data/CA

jbredice commented 7 years ago

Thanks, @sockix - that's super helpful!

Just to make sure I understand correctly: If I look at the metadata for the country code and use the specified language to make the request to Places API, I should get a result I can match against?

That's awesome.

vwmax commented 6 years ago

Refreshing this thread. Taking a look. 65464102. ai/md.