1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- /**
- * Created by Administrator on 2017/10/31.
- * 雷达图类
- */
- define([], function () {
- meteo.f.radar = {
- data: null, //雷达图数据存储位置
- playId: null, //雷达图动画任务id
- imgOverlay: null, //雷达图所用图层id
- showIndex: 0, //将要被显示的雷达图索引
- title: null,
- getData: function () { //获取雷达图数据
- meteo.c.http.httpFunciton(meteo.c.http.radarInfo, null, function (json) {
- var data = json["data"];
- meteo.f.radar.data = new Array(data.length);
- for (var i = 0; i < data.length; i++) {
- var value = new Object();
- value.time = data[i]["date"];
- value.slat = data[i]["slat"];
- value.slng = data[i]["slng"];
- value.elat = data[i]["elat"];
- value.elng = data[i]["elng"];
- value.url = meteo.c.http.serverUrl + data[i]["url"] + ".mkt";
- meteo.f.radar.data[i] = value;
- }
- meteo.f.radar.show();
- }, function () {
- })
- },
- show: function () { //根据索引 显示云图
- var data = meteo.f.radar.data[meteo.f.radar.showIndex];
- var layerid = meteo.c.map.createLayer();
- var imageO = map2DViewer.groups[layerid];
- var cloudImageNew = L.imageOverlay(
- data.url,
- L.latLngBounds(L.latLng(data.slat, data.slng), L.latLng(data.elat, data.elng))
- ).addTo(imageO);
- cloudImageNew.on("load", function (e) {
- if (meteo.f.radar.imgOverlay != null) {
- meteo.c.map.removeLayer(meteo.f.radar.imgOverlay);
- }
- meteo.f.radar.imgOverlay = layerid;
- });
- if (meteo.f.radar.title) {
- meteo.c.title.removeTitle(meteo.f.radar.title);
- }
- meteo.f.radar.title = '雷达图 ' + meteo.f.radar.data[meteo.f.radar.showIndex].time;
- meteo.c.title.addTitle(meteo.f.radar.title);
- },
- remove: function () {
- if (meteo.f.radar.imgOverlay != null) {
- meteo.f.radar.imgOverlay.remove();
- }
- title.removeTitle(meteo.f.radar.title);
- meteo.f.radar.imgOverlay = null;
- },
- play: function () { //云图动画
- if (meteo.f.radar.playId) {
- window.clearInterval(meteo.f.radar.playId);
- meteo.f.radar.playId = null;
- } else {
- meteo.f.radar.playId = window.setInterval(function () {
- meteo.f.radar.showIndex++;
- if (meteo.f.radar.showIndex == meteo.f.radar.data.length) {
- meteo.f.radar.showIndex = 0;
- }
- meteo.f.radar.show();
- }, 1000);
- }
- },
- init: function (b1, b2) {
- $(b1).click(function () {
- if (meteo.f.radar.imgOverlay) {
- if (meteo.f.radar.playId) {
- meteo.f.radar.play();
- }
- meteo.f.radar.remove();
- } else {
- meteo.f.radar.getData();
- }
- });
- $(b2).click(function () {
- if (meteo.f.radar.imgOverlay) {
- meteo.f.radar.play();
- }
- });
- }
- }
- return meteo.f.radar;
- })
|