

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

# 如何使用地理空間內容搜尋附近的
<a name="how-to-search-nearby-geospatial"></a>

SearchNearby API 可讓您探索附近，同時限制地理空間內容 （例如圓圈或週框方塊） 內的結果。

SearchNearby API 可讓您使用地理空間內容篩選結果，例如圓圈和週框方塊。透過定義這些地理邊界，您可以將搜尋結果限制在特定區域。

## 潛在的使用案例
<a name="potential-use-search-nearby-geospatial"></a>
+ 將搜尋結果限制在特定地理區域
+ 在自訂定義的邊界內搜尋
+ 將結果集中在目標鄰里或區域

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

### 使用查詢半徑搜尋
<a name="search-nearby-geospatial-example"></a>

下列範例示範如何搜尋指定座標 1000 公尺半徑內的學校。

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

此請求會搜尋 1000 公尺 (1 公里） 半徑內的學校。

```
{
    "QueryPosition": [
                 -122.741803, 
         49.002478
        ],
        "QueryRadius":1000,
        "Filter" : {
            "IncludeCategories": ["school"]
    }
    
}
```

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

```
{
    "ResultItems": [
        {
            "PlaceId": "<Redacted>",
            "PlaceType": "PointOfInterest",
            "Title": "Grace Lutheran Church",
            "Address": {
                "Label": "Grace Lutheran Church, 702 G St, Blaine, WA 98230-5125, United States",
                "Country": {
                    "Code2": "US",
                    "Code3": "USA",
                    "Name": "United States"
                },
                "Region": {
                    "Code": "WA",
                    "Name": "Washington"
                },
                "SubRegion": {
                    "Name": "Whatcom"
                },
                "Locality": "Blaine",
                "PostalCode": "98230-5125",
                "Street": "G St",
                "StreetComponents": [
                    {
                        "BaseName": "G",
                        "Type": "St",
                        "TypePlacement": "AfterBaseName",
                        "TypeSeparator": " ",
                        "Language": "en"
                    }
                ],
                "AddressNumber": "702"
            },
            "Position": [
                -122.74157,
                48.99533
            ],
            "Distance": 795,
            "Categories": [
                {
                    "Id": "church",
                    "Name": "Church",
                    "LocalizedName": "Church",
                    "Primary": true
                },
                {
                    "Id": "kindergarten_and_childcare",
                    "Name": "Kindergarten and Childcare",
                    "LocalizedName": "Kindergarten & Childcare",
                    "Primary": false
                },
                {
                    "Id": "school",
                    "Name": "School",
                    "LocalizedName": "School",
                    "Primary": false
                }
            ]
        }
        ...
    ]
}
```

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

```
curl --request POST \
  --url 'https://places.geo.eu-central-1.amazonaws.com/v2/search-nearby?key=Your_Key' \
  --header 'Content-Type: application/json' \
  --data '{
    "QueryPosition": [
         -122.741803, 
         49.002478
    ],
    "QueryRadius": 1000,
    "Filter": {
        "IncludeCategories": ["school"]
    }
}'
```

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

```
aws geo-places search-nearby --key ${YourKey} \
--query-position -122.741803 49.002478 \
--query-radius 1000 \
--filter '{"IncludeCategories": ["school"]}'
```

------

## 開發人員秘訣
<a name="search-nearby-geospatial-developer-tips"></a>
+ 或者，您可以使用週框方塊篩選條件。