Reputation:
I have used google to obtain an address from a postcode and the like before. My problem is I want my website to have address fields such that anyone in any country can sign up properly and provide all necessary address information. I will include a feature to enter postcode and obtain all other information automatically.
Is it reasonable for me to check the postcode and force a successful google lookup before someone signs up? If so I could just store the JSON string in the database as a blob or maybe inside a class. But I still need to decide what fields, such as street name, postcode or zip, and the like to include. I'm not sure where to begin deciding what to include?
I think what I'm really asking, is what fields are associated with what google fields in general. I know the different administrative levels are different things in different countries :/
Upvotes: 1
Views: 220
Reputation: 5267
While I can't say what you should specifically do for Google, I can tell you what fields our customers use when they validate international addresses online. (Full Disclosure: I'm a programmer at SmartyStreets where we validate international addresses.)
While each country's mailing system is unique, there are a few major similarities that they all share. This element of commonality is what allows you to have people enter their address into a universal form and then validate the address, regardless of the country in question.
Address Line 1
: This field is usually the house or building number and the street which the building is located. Examples of this field include: 123 Main Street
, Calle Proc. San Sebastián, 15
, 1019 North 1300 West
, etc.
Address Line 2
: This field would include apartment or suite numbers.
Locality
: The most common data entered for this is the city component of the address. For example: Paris, Hamburg, Johannesburg, etc.
Administrative Area
: This is the state or province name or abbreviation. Examples of this would be Texas - TX, Alberta - AB, Firenze (Italy) - FI.
Postal Code
(where available): Examples of this would be 90210 (Beverly Hills in California) or 84000 (Avingon in France).
While you can always add additional fields to give additional context to a software parser or interpreter, the above fields are the most common ones that you would use for international address validation. If you're not sure, you can test a non-US address for free. We offer extensive documentation that is both free and publicly visible to help better explain the nuances and idiosyncrasies of street and mailing addresses.
Upvotes: 2