フィルターを使用してジオコーディングする方法 - Amazon Location Service

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

フィルターを使用してジオコーディングする方法

Geocode API を使用すると、フィルターを使用して必要な結果を取得できます。

想定される用途

フィルターを使用して、ビジネスニーズに基づいて結果を制限します。

IncludeCountries の値を指定すると、その国の結果の値が返されます。

Sample request

IncludeCountries": ["USA"] を使用しない場合、Geocode API はカナダのブリティッシュコロンビア、バンクーバーを返します。

{ "QueryText": "Vancouver", "Filter" : { "IncludeCountries": ["USA"] } }
Sample response
{ "ResultItems": [ { "PlaceId": "<Redacted>", "PlaceType": "Locality", "Title": "Vancouver, WA, United States", "Address": { "Label": "Vancouver, WA, United States", "Country": { "Code2": "US", "Code3": "USA", "Name": "United States" }, "Region": { "Code": "WA", "Name": "Washington" }, "SubRegion": { "Name": "Clark" }, "Locality": "Vancouver", "PostalCode": "98660" }, "Position": [ -122.67156, 45.63248 ], "MapView": [ -122.77466, 45.57714, -122.46451, 45.69803 ], "MatchScores": { "Overall": 1, "Components": { "Address": { "Locality": 1 } } } } ] }
cURL
curl --request POST \ --url 'https://places.geo.eu-central-1.amazonaws.com/v2/geocode?key=Your_Key' \ --header 'Content-Type: application/json' \ --data '{ "QueryText": "Vancouver", "Filter" : { "IncludeCountries": ["USA"] } }'
AWS CLI
aws geo-places geocode --key ${YourKey} --query-text "Vancouver" --filter '{"IncludeCountries": ["USA"]}'

IncludePlaceTypes の値を指定すると、その場所の結果の値が返されます。

Sample request

IncludePlaceTypes": ["Street"] がない場合、Geocode API は国であるジョージアを返します。CANUSA の値で "IncludeCountries" を追加して結果をさらに絞り込み、結果を比較できます。

{ "QueryText": "Georgia", "Filter" : { "IncludePlaceTypes": ["Street"] } }
Sample response
{ "ResultItems": [ { "PlaceId": "<Redacted>", "PlaceType": "Street", "Title": "Georgia, Benito Juárez, CDMX, México", "Address": { "Label": "Georgia, Benito Juárez, CDMX, México", "Country": { "Code2": "MX", "Code3": "MEX", "Name": "México" }, "Region": { "Code": "CDMX", "Name": "Ciudad de México" }, "SubRegion": { "Name": "Ciudad de México" }, "Locality": "Benito Juárez", "Street": "Georgia", "StreetComponents": [ { "BaseName": "Georgia", "Language": "es" } ] }, "Position": [ -99.17754, 19.38887 ], "MapView": [ -99.18133, 19.38755, -99.17374, 19.39016 ], "MatchScores": { "Overall": 1, "Components": { "Address": { "Intersection": [ 1 ] } } } } ] }
cURL
curl --request POST \ --url 'https://places.geo.eu-central-1.amazonaws.com/v2/geocode?key=Your_Key' \ --header 'Content-Type: application/json' \ --data '{ "QueryText": "Georgia", "Filter" : { "IncludePlaceTypes": ["Street"] } }'
AWS CLI
aws geo-places geocode --key ${YourKey} --query-text "Georgia" --filter '{"IncludePlaceTypes": ["Street"]}'

デベロッパー向けのヒント

住所のジオコーディングでは、国や場所などのバイアス位置を組み合わせた完全な住所またはクエリコンポーネントを使用するようにしてください。詳細については住所をジオコーディングする方法を参照してください。