zengh
2022-05-16 63ad2c3598400370dd7da5534659fd7e768a0a4a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/**
 * 时间轴widget
 * @author Liuyl
 * @date 2015/10/15
 */
define([
    "dojo/_base/declare", "dojo/_base/array", "dojo/_base/lang",
    "dojo/dom", "dojo/dom-style", "dojo/dom-class", "dojo/dom-attr", "dojo/dom-construct",
    "dojo/topic",
    "dijit/_WidgetBase", "dijit/_TemplatedMixin",
    "dojo/text!controls/timeliner/TimeLinerControl.html",
    "base/BaseControl", "base/AppEvent","base/ConfigData",
    "controls/timeliner/js/jquery.timeliner.min"
], function(
    declare, arrayUtil, lang,
    dom, domStyle, domClass, domAttr, domConstruct,
    topic,
    _WidgetBase, _TemplatedMixin,
    template,
    BaseControl, AppEvent,ConfigData
) {
    var Widget = declare("TimeLinerControl", [BaseControl], {
        templateString: template,
        baseClass: "timeliner-base",
        constructor: function(options) {
            this._map = options.map;
        },
        startup: function() {
            var thisobj = this;
            this.inherited(arguments);
            AppEvent.addAppEventListener(AppEvent.LOAD_OTHERTIMELAYER, lang.hitch(this, function(evt) {
                if(dojo.byId("all")){
                    dojo.destroy("all");
                }
                if(dojo.byId("bar_div")){
                    dojo.destroy("bar_div");
                }
                var all=domConstruct.create("div", {
                    id: "all",
                    style:"height: 106px;width:100%;",
                }, this.domNode);
                var bar_div=domConstruct.create("div", {
                    id: "bar_div",
                    style:"height: 53px;width:100%;background-color: #fff;margin-top: -43px;",
                }, this.domNode);
                var all_div=domConstruct.create("div", {
                    style:"width: 600px;margin: 0px auto;height: 88px;",
                }, all);
                domConstruct.create("div", {
                    id: "start",
                    style:"float:left;margin-top: 77px;"
                }, all_div);    
                domConstruct.create("ul", {
                    id: "example1",
                    class: "timeliner",
                    style:"float:left;"
                },all_div);    
                domConstruct.create("div", {
                    id: "end",
                    style:"float:left;margin-top: 77px;"
                }, all_div);    
                var close_btn=domConstruct.create("div", {
                    id: "butt",
                }, all_div);
                $("#start").html("起始年份");
                $("#end").html("结束年份");
                $("#butt").html("X");
                for ( var int = 0; int < evt.times.length; int++) {
                    domConstruct.create("li", {
                        title: evt.times[int].name
                    }, "example1");
                }
                var lay=evt.times;
                $("#butt").on("click",function(event,clear) {
                     for ( var y = 0; y <lay.length; y++) {
                        if(!lay[y].init){
                            thisobj._map.removeLayer(lay[y].layer);
                          }
                      }
                     if(!clear){
                         for ( var y = 0; y <lay.length; y++) {
                             if(lay[y].init){
                                 thisobj._map.addLayer(lay[y].layer);
                             }
                         }
                     }
                     
                     dojo.destroy("all");
                     dojo.destroy("bar_div");
                });
                $('#example1').timeliner({times:evt.times,map:thisobj._map});
                $.fn.timeliner.inityear(2);
            }));
        },
        show: function() {
            
        },
        hide: function() {
            
        }
    });
    return Widget;
});