使用 Address Validation API 时,您可以请求验证响应也返回转换为英文的地址。如果您的系统在收到非英语地址的地址时需要以英语拉丁字符提供地址信息,请使用此功能。例如:
- 您的公司可能会满足世界各地的发货请求,并使用英文和英文拉丁字符对所有地址进行标准化。
- 您的商家可能负责处理往返某个国家/地区的货运,而该国家/地区的语言与所提供的地址的语言不同。
如何发回英语地址
如需请求包含等效英语组件的地址验证,请将以下代码添加到验证请求正文:
languageOptions: { returnEnglishLatinAddress: "true" }.
以下示例在验证普拉多博物馆地址时请求了英语组件:
curl -X POST -d '{ "regionCode" : ["ES"], "addressLines": ["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
字段
地址转换的运作方式
Address Validation API 会对地址的每个组成部分进行英语转换。这意味着,系统会单独处理 administrative_area
、locality
和地址的其他组成部分。如需查看地址组成部分的列表,请参阅参考文档中的 AddressComponent。
下图演示了以英语显示的地址 Calledueñ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。