为了完善天气预报功能模块,我开发了一套数据量较为全的天气预报,主要为全国主要城市预报。地址为:http://www.sojson.com/tianqi/
首先首页是个定位功能,然后根据定位查询天气。当定位不准,或者定位到的城市没有在我的城市范围内,那么就采用本省的省会做为天气预报城市,这里比较粗糙。
天气预报效果图
天气预报,我设置了几个背景效果,分为:天晴,下雨,污染雾霾,下雪,等几个背景效果。
天气晴朗效果图:
天气下雨效果图
其他的自己体验。
天气API接口说明
接口链接:http://www.sojson.com/tianqi/api/1011-58414.shtml
参数说明: 1011-58414
,第一个是省ID,第二个是城市ID。
返回说明:返回以 JSON 格式返回。
天气API 返回值如下:
{
"updateTime": 1496988312667,
"alert": "2017年06月09日06时安徽省安庆市太湖县发布雷电黄色预警",
"temperature": 24.4,
"rain": 0.1,
"humidity": 97,
"weatherInfo": "大雨",
"feelst": 23.4,
"icomfort": {
"text": "温暖,较舒适",
"color": "#00a44f",
"value": "1"
},
"airpressure": 996,
"speed": 1.9,
"direct": "西南风",
"power": "微风",
"title": "6小时内我县可能发生雷电活动,请注意防范。",
"description": "1.政府及相关部门按照职责做好防雷工作;\n2.密切关注天气,尽量避免户外活动。",
"aqi": {
"aqi": "26.0",
"aq": "1",
"info": "优",
"description": "空气质量令人满意,基本无空气污染。",
"color": "#32f43e"
},
"day7": [
{
"date": {
"date": "今天",
"md": "06月09日",
"week": "星期五"
},
"day": {
"wicon": "9",
"wdesc": "大雨",
"temp": "28℃",
"direct": "南风",
"wind": "微风"
},
"night": {
"wicon": "8",
"wdesc": "中雨",
"temp": "23℃",
"direct": "南风",
"wind": "微风"
},
"details": {
"hour": [
"17:00",
"20:00",
"23:00",
"10日02:00",
"05:00",
"08:00",
"11:00",
"14:00"
],
"wicon": [
"8",
"8",
"8",
"7",
"7",
"8",
"7",
"7"
],
"temp": [
"24.2℃",
"23.2℃",
"23.4℃",
"25.7℃",
"27.3℃",
"24.6℃",
"28.5℃",
"29.8℃"
],
"rainfall": [
"5.5毫米",
"8.9毫米",
"3.9毫米",
"1毫米",
"0.5毫米",
"8毫米",
"2.3毫米",
"1.3毫米"
],
"wind_speed": [
"0.4米/秒",
"0.6米/秒",
"1米/秒",
"1.8米/秒",
"3.1米/秒",
"3.4米/秒",
"3.7米/秒",
"2.6米/秒"
],
"wind_direction": [
"东风",
"东南风",
"东南风",
"南风",
"西南风",
"西南风",
"西风",
"西风"
],
"pressure": [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
],
"humidity": [
"95.1%",
"95.6%",
"98%",
"97.1%",
"93.7%",
"83%",
"85.6%",
"94.7%"
],
"cloudage": [
"90.7%",
"70%",
"72.9%",
"100%",
"85.5%",
"70%",
"70%",
"70%"
],
"visibility": [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
]
}
},
{
"date": {
"date": "明 天",
"md": "06月10日",
"week": "星期六"
},
"day": {
"wicon": "7",
"wdesc": "小雨",
"temp": "30℃",
"direct": "西南风",
"wind": "微风"
},
"night": {
"wicon": "4",
"wdesc": "雷阵雨",
"temp": "21℃",
"direct": "西南风",
"wind": "微风"
},
"details": {
"hour": [
"08:00",
"11:00",
"14:00",
"17:00",
"20:00",
"23:00",
"11日02:00",
"05:00"