Can this be improved to do the reverse?

#27 · closed · 1 comments

View on GitHub ↗

BenJackGill

Currently this takes a Google `PostalAddress` object and outputs a single formatted string. But I would like to do the reverse. I want to take a single address string such as `100 Sheppard Ave E, North York, ON M2N 6N5` and get back a Google `PostalAddress` object which would look something like this: ```TypeScript { regionCode:"CA", postalCode: "M2N 6N5", locality: "North York", addressLines: [ "100 Sheppard Ave E" ], } ``` This would allow us to fetch an single address line from a 3rd party API and store it as a structured addresses in our database.

Comments

DASPRiD

Sorry for not coming back to this earlier, GitHub notifications are sometimes quite flaky for me. Parsing an address into parts is a lot more involved than formatting an address. For that it's probably best to use something like Google's Geocoding API. That one for instance takes in an address string and returns all possible matches (yes, there could be multiple).