本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
如何对某个位置进行反向地理编码
反向地理编码 API 允许您根据位置查询将地理编码转换为地理区域。API 响应包含地点详情,提供与特定坐标关联的位置的相关信息。
潜在用例
-
存储地点信息:将地点详细信息添加到包含地理坐标的数据存储中。
-
地图可视化:使用地点信息在地图上显示数据。
-
用户位置检测:根据用户设备位置识别用户的位置。
- Sample request
-
{ "QueryPosition": [ -123.11694, 49.28126 ] }
- Sample response
-
{ "ResultItems": [ { "PlaceId": "<Redacted>", "PlaceType": "PointAddress", "Title": "510 W Georgia St, Vancouver, BC V6B 0M3, Canada", "Address": { "Label": "510 W Georgia St, Vancouver, BC V6B 0M3, Canada", "Country": { "Code2": "CA", "Code3": "CAN", "Name": "Canada" }, "Region": { "Code": "BC", "Name": "British Columbia" }, "SubRegion": { "Name": "Metro Vancouver" }, "Locality": "Vancouver", "District": "Downtown Vancouver", "PostalCode": "V6B 0M3", "Street": "W Georgia St", "StreetComponents": [ { "BaseName": "Georgia", "Type": "St", "TypePlacement": "AfterBaseName", "TypeSeparator": " ", "Prefix": "W", "Language": "en" } ], "AddressNumber": "510" }, "Position": [-123.11694, 49.28126], "Distance": 0, "MapView": [-123.11813, 49.27786, -123.11076, 49.28246], "AccessPoints": [ { "Position": [-123.11656, 49.28151] } ] } ] }
- cURL
-
curl --request POST \ --url 'https://places.geo.eu-central-1.amazonaws.com/v2/reverse-geocode?key=Your_Key' \ --header 'Content-Type: application/json' \ --data '{ "QueryPosition": [ -123.11694, 49.28126 ] }'
- AWS CLI
-
aws geo-places reverse-geocode --key ${YourKey} --query-position "-123.11694,49.28126"
- Sample request
-
{ "QueryPosition": [ -123.11694, 49.28126 ], "MaxResults": "3" }
- Sample response
-
{ "ResultItems": [ { "PlaceId": "<Redacted>", "PlaceType": "PointAddress", "Title": "510 W Georgia St, Vancouver, BC V6B 0M3, Canada", "Address": { /* Address details */ }, "Position": [-123.11694, 49.28126], "Distance": 0, "MapView": [/* Map view details */], "AccessPoints": [/* Access point details */] }, { "PlaceId": "<Redacted>", "PlaceType": "PointOfInterest", "Title": "ChargePoint", "Address": { /* Address details */ }, "Position": [-123.11663, 49.28116], "Distance": 25, "Categories": [/* Category details */], "AccessPoints": [/* Access point details */] }, { "PlaceId": "<Redacted>", "PlaceType": "PointOfInterest", "Title": "Zipcar", "Address": { /* Address details */ }, "Position": [-123.11715, 49.28094], "Distance": 29, "Categories": [/* Category details */], "AccessPoints": [/* Access point details */] } ] }
- cURL
-
curl --request POST \ --url 'https://places.geo.eu-central-1.amazonaws.com/v2/reverse-geocode?key=Your_Key' \ --header 'Content-Type: application/json' \ --data '{ "QueryPosition": [ -123.11694, 49.28126 ], "MaxResults": "3" }'
- AWS CLI
-
aws geo-places reverse-geocode --key ${YourKey} --query-position "-123.11694,49.28126" --max-results "3"
开发者小贴士
要获得目标结果,请在过滤器IncludePlaceTypes
中使用。
{ "QueryPosition": [ -123.11694, 49.28126 ], "Filter": { "IncludePlaceTypes": ["PointAddress"] } }
使用 ReverseGeocode
反向地理编码以获得正确的结果