数据库设计,Google地图和地址字段

时间:2021-01-21 12:57:08

I want to collect the addresses of my users so that I can plot them on a Google Map. I know I need to store the lat/long values of their address, which I can get from Google Map API.

我想收集用户的地址,以便我可以在Google地图上绘制它们。我知道我需要存储他们的地址的纬度/经度值,我可以从谷歌地图API获得。

I'm looking for recommendations on how to divide the various address parts and save them to the database. I commonly see things like this:

我正在寻找有关如何划分各种地址部分并将其保存到数据库的建议。我经常看到这样的事情:

  • Address Line 1
  • 地址栏1

  • Address Line 2
  • 地址第2行

  • City
  • State/Region/Province
  • ZIP/Postal Code
  • Country

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

不过,Google对这些地址组件进行了不同的分解。例如,请参阅:http://maps.googleapis.com/maps/api/geocode/json?address = 1600+Amphitheatre + Parkway,+ Mountain + View,+ CA&_sensor = false

I'm not sure what parts of Google address components equate to what is commonly seen in web forms (e.g. is administrative_area_level_1 always the state/region/province?). I'd like to store the various address components as atomically as possible so that I have the greatest control when displaying the address information later on.

我不确定Google地址组件的哪些部分等同于Web表单中常见的部分(例如,administrative_area_level_1始终是州/地区/省?)。我想尽可能以原子方式存储各种地址组件,以便在以后显示地址信息时能够获得最大的控制权。

NOTE: I also plan to store the formatted_address as I think that could be useful in some cases.

注意:我还计划存储formatted_address,因为我认为在某些情况下这可能很有用。

So, what should I store in my database?

那么,我应该在我的数据库中存储什么?

1 个解决方案

#1


4  

This section of the Geocoding documentation provides a pretty good description of the types of data you get back from the reverse geocoder. These data types were developed by Google to describe any address in the world, so are probably a good starting point.

地理编码文档的这一部分提供了对从反向地理编码器返回的数据类型的非常好的描述。这些数据类型是由Google开发的,用于描述世界上的任何地址,因此可能是一个很好的起点。

Based on the following quote the administrative_area_level_1 describes subnational jurisdictions, states in the US/Australia, prefectures in Japan, provinces in france etc:

根据以下引用,administrative_area_level_1描述了地方管辖区,美国/澳大利亚的州,日本的县,法国的省等:

administrative_area_level_1 indicates a first-order civil entity below the country level. Within the United States, these administrative levels are states. Not all nations exhibit these administrative levels.

administrative_area_level_1表示*以下的一级民事实体。在美国,这些行政级别是国家。并非所有国家都具有这些行政级别。

You will probably need to be careful about the assumptions you make about these datatypes for other countries. For instance, the administrative_area_level_1 for addresses in London is England. But with a good understanding of this schema, you should be able to render locale friendly addresses anywhere in the world.

您可能需要注意您对其他国家/地区的这些数据类型所做的假设。例如,伦敦地址的administrative_area_level_1是英格兰。但是通过很好地理解这个模式,您应该能够在世界的任何地方呈现语言环境友好的地址。

#1


4  

This section of the Geocoding documentation provides a pretty good description of the types of data you get back from the reverse geocoder. These data types were developed by Google to describe any address in the world, so are probably a good starting point.

地理编码文档的这一部分提供了对从反向地理编码器返回的数据类型的非常好的描述。这些数据类型是由Google开发的,用于描述世界上的任何地址,因此可能是一个很好的起点。

Based on the following quote the administrative_area_level_1 describes subnational jurisdictions, states in the US/Australia, prefectures in Japan, provinces in france etc:

根据以下引用,administrative_area_level_1描述了地方管辖区,美国/澳大利亚的州,日本的县,法国的省等:

administrative_area_level_1 indicates a first-order civil entity below the country level. Within the United States, these administrative levels are states. Not all nations exhibit these administrative levels.

administrative_area_level_1表示*以下的一级民事实体。在美国,这些行政级别是国家。并非所有国家都具有这些行政级别。

You will probably need to be careful about the assumptions you make about these datatypes for other countries. For instance, the administrative_area_level_1 for addresses in London is England. But with a good understanding of this schema, you should be able to render locale friendly addresses anywhere in the world.

您可能需要注意您对其他国家/地区的这些数据类型所做的假设。例如,伦敦地址的administrative_area_level_1是英格兰。但是通过很好地理解这个模式,您应该能够在世界的任何地方呈现语言环境友好的地址。