<!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() { // Create a weather query instance var weather Weather = new new AMap.Weather (); // perform real-time weather information inquiry weather.getLive (City, function (ERR, the Data) { Alert ( " weather == " + JSON. stringify (the Data)); return the Data; }); }); } // weather function the WeatherForecast (City) { // load check the weather plug AMap.plugin ( ' AMap.Weather ' , function () { // create weather query instance varWeather = new new AMap.Weather (); // perform weather search weather.getForecast (City, function (ERR, Data) { Alert ( " weather forecast == " + the JSON.stringify (Data)); return Data; }) ; }); } $ (Document) .ready ( function () { weatherLive ( " Wuhan " ); }) </ Script > </ body > </ HTML >