123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
- /**
- * 机场单点数据(暂命名)
- * Created by Administrator on 2017/11/7.
- */
- define([], function () {
- var airport = {
- isInit: false,
- map: null,
- layer: null,
- data: null,
- startZoom: null,
- isLoad: false,
- isClose: false,
- isHide: false,
- getData: function () { //获取数据
- meteo.c.http.httpFunction(meteo.c.http.airportIndex, null, null, function (json) {
- airport.data = json;
- airport.drawAllMarkerForLayerZoom();
- }, function () {
- airport.isLoad = false;
- ONEMAP.C.publisher.publish({ type: 'warning', message: '民航报暂无数据' }, 'noteBar::add');
- })
- },
- drawAirportMarker: function (lng, lat, station, cname) { //绘制单个marker点,同时给每个marker加入点击事件
- var iconUrl = 'images/meteo/airport_brown.png';
- // var iconUrl = airport.getIcon(sigmenttype);
- var myIcon = L.icon({
- iconUrl: iconUrl,
- iconSize: [16, 16],
- iconAnchor: [8, 8],
- })
- return L.marker([lng, lat], {icon: myIcon}).on('click', function (marker) {
- meteo.c.http.httpFunction(meteo.c.http.airportInfo, station, null, function (json) {
- var content = airport.getPopupContent(json, station, cname);
- airport.popup.setLatLng(marker.latlng)
- .setContent(content)
- .openOn(map2DViewer.map);
- })
- });
- },
- getIcon: function (sigmenttype) { //获取icon图片
- var url = airport.contains(sigmenttype, "RAIN") ? 'airport_green.png' :
- airport.contains(sigmenttype, "SOOT") ? 'airport_brown.png' :
- airport.contains(sigmenttype, "THUNDER") ? 'airport_red.png' :
- airport.contains(sigmenttype, "SAND") ? 'airport_brown.png' :
- airport.contains(sigmenttype, "STORM") ? 'airport_brown.png' :
- airport.contains(sigmenttype, "CLOTTED GROUND") ? 'airport_green.png' :
- airport.contains(sigmenttype, "PUFF SNOW") ? 'airport_green.png' :
- airport.contains(sigmenttype, "FIRN SNOW") ? 'airport_green.png' :
- airport.contains(sigmenttype, "SNOW") ? 'airport_green.png' :
- airport.contains(sigmenttype, "FOG") ? 'airport_yellow.png' : 'airport_gray.png';
- return meteo.c.http.myImageUrlJs + url;
- },
- getPopupContent: function (data, station, cname) {
- var html = "<div class='popup_html'>"
- + "<div class='popup-lt'></div>"
- + "<div class='popup-lb'></div>"
- + "<div class='popup-rt'></div>"
- + "<div class='popup-rb'></div>"
- + "<div class='popup-ct'>"
- + "<div class='meteo-menu-top meteo-menu-top-airport'>"
- // + "<h3 class='meteo-title meteo-title-airport'>" + cname + " " + station + "</h3>"
- + "<h3 class='meteo-title meteo-title-airport'>" + cname + " " + "</h3>"
- + "</div>"
- + "</div>"
- + "<div class='popup-cb' style='padding-bottom:20px;'>"
- + "<div class='meteo-popup-airport-warp content_scroll'>"
- + "<ul class='meteo-popup-airportUl'>"
- + "<li><h4 class='meteo-popup-airpory-h4'>----机场实况----</h4></li>"
- // + "<li class='meteo-popup-airport-li'><span>观测时间:</span><span>" + meteo.c.process.setDate(data.ldate) + "</span></li>"
- + "<li class='meteo-popup-airport-li'><span>观测时间:</span><span>" + meteo.c.process.setData(data.ldate, "") + " " + "</span></li>"
- + "<li class='meteo-popup-airport-li'><span>天气现象:</span><span>" + meteo.c.process.setWth(data.wth1) + "</span></li>"
- + "<li class='meteo-popup-airport-li'><span>气温:</span><span>" + meteo.c.process.setTt(data.tt) + "</span></li>"
- + "<li class='meteo-popup-airport-li'><span>气压:</span><span>" + meteo.c.process.setPr(data.pr) + "</span></li>"
- + "<li class='meteo-popup-airport-li'><span>露点温度:</span><span>" + meteo.c.process.setTt(data.td) + "</span></li>"
- + "<li class='meteo-popup-airport-li'><span>能见度:</span><span>" + meteo.c.process.setVis(data.vis) + "</span></li>"
- + "<li class='meteo-popup-airport-li'><span>云:</span><span>" + "--" + "</span></li>"
- + "<li class='meteo-popup-airport-li'><span>风:</span><span>" + meteo.c.process.setWsWd(data.ws, data.wd) + "</span></li>"
- // + "<li class='meteo-popup-airpory-li'>"
- // + "<h4 class='meteo-popup-airpory-h4'>----机场预报----</h4>"
- // + "</li>"
- // + "<li><span>起止时间:</span><span>--</span> </li>"
- // + "<li><span>能见度:</span><span>3500米</span></li>"
- // + "<li><span>云:</span><span>疏云/480米</span></li>"
- // + "<li><span>天气现象:</span><span>轻雾(水滴冰晶)</span></li>"
- // + "<li><span>风:</span><span>150°4米/秒</span></li>"
- // + "<li><span>气温:</span><span>9°</span></li>"
- // + "<li>"
- // + "<p class='meteo-popup-airpory-text'></p>"
- // + "</li>"
- + "</ul>"
- //+"<a href="##" class="meteo-delete"><img src="image/delete.png" height="18" width="16" alt="" /></a>"
- + "</div>"
- + "</div>"
- + "</div>";
- return html;
- },
- drawAllMarkerForLayerZoom: function () {
- if (!airport.data) return;
- var layerId = meteo.c.map.createLayer();
- var layer = map2DViewer.groups[layerId];
- var zoom = map2DViewer.map._zoom;
- for (var i = 0; i < airport.data.length; i++) {
- var data = airport.data[i];
- if (zoom < 5 && data.level > 1) {
- continue;
- }
- airport.drawAirportMarker(data.lng, data.lat, data.station, data.cname).addTo(layer);
- }
- if (!airport.layer || !airport.layer.tLayer || airport.isHide) {
- meteo.c.map.removeLayer(layerId);
- return;
- }
- if (airport.layer.cLayer) {
- meteo.c.map.removeLayer(airport.layer.cLayer);
- }
- airport.layer.cLayer = layerId;
- airport.isLoad = false;
- },
- create: function () {
- airport.layer = {
- tLayer: meteo.c.map.createLayer(),
- cLayer: null,
- }
- },
- remove: function () {
- if (airport.layer) {
- meteo.c.map.removeLayer(airport.layer.tLayer);
- meteo.c.map.removeLayer(airport.layer.cLayer);
- airport.layer = null;
- }
- },
- show: function () {
- airport.isHide = false;
- airport.drawAllMarkerForLayerZoom();
- },
- hide: function () {
- airport.isHide = true;
- if (airport.layer) {
- meteo.c.map.removeLayer(airport.layer.cLayer);
- airport.layer.cLayer = null;
- airport.popup.remove();//2d弹窗存在时关闭
- }
- },
- open: function () {
- if(ONEMAP.M.myLayers.checkLength() >= map23DConfig.layerMaxLength) {
- ONEMAP.C.publisher.publish({ type: 'warning', message: '图层数量已达上限' }, 'noteBar::add');
- return;
- }
- airport.isLoad = true;
- airport.isClose = false;
- airport.isHide = false;
- //-------------创建图层------------------
- if (airport.layer) {
- airport.remove();
- }
- airport.create();
- //----------------图层管理-------------------
- var options = {
- action: "add",
- // mod: "qixiang",
- DOM: {
- guid: airport.layer.tLayer,
- type: "group",
- name: '民航报',
- },
- }
- var guid = ONEMAP.M.myLayers.myLayerControl(options);
- ONEMAP.C.publisher.subscribe(function (option) {
- switch (option.action) {
- case 'remove':
- if (airport.isLoad) {
- airport.isClose = true;
- return;
- }
- airport.close();
- break;
- case 'opacity':
- if (airport.isLoad) {
- if (option.options.opacity) {
- airport.isHide = false;
- } else {
- airport.isHide = true;
- }
- return;
- }
- if (option.options.opacity) {
- airport.show();
- } else {
- airport.hide();
- }
- break;
- }
- }, guid);
- //-------------------------------------
- $("#meteo-bt-airport").parent().addClass('current');
- airport.getData();
- if (airport.isInit) return;
- airport.isInit = true;
- //--------------------记录层级缩放开始,当变化到4/5级时重新绘制-----------------------
- map2DViewer.map.on("zoomstart", function () {
- if (!airport.layer) return;
- airport.startZoom = map2DViewer.map._zoom;
- })
- map2DViewer.map.on("zoomend", function () {
- if (!airport.layer || !airport.layer.cLayer) return;
- if (airport.startZoom >= 5 && map2DViewer.map._zoom <= 4) {
- airport.drawAllMarkerForLayerZoom();
- }
- if (airport.startZoom <= 4 && map2DViewer.map._zoom >= 5) {
- airport.drawAllMarkerForLayerZoom();
- }
- })
- },
- close: function () {
- var options = {
- action: "remove",
- DOMid: airport.layer.tLayer,
- }
- ONEMAP.M.myLayers.myLayerControl(options);
- airport.popup.remove();//2d弹窗存在时关闭
- $("#meteo-bt-airport").parent().removeClass('current');
- airport.remove();
- },
- update: function () { //用于时间变化时更新数据
- // airport.getData()
- },
- init: function () {
- $("#meteo-bt-airport").click(function () {
- if (airport.isLoad) return;
- if (airport.layer) {
- airport.close();
- } else {
- airport.open();
- }
- });
- airport.popup = L.popup();
- },
- /**
- * 判断str是否包含str2
- */
- contains: function (str, str2) {
- if (str.indexOf(str2) >= 0) {
- return true;
- }
- return false;
- },
- //-----------------------一些显示数据的格式化方法---------------------
- showInfoWindowDate: function (data, str) {
- if (data != 0 && !data) {
- return "-";
- }
- if (str) {
- return ((data * 10) >> 0) / 10 + str;
- } else {
- return data;
- }
- },
- showCloudData: function (cn1, ch1, cn2, ch2, cn3, ch3, str) {
- if (cn1 && ch1) {
- cn1 = cn1 + "/" + ch1 + str;
- if (cn2 && ch2) {
- cn1 = cn1 + "," + cn2 + "/" + ch2 + str;
- }
- if (cn3 && ch3) {
- cn1 = cn1 + "," + cn3 + "/" + ch3 + str;
- }
- } else {
- cn1 = "-"
- }
- return cn1
- },
- showWindData: function (wd, ws) {
- if ((ws === 0 && wd) || (wd && ws)) {
- return wd + "°" + ws + "米/秒"
- }
- return "";
- },
- showInfoWindowFactTime: function (odate, timeBg, timeEd) {
- var start = timeBg;
- if (timeBg == timeEd) {
- start = odate;
- }
- if (!start || !timeEd) {
- return "--";
- }
- return start.substring(8, 10) + "日" + start.substring(11, 13) + "时" + start.substring(14, 16) + "分-"
- + timeEd.substring(8, 10) + "日" + timeEd.substring(11, 13) + "时" + timeEd.substring(14, 16) + "分";
- }
- };
- meteo.f.airport = airport;
- return meteo.f.airport;
- })
|