高德开放平台天气查询API
Posted youngxuebo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了高德开放平台天气查询API相关的知识,希望对你有一定的参考价值。
https://lbs.amap.com/api/webservice/guide/api/weatherinfo
var deal_time = new Date().getHours();
if(8< deal_time <20)
return [
weather: data[0].forecasts[0].casts[0].dayweather,
temperature:
min : data[0].forecasts[0].casts[0].nighttemp,
max : data[0].forecasts[0].casts[0].daytemp,
wind: direction : data[0].forecasts[0].casts[0].daywind + "风",
level : data[0].forecasts[0].casts[0].daypower.slice(1)
]
else
return [
weather: data[0].forecasts[0].casts[0].nightweather,
temperature:
min : data[0].forecasts[0].casts[0].nighttemp,
max : data[0].forecasts[0].casts[0].daytemp,
wind: direction : data[0].forecasts[0].casts[0].daywind + "风",
level : data[0].forecasts[0].casts[0].daypower.slice(1)
]
json串格式:
[
"status": "1",
"count": "1",
"info": "OK",
"infocode": "10000",
"forecasts": [
"city": "北京市",
"adcode": "110000",
"province": "北京",
"reporttime": "2021-10-21 15:33:53",
"casts": [
"date": "2021-10-21",
"week": "4",
"dayweather": "晴",
"nightweather": "晴",
"daytemp": "18",
"nighttemp": "4",
"daywind": "西北",
"nightwind": "西北",
"daypower": "≤3",
"nightpower": "≤3"
,
"date": "2021-10-22",
"week": "5",
"dayweather": "晴",
"nightweather": "晴",
"daytemp": "17",
"nighttemp": "2",
"daywind": "北",
"nightwind": "北",
"daypower": "≤3",
"nightpower": "≤3"
,
"date": "2021-10-23",
"week": "6",
"dayweather": "晴",
"nightweather": "多云",
"daytemp": "16",
"nighttemp": "3",
"daywind": "西南",
"nightwind": "西南",
"daypower": "≤3",
"nightpower": "≤3"
,
"date": "2021-10-24",
"week": "7",
"dayweather": "多云",
"nightweather": "晴",
"daytemp": "17",
"nighttemp": "4",
"daywind": "西南",
"nightwind": "西南",
"daypower": "≤3",
"nightpower": "≤3"
]
]
]
[
"weather": "晴",
"temperature":
"min": "4",
"max": "18"
,
"wind":
"direction": "西北风",
"level": "3"
]
以上是关于高德开放平台天气查询API的主要内容,如果未能解决你的问题,请参考以下文章