接口说明
车联网API服务的各种能力后续将合并到Web API服务中。自2015年12月31日起,车联网API服务将不再向新用户提供服务支持。已有用户服务暂不受影响,请已使用了各种车联网API服务的开发者,尽快升级服务到Web API中使用。
根据传入的起终点,查询驾车路线方案。
接口示例
http://api.map.baidu.com/telematics/v3/navigation?origin=南京师范大学&destination=中国政法大学&origin_region=南京&destination_region=北京&ak=E4805d16520de693a3fe707cdc962045
接口参数设置
| 参数类型 | 参数名称 | 是否必须 | 具体描述 |
|---|---|---|---|
| String | ak | true | 开发者密钥 |
| String | sn | false | 若用户所用ak的校验方式为sn校验时该参数必须。 |
| String | origin | true | 起点名称或经纬度 |
| String | destination | true | 终点名称或经纬度 |
| String | region | 同城搜索时必填 | 城市名或县名,如:北京或者131,该参数设置后认为起点和终点都在同一城市,除非单独给定起点或终点的城市。 |
| String | origin_region | 跨城搜索时必填 | 起点所在城市或县如:北京或者131,当region设置值后可以不设置该项,主要在跨城搜索中使用,同城搜索建议使用region |
| String | destination_region | 跨城搜索时必填 | 终点所在城市或县,如:北京或者131,当region设置值后可以不设置该项,主要在跨城搜索中使用,同城搜索建议使用region |
| String | route_type | false | 最优策略,0:最少时间1:最短路程2:不走高速,默认为0最少时间 |
| String | waypoints | false | 西单, 途经点集合,包括一个或多个用竖线字符 "|" 分隔的地址名称或经纬度。 |
| String | output | false | 输出的数据格式,默认为xml格式,当output设置为’json’时,输出的为json格式的数据。 |
| String | coord_type | false | 请求参数坐标类型,默认为gcj02经纬度坐标。允许的值为bd09ll、bd09mc、gcj02、wgs84。bd09ll表示百度经纬度坐标,bd09mc表示百度墨卡托坐标,gcj02表示经过国测局加密的坐标。wgs84表示gps获取的坐标。 |
| String | out_coord_type | false | 返回结果输出时的坐标类型,默认为gcj02经纬度坐标。允许的值为bd09ll、bd09mc、gcj02。bd09ll表示百度经纬度坐标,bd09mc表示百度墨卡托坐标,gcj02表示经过国测局加密的坐标。 |
| String | callback | false | 将json格式的返回值通过callback函数返回以实现jsonp功能。举例:callback=showLocation(JavaScript函数名)。 |
返回结果
返回xml格式的数据
注:当起点和终点不够具体时,(如,起点为南京师范大学,而南京师范大学有多个校区)往往不能直接搜索到起点和终点间的驾车信息,代之会返回地点和终点的相关信息; 当搜索词为“青年路”,“民主路”等会出现在多个城市的地点时,也不能搜索到起点终点间的直接驾车路线,而会返回包含当前搜索词信息的城市列表;
1.1 非直跳时显示起点和终点的信息或城市列表
<DrivingRouteResponse> <status>Success</status> <returnType>19</returnType> //returnType为19时表示没有起点和终点之间直跳的驾车路线 <results> <origin> <listType>0</listType> //listType为0 表示,返回起点的详细信息 <cityName>南京市</cityName> <result> <name>南京师范大学</name> <address>文澜路</address> <telephone /> <location> <lng>118.91485517954</lng> <lat>32.109151649066</lat> </location> </result> </origin> <destination> // 终点的相关信息 <listType>1</listType> //listType为1 表示返回包含终点信息的城市列表 <result> <name>上海市</name> <number>75</number> </result> <result> <name>天津市</name> <number>3</number> </result> </destination> </results> </ DrivingRouteResponse>
1.2 直跳时显示路线和关键点的信息 注:可以搜索到起点和终点之间的驾车路线
<DrivingRouteResponse>
<status>Success</status>
<returnType>20</returnType> // returnType值为20时,返回的是起点和终点之间的驾车路线
<results>
<distance>538</distance> // 起点和终点之间的距离 单位:米(下同)
<duration>123</duration> // 所需要的时间,单位:秒(下同)
<origin> // 起点的经纬度坐标
<lng>116.30814793033</lng>
<lat>40.040481964898</lat>
</origin>
<destination> // 终点的经纬度坐标
<lng>116.30574720826</lng>
<lat>40.044841627062</lat>
</destination>
<result> // 第一个路段的信息
<distance>538</distance> // 第一个路段的距离
<duration>38</duration> // 第一个路段需要的时间
<path>116.3081595339,40.040479415093;116.30830953575,40.040549141561;116.30662974093,40.043449004818;116.30573024708,40.044848917951</path> // 第一个路段的路线信息
<type>256</type>
<instruction>从<b>起点</b>向东北方向出发,沿<b>信息路</b>行驶240米,过右侧的<b><font color="0x000000">CPE大厦</font></b>约300米后,到达<b>终点</b></instruction> //路线说明
<originLocation> // 第一个路段的起点的经纬度坐标
<lng>116.30814793033</lng>
<lat>40.040481964898</lat>
</originLocation>
<originInstruction>从起点向东北方向出发 - 240米</originInstruction>
//第一个路段的起点说明
<destinationLocation> // 第一个路段终点的经纬度坐标
<lng>116.30574720826</lng>
<lat>40.044841627062</lat>
</destinationLocation>
<destinationInstruction>到达终点</destinationInstruction> //终点的说明
<pois> //途中经过点
<keyPoint> // 第一组经过点的相关信息
<name>CPE大厦</name>
<location> //经过点的坐标
<lng>116.30751950407</lng>
<lat>40.042659383273</lat>
</location>
<type>106</type>
<detail>
<instruction/> 经过点的说明
<position>1</position>
</detail>
</keyPoint>
</pois>
</result>
</results>
</DrivingRouteResponse>
返回json格式的数据
2.1非直跳时显示起点和终点的信息:
{
status: "Success",
returnType: 19,
origin: {
cityName: "南京市",
listType: 0,
results: [{
name: "南京师范大学",
address: "文澜路",
telephone: null,
location: {
lng: 118.91485517954,
lat: 32.109151649066
}]
},
destination: {
cityName: "全国",
listType: 1,
results: [{
name: "北京市",
address: null,
telephone: null,
number: 553
},
{
name: "上海市",
address: null,
telephone: null,
number: 361}]
}
}
2.2 直跳时显示路线信息:
{
results: [{
distance: 524,
duration: 98,
steps: [{
area: 0,
direction: 5,
distance: 524,
duration: 38,
instructions: "从<b>起点</b>向东南方向出发,沿<b>信息路</b>行驶440米,过右侧的<b><font color="0x000000">方正大厦</font></b>约80米后,到达<b>终点</b>(在道路<b>左侧</b>)",
path: "116.3056498823,40.044799148654;116.30687944807,40.042709130558;116.30813989487,40.040479055788",
pois: [{
detail: {
instructions: "",
position: 1
},
location: {
lng: 116.30732953173,
lat: 40.040908962395
},
name: "方正大厦",
type: 106
}],
type: 3,
stepOriginLocation: {
lng: 116.3056480976,
lat: 40.044802568885
},
stepDestinationLocation: {
lng: 116.30813989487,
lat: 40.040479055788
},
stepOriginInstruction: "从起点向东南方向出发 - 440米",
stepDestinationInstruction: "到达终点"
}
],
originLocation: {
lng: 116.30813989487,
lat: 40.040479055788
},
destinationlocation: {
lng: 116.3056480976,
lat: 40.044802568885
}
}],
returnType: 20,
status: "Success"
}
没有match的答案?试试对话大模型




