(→接口参数说明) |
(→返回结果) |
||
第62行: | 第62行: | ||
|colspan="2"| status | |colspan="2"| status | ||
|返回结果状态信息 | |返回结果状态信息 | ||
− | | | + | |请求状态,如果成功返回0,如果失败返回其他数字,详细见状态码附录。 |
|- | |- | ||
|colspan="2"| date | |colspan="2"| date | ||
第75行: | 第75行: | ||
|当前城市 | |当前城市 | ||
| | | | ||
+ | |- | ||
+ | |colspan="2"| results.pm25 | ||
+ | |pm2.5 | ||
+ | |0~50,一级,优,绿色; | ||
+ | 51~100,二级,良,黄色; | ||
+ | 101~150,三级,轻度污染,橙色; | ||
+ | 151~200,四级,中度污染 ,红色; | ||
+ | 201~300,五级,重度污染 ,紫色; | ||
+ | >300,六级,严重污染, 褐红色。 | ||
+ | 图标分类示意图: | ||
+ | 优, 良 , 轻度污染, 中度污染, 重度污染, 严重污染。 | ||
+ | |- | ||
+ | |colspan="2"|results.index.title | ||
+ | |指数title | ||
+ | |分为:穿衣、洗车、感冒、运动、紫外线这几个类型。 | ||
+ | |- | ||
+ | |colspan="2"|results.index.zs | ||
+ | |指数取值 | ||
+ | |不同指数描述不一 | ||
+ | |- | ||
+ | |colspan="2"|results.index.tipt | ||
+ | |指数含义 | ||
+ | |指数含义 | ||
+ | |- | ||
+ | |colspan="2"|results.index.des | ||
+ | |指数详情 | ||
+ | |指数详情 | ||
|- | |- | ||
|rowspan="6" width="125"|results.weather_data | |rowspan="6" width="125"|results.weather_data | ||
第95行: | 第122行: | ||
|weather_data.wind | |weather_data.wind | ||
|风力 | |风力 | ||
− | | | + | |风力值 |
|- | |- | ||
|weather_data.temperature | |weather_data.temperature | ||
|温度 | |温度 | ||
− | | | + | |温度范围,如:29~22℃ |
|} | |} | ||
2014年7月2日 (三) 17:26的版本
接口说明
根据经纬度/城市名查询天气的结果
接口示例
http://api.map.baidu.com/telematics/v3/weather?location=北京&output=json&ak=yourkey
接口参数说明
参数类型 | 参数名称 | 是否必须 | 具体描述 |
---|---|---|---|
String | ak | true | 开发者密钥 |
String | sn | false | 若用户所用ak的校验方式为sn校验时该参数必须。 (sn生成算法) |
String | location | true | "分隔,location=116.305145,39.982368| 122.305145,36.982368|…. |
String | output | false | 输出的数据格式,默认为xml格式,当output设置为’json’时,输出的为json格式的数据; |
String | coord_type | false | 请求参数坐标类型,默认为gcj02经纬度坐标。允许的值为bd09ll、bd09mc、gcj02、wgs84。bd09ll表示百度经纬度坐标,bd09mc表示百度墨卡托坐标,gcj02表示经过国测局加密的坐标。wgs84表示gps获取的坐标。 |
String | callback | false | 将json格式的返回值通过callback函数返回以实现jsonp功能。举例:callback=showLocation(JavaScript函数名)。 |
返回结果
参数名称 | 含义 | 说明 | |
---|---|---|---|
currentCity | 当前城市 | 返回城市名 | |
status | 返回结果状态信息 | 请求状态,如果成功返回0,如果失败返回其他数字,详细见状态码附录。 | |
date | 当前时间 | 年-月-日 | |
results | 天气预报信息 | 白天可返回近期3天的天气情况(今天、明天、后天)、晚上可返回近期4天的天气情况(今天、明天、后天、大后天) | |
results.currentCity | 当前城市 | ||
results.pm25 | pm2.5 | 0~50,一级,优,绿色;
51~100,二级,良,黄色; 101~150,三级,轻度污染,橙色; 151~200,四级,中度污染 ,红色; 201~300,五级,重度污染 ,紫色; >300,六级,严重污染, 褐红色。 图标分类示意图: 优, 良 , 轻度污染, 中度污染, 重度污染, 严重污染。 | |
results.index.title | 指数title | 分为:穿衣、洗车、感冒、运动、紫外线这几个类型。 | |
results.index.zs | 指数取值 | 不同指数描述不一 | |
results.index.tipt | 指数含义 | 指数含义 | |
results.index.des | 指数详情 | 指数详情 | |
results.weather_data | weather_data.date | 天气预报时间 | |
weather_data.dayPictureUrl | 白天的天气预报图片url | ||
weather_data.nightPictureUrl | 晚上的天气预报图片url | ||
weather_data.weather | 天气状况 | 常见天气情况(“|”分隔符):晴|多云|阴|阵雨|雷阵雨|雷阵雨伴有冰雹|雨夹雪|小雨|中雨|大雨|暴雨|大暴雨|特大暴雨|阵雪|小雪|中雪|大雪|暴雪|雾|冻雨|沙尘暴|小雨转中雨|中雨转大雨|大雨转暴雨|暴雨转大暴雨|大暴雨转特大暴雨|小雪转中雪|中雪转大雪|大雪转暴雪|浮尘|扬沙|强沙尘暴|霾 | |
weather_data.wind | 风力 | 风力值 | |
weather_data.temperature | 温度 | 温度范围,如:29~22℃ |
返回xml格式的数据
<CityWeatherResponse> <status>success</status> <date>2013-07-18</date> <results> <currentCity>北京市</currentCity> <weather_data> <date>周三(今天, 实时:24℃)</date> <dayPictureUrl> http://api.map.baidu.com/images/weather/day/duoyun.png </dayPictureUrl> <nightPictureUrl> http://api.map.baidu.com/images/weather/night/duoyun.png </nightPictureUrl> <weather>多云</weather> <wind>微风</wind> <temperature>23℃~ 15℃</temperature> <date>周四</date> <dayPictureUrl> http://api.map.baidu.com/images/weather/day/leizhenyu.png </dayPictureUrl> <nightPictureUrl> http://api.map.baidu.com/images/weather/night/zhongyu.png </nightPictureUrl> <weather>雷阵雨转中雨</weather> <wind>微风</wind> <temperature>29~22℃</temperature> <date>周五</date> <dayPictureUrl> http://api.map.baidu.com/images/weather/day/yin.png </dayPictureUrl> <nightPictureUrl> http://api.map.baidu.com/images/weather/night/duoyun.png </nightPictureUrl> <weather>阴转多云</weather> <wind>微风</wind> <temperature>31~23℃</temperature> <date>周六</date> <dayPictureUrl> http://api.map.baidu.com/images/weather/day/duoyun.png </dayPictureUrl> <nightPictureUrl> http://api.map.baidu.com/images/weather/night/duoyun.png </nightPictureUrl> <weather>多云</weather> <wind>微风</wind> <temperature>31~24℃</temperature> </weather_data> <currentCity>合肥市</currentCity> <weather_data> <date>周三</date> <dayPictureUrl> http://api.map.baidu.com/images/weather/day/duoyun.png </dayPictureUrl> <nightPictureUrl> http://api.map.baidu.com/images/weather/night/duoyun.png </nightPictureUrl> <weather>多云</weather> <wind>东风3-4级</wind> <temperature>27℃</temperature> <date>周四</date> <dayPictureUrl> http://api.map.baidu.com/images/weather/day/duoyun.png </dayPictureUrl> <nightPictureUrl> http://api.map.baidu.com/images/weather/night/duoyun.png </nightPictureUrl> <weather>多云</weather> <wind>东北风3-4级</wind> <temperature>35~27℃</temperature> <date>周五</date> <dayPictureUrl> http://api.map.baidu.com/images/weather/day/duoyun.png </dayPictureUrl> <nightPictureUrl> http://api.map.baidu.com/images/weather/night/duoyun.png </nightPictureUrl> <weather>多云</weather> <wind>南风</wind> <temperature>35~27℃</temperature> <date>周六</date> <dayPictureUrl> http://api.map.baidu.com/images/weather/day/duoyun.png </dayPictureUrl> <nightPictureUrl> http://api.map.baidu.com/images/weather/night/duoyun.png </nightPictureUrl> <weather>多云</weather> <wind>东风</wind> <temperature>34~27℃</temperature> </weather_data> </results> </CityWeatherResponse> <weather>阵雨</weather> <wind>东北风3-4级</wind> <temperature>18℃</temperature> </result> </results> </CityWeatherResponse>
返回json格式的数据
{ error: 0, status: "success", date: "2013-07-17", results: [ { currentCity: "北京市", weather_data: [ { date: "周三(今天, 实时:24℃)", dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png", nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png", weather: "多云", wind: "微风", temperature: "23℃~ 15℃" }, { date: "明天(周四)", dayPictureUrl: "http://api.map.baidu.com/images/weather/day/leizhenyu.png", nightPictureUrl: "http://api.map.baidu.com/images/weather/night/zhongyu.png", weather: "雷阵雨转中雨", wind: "微风", temperature: "29~22℃" }, { date: "后天(周五)", dayPictureUrl: "http://api.map.baidu.com/images/weather/day/yin.png", nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png", weather: "阴转多云", wind: "微风", temperature: "31~23℃" }, { date: "大后天(周六)", dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png", nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png", weather: "多云", wind: "微风", temperature: "31~24℃" } ] }, { currentCity: "合肥市", weather_data: [ { date: "今天(周三)", dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png", nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png", weather: "多云", wind: "东风3-4级", temperature: "27℃" }, { date: "明天(周四)", dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png", nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png", weather: "多云", wind: "东北风3-4级", temperature: "35~27℃" }, { date: "后天(周五)", dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png", nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png", weather: "多云", wind: "南风", temperature: "35~27℃" }, { date: "大后天(周六)", dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png", nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png", weather: "多云", wind: "东风", temperature: "34~27℃" } ] } ] }