如何搜尋國家/地區內的地點 - Amazon Location Service

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

如何搜尋國家/地區內的地點

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