4.6.201909161536 • Published 5 years ago
@dfeidao/fd-am000040 v4.6.201909161536
逆地理编码查询
Installation
yarn add --dev @dfeidao/fd-am000040
Description
根据传入的坐标位置的经度与纬度来获取当前坐标的地址信息。
param
属性 | 描述 |
---|---|
key | 方案提供从天地图申请的key |
longitude | 坐标的经度 |
latitude | 坐标的纬度 |
result
// 传入精确经纬度
{
"formatted_address": "郑州市黄河路19中国联通郑州联通社区营销中心",// 详细地址
"location": {
"lon": 113.669548, // 经度
"lat": 34.775848 // 纬度
},
"addressComponent": {
"address": "黄河路19", // 此点最近地点信息
"city": "郑州市", // 此点所在国家或城市或区县
"county_code": "156410105",
"nation": "中国",
"poi_position": "东北", // 此点在最近poi点的方向
"county": "金水区",
"city_code": "156410100",
"address_position": "东北", // 此点在最近地点信息方向
"poi": "中国联通郑州联通社区营销中心", // 距离此点最近poi点
"province_code": "156410000",
"province": "河南省",
"road": "黄河路", // 距离此点最近的路
"road_distance": 22, // 此点距离此路的距离
"poi_distance": "13", // 距离此点最近poi点的距离
"address_distance": 13 // 此点距离最近地点信息距离
}
}
// 传入不精确经纬度
{
"formatted_address": "",
"location": {
"lon": 21.3584154,
"lat": 32.486549
},
"addressComponent": {
"address": "迈拉沃",
"city": "",
"county_code": "",
"nation": "利比亚",
"poi_position": "西北",
"county": "",
"city_code": "",
"address_position": "西北",
"poi": "迈拉沃",
"province_code": "",
"province": "",
"poi_distance": "4434",
"address_distance": 4434,
"info": "未找到最近的道路或距离太远"
}
}
result-error
string
错误信息 | 异常原因 |
---|---|
服务器内部异常 | 经纬度大于等于180 |
非法Key | 非法Key |
经纬度值有误 | 经纬度有值为0 |
Network request failed | 无网 |
Example
import am040 from '@dfeidao/fd-am000040'
export default async function a001(fd: IFeidaoAiMobile) {
try{
const res = await am040('test-key', '113.669548', '32.486549');
}catch(e){
// 错误信息
const error = e.message;
}
}