Database Design, Google Maps, and Address Fields

I want to collect the addresses of my users so that I can display them on a Google map. I know that I need to save the lat / long values ​​of their addresses, which I can get from the Google Maps API.

I am looking for recommendations on how to separate different addresses and store them in a database. I usually see things like this:

  • Address Line 1
  • Address bar 2
  • Town
  • State / Region / Region
  • Postcode
  • Country

Google breaks down these components of the address in different ways. See for example: http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false

I'm not sure which parts of Google components correspond to what is usually observed in web forms (for example, is administrative_area_level_1 always state / region / province?). I would like to keep the various address components as atomic as possible so that I have the most control when displaying the address information later.

NOTE. I also plan on storing formatted_address , as I think it might be useful in some cases.

So what should I store in my database?

+4
source share
1 answer

This section of the geocoding documentation provides a pretty good description of the types of data that you return from reverse geocoding. These data types were developed by Google to describe any address in the world, so this is probably a good starting point.

Based on the following quote, administrator_area_level_1 describes subnational jurisdictions, states in the USA / Australia, prefectures in Japan, provinces in France, etc.:

Administrative_area_level_1 indicates a first-level civilian below the country level. Within the US, these administrative levels are states. Not all countries demonstrate these administrative levels.

You may have to be careful about the assumptions you make about these data types for other countries. For example, Administrative_area_level_1 for addresses in London - England. But with a good understanding of this scheme, you should be able to display local addresses anywhere in the world.

+3
source

All Articles