如何从某个位置搜索附近 - Amazon Location Service

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

如何从某个位置搜索附近

借助 SearchNearby API,无需输入任何特定文本,即可查询附近的所有地点和兴趣点 (POI)。用户可以使用此 API 探索社区 POIs、发现社区等。它需要一个QueryPosition,它可以表示设备的位置、基于 IP 的位置或地图视口中心。或者,用户可以指定城市或地点,根据该位置的地理坐标对结果进行偏差。

潜在用例

  • 探索附近 POIs:查看当前位置附近的所有景点。

  • 探索附近的地方:查看给定位置附近的所有位置或地点。

示例

在本示例中,搜索是从迪拜的一个位置进行的,其纬度为25.26951,经度为55.30884。

Sample request
{ "QueryPosition": [ 55.30884, 25.26951 ] }
Sample response
{ "ResultItems": [ { "PlaceId": "<Redacted>", "PlaceType": "PointOfInterest", "Title": "هما", "Address": { "Label": "هما, شارع مستشفى آل مكتوم, نايف دبي, الإمارات العربية المتحدة", "Country": { "Code2": "AE", "Code3": "ARE", "Name": "الإمارات العربية المتحدة" }, "SubRegion": { "Name": "دبي" }, "Locality": "دبي", "District": "نايف", "Street": "شارع مستشفى آل مكتوم", "StreetComponents": [ { "BaseName": "مستشفى آل مكتوم", "Type": "شارع", "TypePlacement": "BeforeBaseName", "TypeSeparator": " ", "Language": "ar" } ] }, "Position": [ 55.30884, 25.26951 ], "Distance": 0, "Categories": [ { "Id": "department_store", "Name": "Department Store", "LocalizedName": "مول تجاري", "Primary": true } ], "BusinessChains": [ { "Name": "HEMA", "Id": "HEMA" } ] }, { "PlaceId": "<Redacted>", "PlaceType": "Locality", "Title": "دبي, الإمارات العربية المتحدة", "Address": { "Label": "دبي, الإمارات العربية المتحدة", "Country": { "Code2": "AE", "Code3": "ARE", "Name": "الإمارات العربية المتحدة" }, "SubRegion": { "Name": "دبي" }, "Locality": "دبي" }, "Position": [ 55.30884, 25.26951 ], "Distance": 0, "MapView": [ 54.64906, 24.62308, 55.7371, 25.36995 ] } ] }
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": [ 55.30884, 25.26951 ], "MaxResults": 2 }'
AWS CLI
aws geo-places search-nearby --key ${YourKey} \ --query-position 55.30884 25.26951 \ --max-results 2