开源软件名称:WeatherMap
开源软件地址:https://gitee.com/zhu/WeatherMap
开源软件介绍:
地级行政区天气组件,基于高德地图 JavaScript API V1.3使用方法:<link rel="stylesheet" href="./weather-amap.css" type="text/css"> <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=yourkey"></script> <script type="text/javascript" src="yourpath/weather-amap.js"></script> - 定义查询天气信息的回调函数,返回 WeatherData 对象
function getWeatherDataCallback(cityName) { // ...获取天气信息的业务逻辑 var weatherData = new WeatherData(dayPictureUrl, weather, wind, temperature); return weatherData; } - 定义查询pm2.5信息的回调函数,返回 pm25Data 对象
function getPm25DataCallback(cityName) { // ...获取天气信息的业务逻辑 var pm25Data = new Pm25Data(pm25); return pm25Data; } var config = { isWeatherControlVisible : true, isPm25ControlVisible : true, isWeatherMarkerVisible : true, isPm25MarkerVisible : true }; var districtWeather = new AMap.DistrictWeather(mapObj, getWeatherDataCallback, getPm25DataCallback, config); mapObj.addControl(districtWeather); 效果图 |
请发表评论