

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# 住所を完成させる方法
<a name="how-to-complete-address"></a>

Autocomplete API を使用すると、部分的に入力された住所を補完でき、エンドユーザーに標準化された入力を提供し、データ入力時の効率を向上させることができます。

## 想定されるユースケース
<a name="potential-use"></a>
+ **チェックアウト時の住所補完:** 顧客がチェックアウトフォームに入力する際、正確で迅速な住所入力をサポートします。
+ **国別住所補完:** 提案を特定の国に絞り、ユーザーの所在地に合わせたコンプライアンスや関連性を確保します。

## 例
<a name="autocomplete-address-examples"></a>

### 最小限のデータで住所を完成させる
<a name="autocomplete-minimal-data"></a>

この例では、レスポンスを簡潔でコスト効果の高いものにするため、最小限のデータが返されます。場所の完全な情報は、後で GetPlace API で PlaceId を使用して取得できます。

------
#### [ Sample request ]

```
{
  "QueryText": "100 McCullum Rd"
}
```

------
#### [ Sample response ]

```
{
    "ResultItems": [
        {
            "PlaceId": "<Redacted>",
            "PlaceType": "PointAddress",
            "Title": "United Kingdom, E3 5JB, London, 100 McCullum Road"
        }
    ],
    "QueryRefinements": []
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://places.geo.eu-central-1.amazonaws.com/v2/autocomplete?key=Your_Key' \
  --header 'Content-Type: application/json' \
  --data '{
  "QueryText": "100 McCullum Rd"
}'
```

------
#### [ AWS CLI ]

```
aws geo-places autocomplete --key ${YourKey} --query-text "100 McCullum Rd"
```

------

### 住所コンポーネントを使用して住所を完成させる
<a name="autocomplete-address-component"></a>

この例では、複数の住所候補が返されるため、ユーザーはフォームフィールドを正確に入力するための標準化された住所形式を選択できます。

------
#### [ Sample request ]

```
{
  "QueryText": "100 McCullum Rd",
  "AdditionalFeatures": [
    "Core"
  ]
}
```

------
#### [ Sample response ]

```
{
    "ResultItems": [
        {
            "PlaceId": "<Redacted>",
            "PlaceType": "PointAddress",
            "Title": "United Kingdom, E3 5JB, London, 100 McCullum Road",
            "Address": {
                "Label": "100 McCullum Road, London, E3 5JB, United Kingdom",
                "Country": {
                    "Code2": "GB",
                    "Code3": "GBR",
                    "Name": "United Kingdom"
                },
                "Region": {
                    "Name": "England"
                },
                "SubRegion": {
                    "Code": "LDN",
                    "Name": "London"
                },
                "Locality": "London",
                "District": "Bow",
                "PostalCode": "E3 5JB",
                "Street": "McCullum Road",
                "StreetComponents": [
                    {
                        "BaseName": "McCullum",
                        "Type": "Road",
                        "TypePlacement": "AfterBaseName",
                        "TypeSeparator": " ",
                        "Language": "en"
                    }
                ],
                "AddressNumber": "100"
            },
            "Language": "en",
            "Highlights": {
                "Title": [
                    {
                        "StartIndex": 32,
                        "EndIndex": 35,
                        "Value": "100"
                    },
                    {
                        "StartIndex": 36,
                        "EndIndex": 49,
                        "Value": "McCullum Road"
                    }
                ],
                "Address": {
                    "Label": [
                        {
                            "StartIndex": 0,
                            "EndIndex": 3,
                            "Value": "100"
                        },
                        {
                            "StartIndex": 4,
                            "EndIndex": 17,
                            "Value": "McCullum Road"
                        }
                    ],
                    "Street": [
                        {
                            "StartIndex": 0,
                            "EndIndex": 13,
                            "Value": "McCullum Road"
                        }
                    ],
                    "AddressNumber": [
                        {
                            "StartIndex": 0,
                            "EndIndex": 3,
                            "Value": "100"
                        }
                    ]
                }
            }
        },
        ...
    ],
    "QueryRefinements": []
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://places.geo.eu-central-1.amazonaws.com/v2/autocomplete?key=Your_Key' \
  --header 'Content-Type: application/json' \
  --data '{
  "QueryText": "100 McCullum Rd",
  "AdditionalFeatures": [
    "Core"
  ]
}'
```

------
#### [ AWS CLI ]

```
aws geo-places autocomplete --key ${YourKey} --query-text "100 McCullum Rd" --additional-features "Core"
```

------