官方接口地址:lbs.qq.com/webservice_…
特点:可分页,可配合前端实现搜索地址联想功能
代码:
/**
* @param string $region 限制城市范围:如,仅获取“广州市”范围内的提示内容
* @param string $keyword 用户输入的关键词(希望获取后续提示的关键词)
* @param string $lng 定位坐标 中心点 经度
* @param string $lat 定位坐标 中心点 纬度
* @param int $page_index 分页 当前页
* @param int $page_size 分页 每页数量
* @return mixed
*/
function searchAddress($region,$keyword,$lng,$lat,$page_index=1,$page_size=10){
$key = '';//腾讯地图 key
$url = 'https://apis.map.qq.com/ws/place/v1/suggestion/?region='.$region.'&keyword='.$keyword.'&key='.$key.'&page_index='.$page_index.'&page_size='.$page_size.'&location='.$lat.','.$lng;
$result = file_get_contents($url);
$array = json_decode($result, true);
return $array;
}