/** * 站点查询 */ define([ 'html!templates/meteo/currentLocation', 'modDir/service/addressSearch', ], function (clhtml, addressSearchF) { var query = { city: null, station: null, getData: function (station, city) { if (station) { query.show(); } else { query.hide(); } meteo.c.http.httpFunction(meteo.c.http.stationInfo, station, null, function (json) { query.station = station; query.city = city; query.updateQuery(json); }) }, updateQuery: function (json) { var city = meteo.c.process.setCity(query.city); city = ' ' + city; $('.meteo-cl-location-p').html(city); $('.meteo-cl-tt').html(meteo.c.process.setTt(json.tt)); $('.meteo-cl-wth').html(meteo.c.process.setWth(json.wth)); $('.meteo-cl-wind').html(meteo.c.process.setWs(json.ws)); var url = json.wth < 10 ? '0' + json.wth : json.wth; url = 'url(../../images/meteo/weatherIcon/cww' + url + '.png)'; $('.meteo-cl-wth').css('background-image', url); var str = json.wd ? json.wd : '--'; if (str == '--') { $('.meteo-cl-wind').css('background-image', ''); } str = str > 360 ? str % 360 : str; str = str < 0 ? (str + 360) : str; str = (str - 22.5) / 45; str = str < 0 ? '0' : str < 1 ? '1' : str < 2 ? '2' : str < 3 ? '3' : str < 4 ? '4' : str < 5 ? '5' : str < 6 ? '6' : str < 7 ? '7' : '0'; str = 'url(../../images/meteo/windDirection/' + str + '.png)'; $('.meteo-cl-wind').css('background-image', str); }, show: function () { $('.meteo-cl-popup').show(); // $('.meteo-cl-popup').css('display', ''); }, hide: function () { $('.meteo-cl-popup').hide(); // $('.meteo-cl-popup').css('display', 'none'); }, getCenterStation: function () { // var weatherLatlng = []; // weatherLatlng.push([map23DData.view.center.lng, map23DData.view.center.lat]); // var addressSearch = new addressSearchF(); // addressSearch.latlngToZDAndName(weatherLatlng, function (json) { // if (json.code == 1) { // query.hide(); // } else if (json.code == 0) { // query.getData(json.data[0].station, json.data[0].chaname); // } // }) }, init: function () { $('.meteo-cl-box').append(clhtml); $('.meteo-cl-popup').click(function () { if (!query.station) return; meteo.c.popup.showPopup(query.station, query.city, 0); }); query.getCenterStation(); ONEMAP.C.publisher.subscribe(function (zoom) { if (zoom < 6) { query.hide(); return; } query.getCenterStation(); }, 'mapChange23D'); } } query.init(); // window.setTimeout(function () { // query.getData(54511, '北京'); // window.setTimeout(function () { // // query.getData(54399, '海淀'); // query.getData('', '海淀'); // }, 2000) // }, 2000) meteo.f.query = { getData: query.getData } return meteo.f.query; })