使用 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
欄位相同的 Address proto,但以下情況除外:
- 沒有
ConfirmationLevel
欄位 - 沒有
unconfirmedComponentTypes
欄位
地址轉換的運作方式
Address Validation API 會將英文轉換套用至地址的每個元件。也就是說,系統會個別處理地址的 administrative_area
、locality
和其他元件。如需地址元件的清單,請參閱參考說明文件中的 AddressComponent。
下圖說明 Calle Rideñas, 5, 41003 Sevilla, España 這地址的英文轉換效果。
對於接受英文轉換評估的每個元件,服務會使用以下各節所述的程序。
盡可能使用完整翻譯的英文內容
某些地址元件可能提供完整翻譯版本,以供使用。舉例來說,España
的西班牙國家/地區會翻譯成Spain
。在此情況下,服務會使用英文版。通常為 country
和 administrative_area_level_1
等大型地址元件的情況。
在未提供英文的情況下,使用當地語言進行初始化
拉丁文表示透過語音轉錄將當地語言轉換為拉丁文字集。
- 如果地址的當地語言使用拉丁字元集,但地址元件沒有英文對等項目,服務會取代「非」英文字元的當地語言。舉例來說,
Calle Dueñas
會變成Calle Duenas
,其中 ñ 會取代 n。 - 如果地址的當地語言不使用拉丁式字元集,且地址元件沒有英文對等項目,則服務會使用本地化版本的當地語言 (如果有的話)。例如,日文轉換會傳回日文的拼音。所有非英文、非拉丁字元都會替換為英文拉丁字元。例如:3 號星球會變成 3 杯。
- 請注意,預覽時尚未啟用日文
- 如果語言沒有拉丁文版本,則會以當地語言傳回元件。
替換英文的拉丁字元
任何非英文的拉丁字元都會替換為對等的英文字元。舉例來說,以下每個字元都會由以下字元取代:「o ": o": 」、「ó、ô、õ、ö、ø、ō、中看到、、ṓ、例如:
Rae de Ruiz de Alarcón 變成 Calle de Ruiz de Alarcon
地址轉換範例
以下範例顯示了西班牙 Palacio de las Afterñas 要求,其中 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 地圖平台服務水準協議的涵蓋範圍內。
使用備用機制,特別是在實際工作環境中使用正式發布前功能時。以下是一些備用情況的範例:超出配額、非預期的回應代碼和延遲時間,或是與現有行為相比的非預期的回應。
您可以透過 Issue Tracker 要求新功能,或建議修改現有功能。請務必在要求中附上以下資訊:
請說明您希望新增的特定地圖項目或行為,以及您認為該功能的重要性。
盡可能詳述這項功能的用途及新用途。
如有任何關於本意見或功能方面的其他問題,請傳送電子郵件至地址驗證熱線:address-validation-hotline@google.com。