Appearance
地理编码 API
地理编码API提供了地址与经纬度坐标互相转换的功能,包括正向地理编码(地址转坐标)和逆向地理编码(坐标转地址)。
地理编码 API
接口描述
将地址信息转换为结构化的地理位置信息(经纬度等)。
请求方式
| URL | 请求方式 |
|---|---|
| https://lbs.xiaojukeji.com/api/v2/geocode | POST、GET |
请求
查询参数(GET)
| 参数名 | 必选 | 类型 | 描述 | 示例值 |
|---|---|---|---|---|
| key | 是 | string | 鉴权用的 API Key | YOUR_API_KEY |
| address | 是 | string | 地址信息 | 北京市海淀区西二旗东路1号 |
| city | 是 | string | 城市名称 | 北京市 |
请求体参数(POST)
当使用POST方法时,请求体应为 GeocodeRequest 模型的JSON格式。
请求示例
GET
shell
curl -X GET "https://lbs.xiaojukeji.com/api/v2/geocode?key=YOUR_API_KEY&address=北京市海淀区西二旗东路1号&city=北京市"POST
shell
curl -X POST "https://lbs.xiaojukeji.com/api/v2/geocode?key=YOUR_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"address": "北京市海淀区西二旗东路1号",
"city": "北京市"
}'响应
成功响应为 GeocodeRPCResponse 模型的JSON格式。
响应示例
json
{
"status": 10000,
"msg": "OK",
"trace_id": "0aaca55168cbb1b682bfc0c73a9c8a02",
"results": {
"count": 1,
"geocodes": [
{
"country": "中国",
"province": "北京市",
"city": "北京市",
"district": "海淀区",
"adcode": "110108",
"location": {
"lng": 116.303067,
"lat": 40.054749
},
"poi_id": "244088785252014266501395416315697346744"
}
]
}
}逆地理编码 API
接口描述
将经纬度坐标转换为结构化的地址信息,可获取坐标点所在的道路、门牌号、区域等信息。
请求方式
| URL | 请求方式 |
|---|---|
| https://lbs.xiaojukeji.com/api/v2/reversegeo | POST、GET |
请求
查询参数(GET)
| 参数名 | 必选 | 类型 | 描述 | 示例值 |
|---|---|---|---|---|
| key | 是 | string | 鉴权用的 API Key | YOUR_API_KEY |
| location | 是 | string | 坐标,经纬度,格式"lng,lat" | 116.424790,39.956953 |
请求体参数(POST)
当使用POST方法时,请求体应为 ReverseGeoRequest 模型的JSON格式。
请求示例
GET
shell
curl -X GET "https://lbs.xiaojukeji.com/api/v2/reversegeo?key=YOUR_API_KEY&location=116.437006,39.868578"POST
shell
curl -X POST "https://lbs.xiaojukeji.com/api/v2/reversegeo?key=YOUR_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"location": "116.437006,39.868578"
}'响应
成功响应为包含地址信息的JSON格式,主要返回 ReverseGeoRes 类型的数据。
响应示例
json
{
"status": 10000,
"msg": "OK",
"trace_id": "0aaca55168cbb17482bfc0c73a9bd802",
"results": [
{
"name": "北京丰台体坛中医医院-南3门",
"location": {
"lng": 116.437006,
"lat": 39.868578
},
"address": "北京市丰台区芳城路",
"city": "北京市",
"district": "丰台区",
"adcode": "110106",
"address_all": "北京市丰台区芳城路北京丰台体坛中医医院-南3门",
"province": "北京市",
"poi_id": "212624531042832046403573813650552619853"
}
]
}