

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 如何使用地理空間內容進行地理編碼
<a name="how-to-geocode-geospatial"></a>

Geocode API 可讓您使用地理空間內容 （例如偏差位置） 來取得所需的結果。

**注意**  
「平衡位置」是指根據使用者指定的位置或定義的區域排定搜尋結果優先順序的機制。它基本上會將搜尋結果的焦點轉移到地理位置上更接近指定偏差點的位置，而不一定排除其他結果。

## 潛在用途
<a name="geospatial-uses"></a>

使用地理空間內容，根據您的業務需求取得正確的結果。

## 範例
<a name="geospatial-examples"></a>

### 偏差結果到位置
<a name="bias-position-example"></a>

透過偏差到位置，您可以變更結果的排名。嘗試以下範例，使用 值，然後不使用 `BiasPosition`值，並比較結果。

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

```
{
    "QueryText": "George Street",
    "BiasPosition": [
                151.2059,
                -33.8691
            ]
}
```

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

```
{
    "ResultItems": [
        {
            "PlaceId": "<Redacted>",
            "PlaceType": "Street",
            "Title": "George St, Sydney NSW, Australia",
            "Address": {
                "Label": "George St, Sydney NSW, Australia",
                "Country": {
                    "Code2": "AU",
                    "Code3": "AUS",
                    "Name": "Australia"
                },
                "Region": {
                    "Code": "NSW",
                    "Name": "New South Wales"
                },
                "Locality": "Sydney",
                "Street": "George St",
                "StreetComponents": [
                    {
                        "BaseName": "George",
                        "Type": "St",
                        "TypePlacement": "AfterBaseName",
                        "TypeSeparator": " ",
                        "Language": "en"
                    }
                ]
            },
            "Position": [
                151.20691,
                -33.86974
            ],
            "Distance": 117,
            "MapView": [
                151.20225,
                -33.88406,
                151.20912,
                -33.85635
            ],
            "MatchScores": {
                "Overall": 1,
                "Components": {
                    "Address": {
                        "Intersection": [
                            1
                        ]
                    }
                }
            }
        },
        ...
        ...
    ]
}
```

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

```
curl --request POST \
  --url 'https://places.geo.eu-central-1.amazonaws.com/v2/geocode?key=Your_Key' \
  --header 'Content-Type: application/json' \
  --data '{
  "QueryText": "George Street",
    "BiasPosition": [
                151.2059,
                -33.8691
            ]
}'
```

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

```
aws geo-places geocode --key ${YourKey} --query-text "George Street" --bias-position 151.2059 -33.8691
```

------

## 開發人員秘訣
<a name="geospatial-developer-tips"></a>

對於地址地理編碼，請嘗試使用完整地址或查詢元件搭配偏差位置的組合，包括國家和地點。如需進一步了解，請參閱[如何對地址進行地理編碼](how-to-geocode-address.md)。