腾讯地图接口,根据关键字搜索附近地址

官方接口地址: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; }复制代码

文章转载自 https://www.juchengvi.com/looknews/49

原文地址:https://www.cnblogs.com/jucheng/p/12515774.html