使用 Address Validation API 时,您可以请求验证响应也返回转换为英文的地址。当您的系统需要以基于英语的拉丁字符提供地址信息,但收到的地址信息为非英语时,请使用此功能。 例如:
- 贵公司可能需要处理来自世界各地的配送请求,并使用英语和基于英语的拉丁字符来标准化所有地址。
- 您的商家可能需要处理发往或来自某个国家/地区的货件,而该国家/地区使用的语言与所提供地址的语言不同。
如何以英文返回地址
如需请求包含等效英语组成部分的地址验证,请将以下内容添加到验证请求正文中:
"languageOptions": { "returnEnglishLatinAddress": "true" }
以下示例在验证普拉多博物馆的地址时请求基于英语的组件:
curl -X POST -d '{ "address": { "region_code" : "ES", "address_lines": ["C. de Ruiz de Alarcón, 23, 28014 Madrid, Spain"], }, "languageOptions": {returnEnglishLatinAddress: true} }' \ -H 'Content-Type: application/json' \ -H 'X-Goog-Api-Key: API_KEY' \ 'https://addressvalidation.googleapis.com/v1:validateAddress'
响应会在 englishLatinAddress
字段中返回英文地址。如需了解详情,请参阅下方的地址转换示例。返回的本地语言地址的每个组成部分都会尽可能转换为英语。转换后的地址无法作为 API 的输入重复使用。
englishLatinAddress
字段使用的 Address proto 与 address
字段使用的相同,但有以下例外情况:
- 没有
ConfirmationLevel
字段 - 没有
unconfirmedComponentTypes
字段
提高日语地址转换质量
提交要转换为英文的日文地址时,请在地址的以下部分之间添加空格或分隔符(例如“-”):
- 楼栋号(营业场所)和楼栋名称。
- 楼号(房屋)和子房屋 / 单元号。
- 建筑物名称和子地址。
例如:
- 東京都渋谷区渋谷 3−21−3 渋谷ストリーム 5階 (Recommended)
- 東京都渋谷区渋谷3−21−3渋谷ストリーム5階(不推荐)
没有楼宇名称时的示例:
- 東京都渋谷区渋谷3丁目21−3 5階(推荐)
- 東京都渋谷区渋谷3丁目21−3−5階(推荐)
- 東京都渋谷区渋谷3丁目21−35階(不推荐)
地址转换的运作方式
Address Validation API 会将地址的每个组成部分转换为英文。这意味着,系统会单独处理 administrative_area
、locality
和地址的其他组成部分。如需查看地址组件的列表,请参阅参考文档中的 AddressComponent。
下图展示了地址 Calle Dueñas, 5, 41003 Sevilla, España 的英文转换效果。
对于评估的每个需要转换为英语的组件,该服务都会使用以下部分中所述的流程。
尽可能使用完全翻译的英文
某些地址组成部分可能具有完全翻译的版本可供使用。例如,西班牙国家/地区代码 España
会被翻译为 Spain
。在这种情况下,该服务会使用英文版。对于较大的地址组成部分(例如 country
和 administrative_area_level_1
),通常是这种情况。
如果英语不可用,则使用本地语言的拉丁化版本
拉丁化是指使用转写将本地语言转换为拉丁文字。
- 如果地址的本地语言使用拉丁字符集,并且地址组成部分没有对应的英文,则该服务会替换本地语言中不是基于英语的字符。例如,
Calle Dueñas
会变为Calle Duenas
,其中 ñ 会替换为 n。 - 如果地址的本地语言不使用基于拉丁字母的字符集,并且地址组成部分没有对应的英语版本,则该服务会使用本地语言的拉丁化版本(如果有)。
例如,日语转换会返回日语的拼音化结果。
所有非英语、非拉丁字符都会替换为基于英语的拉丁字符。例如:3丁目变为 3-chome。
- 请注意,预览版尚未启用日语
- 如果该语言没有拉丁化版本,则返回的组件采用本地语言。
替换非英语拉丁字符
所有非英语拉丁字符都会替换为相应的英文字符。例如,以下每个字符都会被替换为字符“o”:ð、ò、ó、ô、õ、ö、ø、ō、ŏ、ő、ơ、ṍ、ṏ、ṑ、ṓ、ọ、ỏ、ố、ồ、ổ、ỗ、ộ、ớ、ờ、ở、ỡ 和 ợ。例如:
Calle de Ruiz de Alarcón 变为 Calle de Ruiz de Alarcon
地址转换示例
以下示例展示了对西班牙杜埃尼亚斯宫的请求的验证响应,其中 englishLatinAddress
以粗体显示。此请求在输入中使用了 languageOptions
参数中的 returnEnglishLatinAddress
字段。
"result": { "verdict": { "inputGranularity": "PREMISE", "validationGranularity": "PREMISE", "geocodeGranularity": "PREMISE", "addressComplete": true, "hasInferredComponents": true }, "address": { "formattedAddress": "Calle Dueñas, 5, 41003 Sevilla, España", "postalAddress": { "regionCode": "ES", "languageCode": "es", "postalCode": "41003", "administrativeArea": "Sevilla", "locality": "Sevilla", "addressLines": [ "C. Dueñas, 5" ] }, "addressComponents": [ { "componentName": { "text": "Calle Dueñas", "languageCode": "es" }, "componentType": "route", "confirmationLevel": "CONFIRMED" }, { "componentName": { "text": "5", "languageCode": "es" }, "componentType": "street_number", "confirmationLevel": "CONFIRMED" }, { "componentName": { "text": "41003" }, "componentType": "postal_code", "confirmationLevel": "CONFIRMED" }, { "componentName": { "text": "Sevilla", "languageCode": "es" }, "componentType": "locality", "confirmationLevel": "CONFIRMED" }, { "componentName": { "text": "España", "languageCode": "es" }, "componentType": "country", "confirmationLevel": "CONFIRMED" }, { "componentName": { "text": "Sevilla", "languageCode": "es" }, "componentType": "administrative_area_level_2", "confirmationLevel": "CONFIRMED", "inferred": true } ] }, "geocode": { "location": { "latitude": 37.394849, "longitude": -5.9893604 }, "plusCode": { "globalCode": "8C9P92V6+W7" }, "bounds": { "low": { "latitude": 37.3948098, "longitude": -5.9894249 }, "high": { "latitude": 37.3948882, "longitude": -5.9893025 } }, "featureSizeMeters": 7.174035, "placeId": "ChIJzRDYbgRsEg0RDDgHlF80UoI", "placeTypes": [ "premise" ] }, "metadata": { "business": true, "residential": false }, "englishLatinAddress": { "formattedAddress": "Calle Duenas, 5, 41003 Seville, Spain", "postalAddress": { "regionCode": "ES", "languageCode": "en", "postalCode": "41003", "administrativeArea": "Seville", "locality": "Seville", "addressLines": [ "C. Duenas, 5" ] }, "addressComponents": [ { "componentName": { "text": "Calle Duenas", "languageCode": "es" }, "componentType": "route", }, { "componentName": { "text": "5", "languageCode": "es" }, "componentType": "street_number", }, { "componentName": { "text": "41003" }, "componentType": "postal_code", }, { "componentName": { "text": "Seville", "languageCode": "en" }, "componentType": "locality", }, { "componentName": { "text": "Spain", "languageCode": "en" }, "componentType": "country", }, { "componentName": { "text": "Seville", "languageCode": "en" }, "componentType": "administrative_area_level_2", "inferred": true } ] } }, "responseId": "e874d263-7d0d-413f-9213-119a784765ed"
预览版的支持选项
虽然 Google 不为服务的预览版、特性或功能提供支持服务,但我们会根据具体情况考虑这些开发阶段提出的请求。
对于非正式版,请使用以下建议:
正式发布前的功能不在 Google Maps Platform 服务等级协议 (SLA) 的涵盖范围内。
使用回退机制,尤其是在生产环境中使用预发布版功能时。以下是一些回退情况示例:超出配额、出现意外的响应代码和延迟时间,或者与现有行为相比,出现意外的响应。
您可以使用问题跟踪器请求新功能或建议修改现有功能。请务必在申请中提供以下信息:
请描述您希望添加的具体功能或行为,以及您认为必须添加该功能的理由。
如果可以,请详细具体地说明您的用例以及此功能可创造的新机遇。
如果您对此反馈或功能有任何其他疑问,请发送电子邮件至地址验证热线:address-validation-hotline@google.com。