接口说明
根据城市,返回相应的交通事件信息。
接口示例
http://api.map.baidu.com/telematics/v3/trafficEvent?location=北京&output=json&ak=yourkey
接口参数说明
参数类型
|
参数名称
|
是否必须
|
具体描述
|
String
|
ak
|
true
|
开发者密钥
|
String
|
sn
|
false
|
若用户所用ak的校验方式为sn校验时该参数必须。 (sn生成算法)
|
String
|
location
|
true
|
输入城市名或经纬度,经纬度格式为 lng,lat
|
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表示经过国测局加密的坐标。
|
返回结果
参数名称
|
含义
|
说明
|
status
|
返回结果状态信息
|
|
currentCity
|
当前城市
|
返回城市名
|
datetime
|
当前时间
|
格式 年/月/日/时/分/秒
|
results.startTime
|
事件开始时间
|
格式 年/月/日/时/分/秒
|
results.endTime
|
事件结束时间
|
格式 年/月/日/时/分/秒
|
results.title
|
事件名称
|
|
results.description
|
事件描述
|
|
results.location
|
事件位置(经纬度)
|
|
results.location.lng
|
经度
|
|
results.location.lat
|
纬度
|
|
results.type
|
事件类型
|
0管制、1事故、2施工、3管制
|
返回xml格式的数据
<TrafficEventResponse>
<status>success</status>
<currentCity>北京</currentCity>
<dateTime>2013/07/23/18/32/41</dateTime>
<results>
<result>
<startTime>2013/03/08/10/51/00</startTime>
<endTime>2013/10/08/12/00/00</endTime>
<title>东四西大街1车道限行(长期)</title>
<description>东四西大街因为道路施工,导致1车道限行。</description>
<location>
<lng>116.420497</lng>
<lat>39.930511</lat>
</location>
<type>2</type>
</result>
<result>
<startTime>2013/01/01/00/00/00</startTime>
<endTime>2013/12/31/23/59/00</endTime>
<title>清华东路3车道限行(长期)</title>
<description>清华东路因为道路施工,导致3车道限行。</description>
<location>
<lng>116.37618</lng>
<lat>40.007609</lat>
</location>
<type>2</type>
</result>
</results>
</TrafficEventResponse>
返回json格式的数据
{
error: 0,
status: "success",
currentCity: "北京",
dateTime: "2013/07/23/18/33/46",
results: [
{
startTime: "2013/03/08/10/51/00",
endTime: "2013/10/08/12/00/00",
title: "东四西大街1车道限行(长期)",
description: "东四西大街因为道路施工,导致1车道限行。",
location: {
lng: 116.420497,
lat: 39.930511
},
type: "2"
}
]
}