如何从 HERE API 获取给定城市的给定半径内的所有城市?
How can I get all cities within a given radius of a given city from the HERE API?
我需要能够使用此处给出给定半径内的 City/State 或邮政编码和整数 return 所有 cities/postal 代码,但文档似乎不清楚。
https://geocoder.api.here.com/6.2/reversegeocode.json?app_id=xxx&app_code=xxxx
return是:
<ns2:Error xmlns:ns2="http://www.navteq.com/lbsp/Errors/1" type="PermissionError" subtype="InvalidCredentials">
<Details>invalid credentials for xxxxxxx</Details>
</ns2:Error>
但是当我使用
https://geocoder.api.here.com/6.2/geocode.json?app_id=xxx&app_code=xxxx
我取回数据。
值得一提的是,我正在使用 REST 的免费增值套餐 API
首先,为什么我不能从反向地理代码中获取数据 API?
完成上述操作的合适字符串是什么?
更新:
剩下的留在这里以防其他人遇到这个问题。要使用反向地理编码,API 路线实际上是
https://reverse.geocoder.api.here.com/6.2/reversegeocode.json
虽然我仍然需要一些关于如何获取半径数据的帮助
更新二:
https://reverse.geocoder.api.here.com/6.2/reversegeocode.json?app_id=x&app_code=x&level=city&mode=retrieveAreas&prox=52.5309,13.3847,80467.2
Returns:
{
"Response": {
"MetaInfo": {
"Timestamp": "2019-04-27T17:47:41.043+0000"
},
"View": [
{
"_type": "SearchResultsViewType",
"ViewId": 0,
"Result": [
{
"Relevance": 1,
"Distance": 0,
"Direction": 0,
"MatchLevel": "district",
"MatchQuality": {
"Country": 1,
"State": 1,
"County": 1,
"City": 1,
"District": 1,
"PostalCode": 1
},
"Location": {
"LocationId": "NT_0ES-GaH3lZzJCuLQBrdw7C",
"LocationType": "point",
"DisplayPosition": {
"Latitude": 52.5309,
"Longitude": 13.3847
},
"MapView": {
"TopLeft": {
"Latitude": 52.54063,
"Longitude": 13.36566
},
"BottomRight": {
"Latitude": 52.50407,
"Longitude": 13.42964
}
},
"Address": {
"Label": "Mitte, Berlin, Deutschland",
"Country": "DEU",
"State": "Berlin",
"County": "Berlin",
"City": "Berlin",
"District": "Mitte",
"PostalCode": "10178",
"AdditionalData": [
{
"value": "Deutschland",
"key": "CountryName"
},
{
"value": "Berlin",
"key": "StateName"
},
{
"value": "Berlin",
"key": "CountyName"
}
]
},
"MapReference": {
"ReferenceId": "53500282",
"SideOfStreet": "neither",
"CountryId": "20147700",
"StateId": "20187401",
"CountyId": "20187402",
"CityId": "20187403",
"DistrictId": "20187417"
}
}
}
]
}
]
}
}
文档说要输入坐标和半径,即 50 英里,所以不确定为什么我在响应中只收到柏林 1 个城市。
更新 3:
https://reverse.geocoder.api.here.com/6.2/multi-reversegeocode.json?app_id=x&app_code=x&level=city&mode=retrieveAreas&prox=60.5544,-151.2583,80000
尝试过 multi-reversegeocode
Return 是:{}
获取邻近半径内的城市
使用具有以下参数的反向地理编码端点
https://reverse.geocoder.api.here.com/6.2/reversegeocode.json?
prox=52.5309,13.3847,80500 /* Note: 80.5 km around Berlin */
&app_id=YOUR_APP_ID
&app_code=YOUR_APP_CODE
&mode=retrieveAreas
&level=city
&gen=9
简而言之,您在“更新 2”中的示例是正确的,此外它缺少 gen
查询参数。实际上,根据 API Reference,查询参数 level
仅在与 gen=2
或更高组合时有效。
我需要能够使用此处给出给定半径内的 City/State 或邮政编码和整数 return 所有 cities/postal 代码,但文档似乎不清楚。
https://geocoder.api.here.com/6.2/reversegeocode.json?app_id=xxx&app_code=xxxx
return是:
<ns2:Error xmlns:ns2="http://www.navteq.com/lbsp/Errors/1" type="PermissionError" subtype="InvalidCredentials">
<Details>invalid credentials for xxxxxxx</Details>
</ns2:Error>
但是当我使用
https://geocoder.api.here.com/6.2/geocode.json?app_id=xxx&app_code=xxxx
我取回数据。
值得一提的是,我正在使用 REST 的免费增值套餐 API
首先,为什么我不能从反向地理代码中获取数据 API?
完成上述操作的合适字符串是什么?
更新:
剩下的留在这里以防其他人遇到这个问题。要使用反向地理编码,API 路线实际上是
https://reverse.geocoder.api.here.com/6.2/reversegeocode.json
虽然我仍然需要一些关于如何获取半径数据的帮助
更新二:
https://reverse.geocoder.api.here.com/6.2/reversegeocode.json?app_id=x&app_code=x&level=city&mode=retrieveAreas&prox=52.5309,13.3847,80467.2
Returns:
{
"Response": {
"MetaInfo": {
"Timestamp": "2019-04-27T17:47:41.043+0000"
},
"View": [
{
"_type": "SearchResultsViewType",
"ViewId": 0,
"Result": [
{
"Relevance": 1,
"Distance": 0,
"Direction": 0,
"MatchLevel": "district",
"MatchQuality": {
"Country": 1,
"State": 1,
"County": 1,
"City": 1,
"District": 1,
"PostalCode": 1
},
"Location": {
"LocationId": "NT_0ES-GaH3lZzJCuLQBrdw7C",
"LocationType": "point",
"DisplayPosition": {
"Latitude": 52.5309,
"Longitude": 13.3847
},
"MapView": {
"TopLeft": {
"Latitude": 52.54063,
"Longitude": 13.36566
},
"BottomRight": {
"Latitude": 52.50407,
"Longitude": 13.42964
}
},
"Address": {
"Label": "Mitte, Berlin, Deutschland",
"Country": "DEU",
"State": "Berlin",
"County": "Berlin",
"City": "Berlin",
"District": "Mitte",
"PostalCode": "10178",
"AdditionalData": [
{
"value": "Deutschland",
"key": "CountryName"
},
{
"value": "Berlin",
"key": "StateName"
},
{
"value": "Berlin",
"key": "CountyName"
}
]
},
"MapReference": {
"ReferenceId": "53500282",
"SideOfStreet": "neither",
"CountryId": "20147700",
"StateId": "20187401",
"CountyId": "20187402",
"CityId": "20187403",
"DistrictId": "20187417"
}
}
}
]
}
]
}
}
文档说要输入坐标和半径,即 50 英里,所以不确定为什么我在响应中只收到柏林 1 个城市。
更新 3:
https://reverse.geocoder.api.here.com/6.2/multi-reversegeocode.json?app_id=x&app_code=x&level=city&mode=retrieveAreas&prox=60.5544,-151.2583,80000
尝试过 multi-reversegeocode
Return 是:{}
获取邻近半径内的城市
使用具有以下参数的反向地理编码端点
https://reverse.geocoder.api.here.com/6.2/reversegeocode.json?
prox=52.5309,13.3847,80500 /* Note: 80.5 km around Berlin */
&app_id=YOUR_APP_ID
&app_code=YOUR_APP_CODE
&mode=retrieveAreas
&level=city
&gen=9
简而言之,您在“更新 2”中的示例是正确的,此外它缺少 gen
查询参数。实际上,根据 API Reference,查询参数 level
仅在与 gen=2
或更高组合时有效。