//船舶报数据 define([], function () { var ship = { id: 'ship', title: '船舶报', popupTo2d: null, isInit: false, layer: null, data: null, markerData: {}, isLoad: false, isClose: false, isHide: false, getData: function () { meteo.c.http.httpFunction(meteo.c.http.ship, null, null, function (json) { ship.data = json; ship.showMarker(); }, function () { ship.isLoad = false; ONEMAP.C.publisher.publish({ type: 'warning', message: '船舶报暂无数据' }, 'noteBar::add'); }) }, showMarker: function () { var layerId = meteo.c.map.createLayer(); //新建图层展示marker ship.markerData = {}; //初始化数据存储对象 var json = ship.data; var latlngs = meteo.c.map.getBounds(); var zoom = meteo.c.map.getZoom(); var level = ship.getLevel(zoom); for (var i = 0; i < json.length; i += level) { if (zoom < 4) break; if (json[i].lat < latlngs[0] || json[i].lat > latlngs[2] || json[i].lng < latlngs[1] || json[i].lng > latlngs[3]) { continue; } if (json[i].lat && json[i].lng && (json[i].wth == 0 || json[i].wth) && json[i].wth < 99) { //有经纬度和天气状态 var url = json[i].wth < 10 ? "0" + json[i].wth : json[i].wth; url = meteo.c.http.markerUrl + "weatherImage/cww" + url + ".png"; var content = null; var markerId = meteo.c.map.addMarker("", url, 26, 0, content, json[i].lat, json[i].lng, layerId); map23DData.markers[markerId].station = json[i].station; ship.markerData[markerId] = json[i].station; //根据merkerId记录marker所对应数据 //添加点击事件 2D var marker = map2DViewer.markers[markerId]; marker.on('click', function (e) { ship.showPopup(e); }); } } //判断是否有重复图层,有则替换 if (!ship.layer || !ship.layer.tLayer || ship.isHide) { meteo.c.map.removeLayer(layerId); } if (ship.layer.cLayer) { meteo.c.map.removeLayer(ship.layer.cLayer); } ship.layer.cLayer = layerId; ship.isLoad = false; }, getLevel: function (zoom) { //根据地图缩放等级获取风羽疏密等级 var level = zoom < 3 ? 5 : zoom < 5 ? 3 : zoom < 6 ? 2 : 1; return level; }, getPopup : function () { }, showPopup: function (e) { //固定位置弹窗 var station = ship.markerData[e.target.guid]; if (station) { meteo.c.http.httpFunction(meteo.c.http.shipInfo, station, null, function (json) { var content = "