本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
如何在某个国家内搜索地点
通过 SearchText API,您可以将搜索结果限制在一个或多个国家/地区内。此功能对于在边境地区或彼此相邻的小国进行搜索很有用。
使用 SearchText API 的一种方法是让最终用户进行自由文本搜索并确定应用程序集的偏见位置。这些偏置位置可以是设备位置、IP 位置或地图的视口中心。此外,最终用户可以提供城市名称或地点,应用程序可以根据地理坐标对结果进行偏差。
潜在用例
-
将搜索结果限制在一个国家范围内,以搜索国际边境为邻近的地区。
-
将结果筛选到多个国家。
示例
在此示例中,偏差位置位于美国和加拿大边境附近。如果不指定IncludeCountries": ["CAN"],API 将返回来自加拿大和美国的结果。
- Sample request
-
{ "QueryText": "Starbucks", "BiasPosition": [ -122.741803, 49.002478 ] } - Sample response
-
{ "ResultItems": [ { "PlaceId": "<Redacted>", "PlaceType": "PointOfInterest", "Title": "STARBUCKS", "Address": { "Label": "STARBUCKS, 16010 24 Ave, Surrey, BC V3Z 0R5, Canada", "Country": { "Code2": "CA", "Code3": "CAN", "Name": "Canada" }, "Region": { "Code": "BC", "Name": "British Columbia" }, "SubRegion": { "Name": "Metro Vancouver" }, "Locality": "Surrey", "District": "South Surrey", "PostalCode": "V3Z 0R5", "Street": "24 Ave", "StreetComponents": [ { "BaseName": "24", "Type": "Ave", "TypePlacement": "AfterBaseName", "TypeSeparator": " ", "Language": "en" } ], "AddressNumber": "16010" }, "Position": [ -122.77867, 49.04482 ], "Distance": 5422, "Categories": [ { "Id": "coffee_shop", "Name": "Coffee Shop", "LocalizedName": "Coffee Shop", "Primary": true } ] }, { "PlaceId": "<Redacted>", "PlaceType": "PointOfInterest", "Title": "STARBUCKS", "Address": { "Label": "STARBUCKS, 1730 152 St, Surrey, BC V4A 4N4, Canada", "Country": { "Code2": "CA", "Code3": "CAN", "Name": "Canada" }, "Region": { "Code": "BC", "Name": "British Columbia" }, "SubRegion": { "Name": "Metro Vancouver" }, "Locality": "Surrey", "District": "South Surrey", "PostalCode": "V4A 4N4", "Street": "152 St", "StreetComponents": [ { "BaseName": "152", "Type": "St", "TypePlacement": "AfterBaseName", "TypeSeparator": " ", "Language": "en" } ], "AddressNumber": "1730" }, "Position": [ -122.80096, 49.03341 ], "Distance": 5517, "Categories": [ { "Id": "coffee_shop", "Name": "Coffee Shop", "LocalizedName": "Coffee Shop", "Primary": true } ], "BusinessChains": [ { "Name": "Starbucks", "Id": "Starbucks" } ] }, ... ... ] } - cURL
-
curl --request POST \ --url 'https://places.geo.eu-central-1.amazonaws.com/v2/search-text?key=Your_Key' \ --header 'Content-Type: application/json' \ --data '{ "QueryText": "Starbucks", "BiasPosition": [ -122.741803, 49.002478 ] }' - AWS CLI
-
aws geo-places search-text --key ${YourKey} --query-text "Starbucks" --bias-position -122.741803 49.002478
搜索地址
搜索联系方式和营业时间