开发者可以通过该功能,获取货车etc费用。
货车etc费用为高级付费服务,需要开通高级权限,您也可以查看您可使用的服务
如果您已开通了该服务,运行返回结果中将返回货车etc费用
https://api.map.baidu.com/logistics_direction/v1/truck?origin=22.673186,114.065699&destination=22.6721,114.068886&height=1.8&width=1.9&weight=2.5&length=4.2&axle_weight=2&axle_count=2&is_trailer=0&plate_province=&plate_number=&plate_color=0&ak=你的ak
//get请求
字段名称 | 类型 | 备注 | ||
---|---|---|---|---|
toll | int32 | 此路线道路收费,单位:元。注:该字段为高级付费服务,需通过联系工作人员开通 | ||
toll_distance | double | 收费路段里程,单位:米。注意:该字段为高级付费服务,需通过联系工作人员开通 | ||
steps | ||||
toll_gate_name | string | 收费站名称注意:收费站名称为高级付费服务,需通过联系工作人员开通 | ||
toll_gate_location | ||||
lng | double | 收费站位置:经度。注意:该字段为高级付费服务,需通过联系工作人员开通 | ||
lat | double | 收费站位置:纬度。注意:该字段为高级付费服务,需通过联系工作人员开通 |
输入ak可生成包含ip/sn校验方式的代码
<?php// 此处填写你在控制台-应用管理-创建应用后获取的ak$ak ='您的ak';// 发起一个http get请求,并返回请求的结果// $url字段为请求的地址// $param字段为请求的参数functionrequest_get($url ='', $param =array()){if(empty($url)||empty($param)){returnfalse;}$geturl = $url ."?".http_build_query($param);$curl =curl_init();// 初始化curlcurl_setopt($curl,curlopt_ssl_verifypeer,false);// 跳过证书检查curl_setopt($curl,curlopt_ssl_verifyhost,2);// 从证书中检查ssl加密算法是否存在curl_setopt($curl,curlopt_url, $geturl);// 抓取指定网页curl_setopt($curl,curlopt_timeout,1000);// 设置超时时间1秒curl_setopt($curl,curlopt_returntransfer,1);// curl不直接输出到屏幕curl_setopt($curl,curlopt_header,0);// 设置header$data =curl_exec($curl);// 运行curlif(!$data){print("an error occured in function request_get(): ".curl_error($curl)."\n");}curl_close($curl);return $data;}// 请求地址$url ='https://api.map.baidu.com/logistics_direction/v1/truck';// 构造请求参数$param['origin']='22.673186,114.065699';$param['destination']='22.6721,114.068886';$param['height']='1.8';$param['width']='1.9';$param['weight']='2.5';$param['length']='4.2';$param['axle_weight']='2';$param['axle_count']='2';$param['is_trailer']='0';$param['plate_province']='';$param['plate_number']='';$param['plate_color']='0';$param['ak']= $ak;$res =request_get($url, $param);// 将原始返回的结果打印出来print("请求的原始返回结果为:\n");print($res ."\n");?>
{"status":0,"message":"ok","result":{"restriction":{"type":"0","info":""},"total":1,"routes":[{"origin":{"lng":114.06571601088974,"lat":22.67317578337568},"destination":{"lng":114.06883474382559,"lat":22.672117710702736},"tag":"默认","distance":880,"duration":264,"toll":0,"toll_distance":0,"steps":[{"leg_index":0,"direction":7,"distance":216,"road_name":"清祥路","road_type":4,"toll_distance":0,"toll_gate_location":{"lng":0,"lat":0},"start_location":{"lng":114.06571601088974,"lat":22.67317578337568},"end_location":{"lng":114.06503442048037,"lat":22.671346252553548},"path":"114.065716,22.6731758;114.065506,22.6726359;114.065435,22.6724659;114.065385,22.672326;114.065235,22.6718961;114.065225,22.6718661;114.065175,22.6717461;114.065034,22.6713463","traffic_condition":[{"status":1,"geo_cnt":7,"distance":216}],"restrictions":[{}],"duration":50,"adcodes":"440309","turn":1,"instructions":"请直行,进入清祥路","camera":[{}],"lane":[{}],"trafficsign":[{}],"road_attr":[{}],"intersections":[{}]},{"leg_index":0,"direction":7,"distance":52,"road_name":"清祥路","road_type":4,"toll_distance":0,"toll_gate_location":{"lng":0,"lat":0},"start_location":{"lng":114.06503442048037,"lat":22.671346252553548},"end_location":{"lng":114.06498411443144,"lat":22.67095626741058},"path":"114.065034,22.6713463;114.064934,22.6711064;114.064894,22.6709864;114.064984,22.6709563","traffic_condition":[{"status":1,"geo_cnt":3,"distance":52}],"restrictions":[{}],"duration":30,"adcodes":"440309,440307","turn":35,"instructions":"靠左前方直行,沿清祥路继续行驶","camera":[{}],"lane":[{}],"trafficsign":[{}],"road_attr":[{}],"intersections":[{}]},{"leg_index":0,"direction":4,"distance":118,"road_name":"环城路","road_type":3,"toll_distance":0,"toll_gate_location":{"lng":0,"lat":0},"start_location":{"lng":114.06498411443144,"lat":22.67095626741058},"end_location":{"lng":114.06596391717336,"lat":22.670415194262233},"path":"114.064984,22.6709563;114.065264,22.6708159;114.065964,22.6704152","traffic_condition":[{"status":1,"geo_cnt":2,"distance":118}],"restrictions":[{}],"duration":71,"adcodes":"440307","turn":7,"instructions":"左转,进入环城路","camera":[{}],"lane":[{}],"trafficsign":[{}],"road_attr":[{}],"intersections":[{}]},{"leg_index":0,"direction":4,"distance":69,"road_name":"环城路","road_type":3,"toll_distance":0,"toll_gate_location":{"lng":0,"lat":0},"start_location":{"lng":114.06596391717336,"lat":22.670415194262233},"end_location":{"lng":114.06647375599361,"lat":22.67014499432073},"path":"114.065964,22.6704152;114.066284,22.670165;114.066414,22.670075;114.066474,22.670145","traffic_condition":[{"status":1,"geo_cnt":3,"distance":69}],"restrictions":[{}],"duration":44,"adcodes":"440307","turn":35,"instructions":"靠左前方直行,沿环城路继续行驶","camera":[{}],"lane":[{}],"trafficsign":[{}],"road_attr":[{}],"intersections":[{}]},{"leg_index":0,"direction":1,"distance":268,"road_name":"五和大道","road_type":3,"toll_distance":0,"toll_gate_location":{"lng":0,"lat":0},"start_location":{"lng":114.06647375599361,"lat":22.67014499432073},"end_location":{"lng":114.06812492008547,"lat":22.672016417426942},"path":"114.066474,22.670145;114.066664,22.670365;114.067394,22.6712055;114.068095,22.6719964;114.068125,22.6720164","traffic_condition":[{"status":1,"geo_cnt":4,"distance":268}],"restrictions":[{}],"duration":36,"adcodes":"440307","turn":7,"instructions":"左转,进入五和大道","camera":[{}],"lane":[{}],"trafficsign":[{}],"road_attr":[{}],"intersections":[{}]},{"leg_index":0,"direction":4,"distance":112,"road_name":"","road_type":6,"toll_distance":0,"toll_gate_location":{"lng":0,"lat":0},"start_location":{"lng":114.06812492008547,"lat":22.672016417426942},"end_location":{"lng":114.06910443577772,"lat":22.671878283021133},"path":"114.068125,22.6720164;114.068215,22.6719865;114.068974,22.671758;114.069104,22.6718783","traffic_condition":[{"status":0,"geo_cnt":3,"distance":112}],"restrictions":[{}],"duration":18,"adcodes":"440307","turn":3,"instructions":"右转","camera":[{}],"lane":[{}],"trafficsign":[{}],"road_attr":[{}],"intersections":[{}]},{"leg_index":0,"direction":11,"distance":45,"road_name":"","road_type":6,"toll_distance":0,"toll_gate_location":{"lng":0,"lat":0},"start_location":{"lng":114.06910443577772,"lat":22.671878283021133},"end_location":{"lng":114.06883474382559,"lat":22.672117710702736},"path":"114.069104,22.6718783;114.068875,22.6720178;114.068815,22.6720877;114.068835,22.6721177","traffic_condition":[{"status":0,"geo_cnt":3,"distance":45}],"restrictions":[{}],"duration":5,"adcodes":"440307","turn":7,"instructions":"左转","camera":[{}],"lane":[{}],"trafficsign":[{}],"road_attr":[{}],"intersections":[{}]}],"oil_cost":0.46,"track_idx":-1,"unavoid_polygons_idx":"","unavoid_statistics":{"height":0,"width":0,"weight":0,"plate":0,"road_to_open":0,"road_not_open":0},"traffic_light_num":2,"route_id":"imcioii2m18xiiwibyi6ijexnda1ote0ldiynjy3ntmilcj3ijoiqufbqsisimxhymvsijoiocisinnlcsi6ijai"}],"routesinfo_ext":"eyjzzxnzaw9ux2lkijoiiiwibg9jijoiz3oilcj0cmfja3b0c19kaxn0yw5jzxmiols4odbdfq"}}
参数 | 值 | 备注 | 必选 |
---|---|---|---|
origin | 22.673186,114.065699 | 是 | |
destination | 22.6721,114.068886 | 是 | |
height | 1.8 | 否 | |
width | 1.9 | 否 | |
weight | 2.5 | 否 | |
length | 4.2 | 否 |
上一篇
下一篇
本篇文章对您是否有帮助?