官方地址:https://lbs.qq.com/webservice_v1/guide-road.html
本文章借助腾讯地图接口实现,需提前准备好腾讯地图key值。
public function ceshi(){ $form = '39.087054,117.128543'; $to = '39.118621,117.197613'; $data = $this->planning($form,$to); dump($data); } /** * 路线规划 * @param $form 起点 * @param $to 终点 * @param string $type 驾车(driving) 步行(walking) 骑行(bicycling) 公交(transit) * @return mixed */ public function planning($form,$to,$type='driving'){ $url = "https://apis.map.qq.com/ws/direction/v1/$type/?"; $param = [ 'from'=>$form,//lat,lng 'to'=>$to, 'key'=>'',//腾讯地图key ]; $res = file_get_contents($url.http_build_query($param)); return json_decode($res,true); }复制代码
运行结果如图,具体参数细节参考官方文档