公交路线查询有很多网站都作了接口api,我使用的是haoservice的接口,需要您申请key值
haoservice提供的有公交站点的查询,公交线路的查询,还有公交路线的规划.
1.公交站点查询,该接口根据关键字查询周边公交站点 .
1.1.形式:
http://apis.haoservice.com/lifeservice/busline/stopname
例如:
http://apis.haoservice.com/lifeservice/busline/stopname?city=0512&keywords=生物纳米园西&key=您申请的APPKEY
1.2参数说明:
名称 类型 必须 说明
key string 是 APP KEY
city string 是 城市名称,如:苏州或0512
keywords string 是 站点名称关键字。 如:生物纳米园西(支持模糊匹配)
1.3.返回示例:
{
"error_code":0,
"reason":"Success",
"result":{
"busstops":[{
"adcode":320506,
"citycode":"0512", /*城市区号*/
"timestamp":null,
"id":"BV20030270",
"name":"生物纳米园西(公交站)", /*站点名称*/
"location":"120.727766,31.258087", /*站点坐标*/
"buslines":[{ /*公交线路*/
"start_stop":"启月街首末站",
"end_stop":"星华街游客中心首末站",
"id":"320500012825",
"name":"176路(启月街首末站--星华街游客中心首末站)",
"location":"120.727766,31.258087"
},{
"start_stop":"启月街首末站",
"end_stop":"星华街游客中心首末站",
"id":"320500011036","name":"176路空调(启月街首末站--星华街游客中心首末站)",
"location":"120.727766,31.258087"
},{
"start_stop":"星华街游客中心首末站",
"end_stop":"启月街首末站",
"id":"320500012826",
"name":"176路(星华街游客中心首末站--启月街首末站)",
"location":"120.727677,31.258105"
},{
"start_stop":"星华街游客中心首末站",
"end_stop":"启月街首末站",
"id":"320500011038",
"name":"176路空调(星华街游客中心首末站--启月街首末站)",
"location":"120.727677,31.258105"
}]
}]
}
}
2.公交线路查询,根据关键词可以查询某一路公交经过站点和时间等.
2..1.形式:
http://apis.haoservice.com/lifeservice/busline/linename
例如:
http://apis.haoservice.com/lifeservice/busline/linename?city=苏州&keywords=10&key=您申请的APPKEY
2.2.参数说明:
名称 类型 必须 说明
key string 是 APP KEY
city string 是 城市区号,如:苏州或0512
keywords string 是 线路名称关键字。 如:110(支持模糊匹配)
2.3.返回示例:
{
"error_code":0,
"reason":"Success",
"result":{
"buslines":[{
"id":"320500012746",
"name":"松陵110路(喜庆苑--山湖东路口)", /*线路名称*/
"type":"普通公交",
"polyline":"120.630445,31.119342;120.631847,31.119362;120.635081,31.11943;120.635129,31.120956;120.635173,31.12235;120.63
5237,31.123992;................
31.161515;120.680074,31.161533;120.688185,31.161606;120.68909,31.161595;120.689331,31.15692;120.689461,31.152195", /*途径
线路坐标*/
"citycode":"0512", /*城市区号*/
"start_stop":"喜庆苑", /*始发站点*/
"end_stop":"山湖东路口", /*终点站*/
"start_time":"0620", /*始发时间*/
"end_time":"1810", /*停运时间*/
"company":"苏州吴江公共交通有限公司", /*所属公司*/
"distance":"14.96524", /*距离(单位:km)*/
"basic_price":1.0, /*票价(单位:圆)*/
"bounds":"120.630445,31.119342;120.689461,31.161606", /*界限坐标*/
"busstops":[{ /*停靠站点*/
"sequence":"1", /*站点序号*/
"id":"BV20028197",
"name":"喜庆苑", /*站点名称*/
"location":"120.630445,31.119342" /*站点坐标*/
},{
"sequence":"2",
"id":"BV20028538",
"name":"联杨小区东",
"location":"120.635129,31.120956"
},{
"sequence":"3",
"id":"BV20028433",
"name":"联杨新村",
"location":"120.635237,31.123992"
},{
......
},{
"sequence":"24",
"id":"BV20028418",
"name":"新城花园(吴江)",
"location":"120.689331,31.15692"
},{
"sequence":"25",
"id":"BV20028152",
"name":"山湖东路口",
"location":"120.689461,31.152195"
}]
}]}
}
3.公交路线规划查询,起点和终点之间的换乘信息,(因名字重复难以辨别,故用经纬度)
3.1.形式:
http://apis.haoservice.com/lifeservice/busline/planning
例如:
http://apis.haoservice.com/lifeservice/busline/planning?origin=120.732446,31.255821&destination=120.73017,31.259022&city=
苏州&key=您申请的APPKEY
3.2.参数说明:
名称 类型 必须 说明
key string 是 APP KEY
city string 是 城市区号,如:苏州或0512
origin string 是 起始地坐标,如:120.73017,31.259022
destination string 是 目的地坐标,如120.73017,31.259022
3.3.返回示例:
{
"error_code":0,
"reason":"Success",
"result":{
"route":{
"origin":"120.732446,31.255821",
"destination":"120.730170,31.259022",
"distance":"562",
"taxi_cost":10.0,
"transits":[{
"cost":"1.0",
"duration":917,
"nightflag":0,
"walking_distance":289,
"segments":[{
"walking":{
"origin":"120.731995,31.255573",
"destination":"120.733253,31.253971",
"distance":"219",
"duration":"225",
"steps":[{
"instruction":"沿新平街步行219米到达腾飞创新园",
"road":"新平街",
"distance":"219",
"duration":"",
"polyline":"120.731995,31.255573;120.732407,31.255035;120.732445,
31.254988;120.732559,31.254818;120.733078,31.254189;
120.733253,31.253971",
"action":"",
"assistant_action":"到达腾飞创新园"
}]},...........
"walking":{
"origin":"120.730919,31.257700",
"destination":"120.730141,31.259102",
"distance":"194",
"duration":"199",
"steps":[{
"instruction":"沿新平街步行170米左转",
"road":"新平街",
"distance":"170",
"duration":"",
"polyline":"120.730919,31.257700;120.730759,31.258121;
120.730698,31.258255;120.730415,31.258963;
120.730347,31.259157",
"action":"左转",
"assistant_action":""
},{
"instruction":"步行24米到达目的地",
"road":"",
"distance":"24",
"duration":"",
"polyline":"120.730347,31.259157;120.730286,31.259146;
120.730141,31.259102",
"action":"",
"assistant_action":"到达目的地"
}]},
"bus":{
"buslines":null
},
"entrance":null,
"exit":null
}]
}]
}
}
}
备注说明
全国各大城市的公交线路查询,如北京、广州、上海、深圳等城市公交车查询,公交换乘查询等,提供近2000条公交线路,5万余公交站点数据查询