

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 如何根据类别搜索附近的地点
<a name="how-to-search-nearby-category"></a>

该 SearchNearby API 允许在包含或排除指定类别的情况下查询兴趣点 (POI)。这可以帮助用户探索社区、探索当地 POIs景点等。该 API 需要 `QueryPosition`，它可以基于设备的位置、IP 位置或地图视口中心。或者，用户可以指定一个城市或地点，应用程序将根据该位置的坐标对结果进行偏置。

要了解有关支持的类别的更多信息，请参阅[类别筛选条件](places-filtering.md#place-categories)。

## 潜在使用案例
<a name="potential-use"></a>
+ **探索当地设施：**查找邻域可用的设施。
+ **探索旅游景点：**确定城市内的旅游景点。
+ **计划城市旅行：**组织所选城市 POIs 内不同城市的旅行。

## 示例
<a name="search-nearby-category-examples"></a>

### 包含类别
<a name="include-category"></a>

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

```
{
    "QueryPosition": [
        4.35609,
        50.84439
    ],
    "Filter": {
        "IncludeCategories": ["airport"]
    }
}
```

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

```
{
    "ResultItems": [
        {
            "PlaceId": "<Redacted>",
            "PlaceType": "PointOfInterest",
            "Title": "Brussels Airport",
            "Address": {
                "Label": "Brussels Airport, A201, 1930 Zaventem, België",
                "Country": {
                    "Code2": "BE",
                    "Code3": "BEL",
                    "Name": "België"
                },
                "Region": {
                    "Code": "VLG",
                    "Name": "Vlaanderen"
                },
                "SubRegion": {
                    "Name": "Vlaams Brabant"
                },
                "Locality": "Zaventem",
                "PostalCode": "1930",
                "Street": "A201",
                "StreetComponents": [
                    {
                        "BaseName": "A201",
                        "Language": "nl"
                    }
                ]
            },
            "Position": [
                4.47767,
                50.89452
            ],
            "Distance": 10191,
            "Categories": [
                {
                    "Id": "airport",
                    "Name": "Airport",
                    "LocalizedName": "Luchthaven",
                    "Primary": true
                }
            ]
        },
        {
            "PlaceId": "<Redacted>",
            "PlaceType": "PointOfInterest",
            "Title": "Internationale Luchthaven Antwerpen",
            "Address": {
                "Label": "Internationale Luchthaven Antwerpen, Luchthavenlei 1, 2100 Antwerpen, België",
                "Country": {
                    "Code2": "BE",
                    "Code3": "BEL",
                    "Name": "België"
                },
                "Region": {
                    "Code": "VLG",
                    "Name": "Vlaanderen"
                },
                "SubRegion": {
                    "Name": "Antwerpen"
                },
                "Locality": "Antwerpen",
                "District": "Deurne",
                "PostalCode": "2100",
                "Street": "Luchthavenlei",
                "StreetComponents": [
                    {
                        "BaseName": "Luchthaven",
                        "Type": "lei",
                        "TypePlacement": "AfterBaseName",
                        "TypeSeparator": "",
                        "Language": "nl"
                    }
                ],
                "AddressNumber": "1"
            },
            "Position": [
                4.45083,
                51.18867
            ],
            "Distance": 38852,
            "Categories": [
                {
                    "Id": "airport",
                    "Name": "Airport",
                    "LocalizedName": "Luchthaven",
                    "Primary": true
                }
            ]
        }
    ]
}
```

------
#### [ 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": [
        4.35609,
        50.84439
    ],
    "Filter": {
        "IncludeCategories": ["airport"]
    },
    "MaxResults": 2
}
```

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

```
aws geo-places search-nearby --key ${YourKey} \
--query-position 4.35609 50.84439 \
--filter '{"IncludeCategories": ["airport"]}' \
--max-results 2
```

------

### 排除类别
<a name="exclude-category"></a>

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

```
{
    "QueryPosition": [
        4.35609,
        50.84439
    ],
    "Filter": {
        "ExcludeCategories": ["airport"]
    }
}
```

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

```
{
    "ResultItems": [
        {
            "PlaceId": "<Redacted>",
            "PlaceType": "PointOfInterest",
            "Title": "Socialbrands Module 2",
            "Address": {
                "Label": "Socialbrands Module 2, Albertinaplein, 1000 Brussel, België",
                "Country": {
                    "Code2": "BE",
                    "Code3": "BEL",
                    "Name": "België"
                },
                "Region": {
                    "Code": "BRU",
                    "Name": "Brussel"
                },
                "SubRegion": {
                    "Name": "Brussel"
                },
                "Locality": "Brussel",
                "District": "Koningswijk",
                "PostalCode": "1000",
                "Street": "Albertinaplein",
                "StreetComponents": [
                    {
                        "BaseName": "Albertina",
                        "Type": "plein",
                        "TypePlacement": "AfterBaseName",
                        "TypeSeparator": "",
                        "Language": "nl"
                    }
                ]
            },
            "Position": [
                4.35609,
                50.84439
            ],
            "Distance": 0,
            "Categories": [
                {
                    "Id": "commercial_services",
                    "Name": "Commercial Services",
                    "LocalizedName": "Commerciële diensten",
                    "Primary": true
                }
            ],
            "Contacts": {
                "Websites": [
                    {
                        "Value": "https://oneread.net"
                    }
                ]
            },
            "AccessPoints": [
                {
                    "Position": [
                        4.35609,
                        50.84439
                    ]
                }
            ]
        },
        {
            "PlaceId": "<Redacted>",
            "PlaceType": "PointOfInterest",
            "Title": "Barman Privé",
            "Address": {
                "Label": "Barman Privé, Albertinaplein, 1000 Brussel, België",
                "Country": {
                    "Code2": "BE",
                    "Code3": "BEL",
                    "Name": "België"
                },
                "Region": {
                    "Code": "BRU",
                    "Name": "Brussel"
                },
                "SubRegion": {
                    "Name": "Brussel"
                },
                "Locality": "Brussel",
                "District": "Koningswijk",
                "PostalCode": "1000",
                "Street": "Albertinaplein",
                "StreetComponents": [
                    {
                        "BaseName": "Albertina",
                        "Type": "plein",
                        "TypePlacement": "AfterBaseName",
                        "TypeSeparator": "",
                        "Language": "nl"
                    }
                ]
            },
            "Position": [
                4.35609,
                50.84439
            ],
            "Distance": 0,
            "Categories": [
                {
                    "Id": "catering_and_other_food_services",
                    "Name": "Catering and Other Food Services",
                    "LocalizedName": "Catering- en horecadiensten",
                    "Primary": true
                }
            ],
            "Contacts": {
                "Phones": [
                    {
                        "Value": "+32476891634"
                    }
                ]
            },
            "OpeningHours": [
                {
                    "Display": [
                        "ma-zo: 00:00 - 24:00"
                    ],
                    "OpenNow": true,
                    "Components": [
                        {
                            "OpenTime": "T000000",
                            "OpenDuration": "PT24H00M",
                            "Recurrence": "FREQ:DAILY;BYDAY:MO,TU,WE,TH,FR,SA,SU"
                        }
                    ]
                }
            ],
            "AccessPoints": [
                {
                    "Position": [
                        4.35609,
                        50.84439
                    ]
                }
            ]
        }
    ]
}
```

------
#### [ 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": [
        4.35609,
        50.84439
    ],
    "Filter": {
        "ExcludeCategories": ["airport"]
    }
}
```

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

```
aws geo-places search-nearby --key ${YourKey} \
--query-position 4.35609 50.84439 \
--filter '{"ExcludeCategories": ["airport"]}' \
--max-results 2
```

------