坐标位置描述
腾讯地图 官方文档
本接口提供由坐标到坐标所在位置的文字描述的转换
基本说明:
接口地址:https://apis.map.qq.com/ws/geocoder/v1
返回格式:json/jsonp
请求方式:get
请求示例:https://apis.map.qq.com/ws/geocoder/v1/?location=39,116&key=yourkey&get_poi=1
请求参数说明:
名称 类型 必填 说明
key string 必填 开发密钥 扫码关注公众号
location string 必填 位置坐标
get_poi string 选填 是否返回周边POI列表: 1.返回;0不返回(默认) get_poi=1 poi_options 否 用于控制POI列表: 1 poi_options=address_format=short 返回短地址,缺省时返回长地址 2 poi_options=radius=5000 半径,取值范围 1-5000(米) 3 poi_options=page_size=20 每页条数,取值范围 1-20 4 poi_options=page_index=1 页码,取值范围 1-20 注:分页时page_size与page_index参数需要同时使用 5 poi_options=policy=1/2/3/4/5 控制返回场景, policy=1[默认] 以地标+主要的路+近距离POI为主,着力描述当前位置; policy=2 到家场景:筛选合适收货的POI,并会细化收货地址,精确到楼栋; policy=3 出行场景:过滤掉车辆不易到达的POI(如一些景区内POI),增加道路出入口、交叉口、大区域出入口类POI,排序会根据真实API大用户的用户点击自动优化。 policy=4 社交签到场景,针对用户签到的热门地点进行优先排序。 policy=5 位置共享场景,用户经常用于发送位置、位置分享等场景的热门地点优先排序 6 poi_options=category=分类词1
output string 选填 返回格式:支持JSON/JSONP,默认JSON
callback string 选填 JSONP方式回调函数
返回参数说明:
名称 类型 说明
- - -
JSON返回示例:
{
	"status": 0,
	"message": "query ok",
	"request_id": "359e82fc-46ed-11ea-a19e-28c13c908b77",
	"result": {
		"location": {
			"lat": 39.984154,
			"lng": 116.30749
		},
		"address": "北京市海淀区北四环西路66号",
		"formatted_addresses": {
			"recommend": "海淀区中关村中国技术交易大厦(彩和坊路)",
			"rough": "海淀区中关村中国技术交易大厦(彩和坊路)"
		},
		"address_component": {
			"nation": "中国",
			"province": "北京市",
			"city": "北京市",
			"district": "海淀区",
			"street": "北四环西路",
			"street_number": "北四环西路66号"
		},
		"ad_info": {
			"nation_code": "156",
			"adcode": "110108",
			"city_code": "156110000",
			"name": "中国,北京市,北京市,海淀区",
			"location": {
				"lat": 40.045132,
				"lng": 116.375
			},
			"nation": "中国",
			"province": "北京市",
			"city": "北京市",
			"district": "海淀区"
		},
		"address_reference": {
			"business_area": {
				"id": "14178584199053362783",
				"title": "中关村",
				"location": {
					"lat": 39.980598,
					"lng": 116.310997
				},
				"_distance": 0,
				"_dir_desc": "内"
			},
			"famous_area": {
				"id": "14178584199053362783",
				"title": "中关村",
				"location": {
					"lat": 39.980598,
					"lng": 116.310997
				},
				"_distance": 0,
				"_dir_desc": "内"
			},
			"crossroad": {
				"id": "529981",
				"title": "彩和坊路/北四环西路辅路(路口)",
				"location": {
					"lat": 39.985001,
					"lng": 116.308113
				},
				"_distance": 102.8,
				"_dir_desc": "西南"
			},
			"town": {
				"id": "110108012",
				"title": "海淀街道",
				"location": {
					"lat": 39.974819,
					"lng": 116.284409
				},
				"_distance": 0,
				"_dir_desc": "内"
			},
			"street_number": {
				"id": "6996505596656075740",
				"title": "北四环西路66号",
				"location": {
					"lat": 39.984119,
					"lng": 116.307503
				},
				"_distance": 1.7,
				"_dir_desc": ""
			},
			"street": {
				"id": "9217092216709107946",
				"title": "彩和坊路",
				"location": {
					"lat": 39.97921,
					"lng": 116.308411
				},
				"_distance": 46.6,
				"_dir_desc": "西"
			},
			"landmark_l2": {
				"id": "3629720141162880123",
				"title": "中国技术交易大厦",
				"location": {
					"lat": 39.984104,
					"lng": 116.307503
				},
				"_distance": 0,
				"_dir_desc": "内"
			}
		},
		"poi_count": 10,
		"pois": [{
			"id": "13496299173191724318",
			"title": "泰鹏大厦",
			"address": "北京市海淀区海淀北二街10号",
			"category": "房产小区:商务楼宇",
			"location": {
				"lat": 39.983551,
				"lng": 116.308899
			},
			"ad_info": {
				"adcode": "110108",
				"province": "北京市",
				"city": "北京市",
				"district": "海淀区"
			},
			"_distance": 73,
			"_dir_desc": "西北"
		}]
	}
}
服务级错误码参照
错误码 说明
310 请求参数信息有误
311 Key格式错误
306 请求有护持信息请检查字符串
110 请求来源未被授权
完整教学代码示例
<?php
class freeApi{
    private $apiUrl;
    private $appKey;

    public function __construct($appKey){
        $this->appKey = $appKey;
        $this->apiUrl = 'https://apis.map.qq.com/ws/geocoder/v1';
    }
    /**
     * 获取结果
     * @return string
     */
    public function getResult(){
        $paras = [
            'key' => $this->appKey,
            'keyword' => 'KFC',
            'region' => '北京'
        ];
        return $this->freeApiCurl($this->apiUrl,$paras);
    }
    /**
     * 请求接口返回内容
     * @param  string $url [请求的URL地址]
     * @param  string $params [请求的参数]
     * @return  string
     */
    public function freeApiCurl($url,$params=[]){
        if (!$params) return false;
        return file_get_contents($url.'?'.http_build_query($params));
    }
}
package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

const (
	APIURL   = "https://apis.map.qq.com/ws/geocoder/v1"
	APIKEY = "your key"
)

func main() {
	queryUrl := fmt.Sprintf("%s?key=%s&location=39,116&get_poi=1",APIURL,APIKEY)
	resp, err := http.Get(queryUrl)
	if err != nil {
		log.Println(err)
		return
	}

	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)

	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(string(body))
}