高德天气(纯天气)

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>天气预报查询</title>
    <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />
</head>
<body>

<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=0e0515e5982fbfb4bb949348fe907b16"></script>
<script type="text/javascript">
//实时天气
function weatherLive(city) {
    //加载天气查询插件
    AMap.plugin('AMap.Weather', function() {
        //创建天气查询实例
        var weather = new AMap.Weather();
    
        //执行实时天气信息查询
        weather.getLive(city, function(err, data) {
            alert("实时天气==" + JSON.stringify(data));
            return data;
        });
        
       
    });
}

//实时天气
function weatherForecast(city) {
    //加载天气查询插件
    AMap.plugin('AMap.Weather', function() {
        //创建天气查询实例
        var weather = new AMap.Weather();
        
        //执行天气预报查询
        weather.getForecast(city, function(err, data) {
            alert("天气预报==" + JSON.stringify(data));
            return data;
        });
    });
}

$(document).ready(function() { 
    weatherLive("武汉");
})
</script>
</body>
</html>

猜你喜欢

转载自www.cnblogs.com/hedongfei/p/11964734.html