zengh
2020-11-13 8274f20d8093486dc3d54e074d25b6e412f4e4c7
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
define([
    'dojo/_base/declare',
    'dojo/_base/lang',
    'dojo/_base/array',
    'dojo/_base/html',
    'dojo/topic',
    'jimu/BaseWidget',
],
    function (declare,
        lang,
        array,
        html,
        topic,
        BaseWidget
    ) {
        return declare([BaseWidget], {
            baseClass: 'jimu-widget-CoorPosition',
            name: 'CoorPosition',
            startup: function () {
                var that = this;
                // 点击x隐藏面板
                $('.CoorPosition-zbdw-x').click(function () {
                    $('.jimu-widget-CoorPosition').hide();
                })
 
                // 鼠标移入显示箭头
                $('.mouseenterJD').mouseenter(function () {
                    $('.jiantou.jinddu').css('display', 'block');
                })
                $('.mouseenterJD').mouseleave(function () {
                    $('.jiantou.jinddu').css('display', 'none');
                })
 
                $('.mouseenterED').mouseenter(function () {
                    $('.jiantou.weidu').css('display', 'block');
                })
                $('.mouseenterED').mouseleave(function () {
                    $('.jiantou.weidu').css('display', 'none');
                })
 
                $('.mouseenterGD').mouseenter(function () {
                    $('.jiantou.gaodu').css('display', 'block');
                })
                $('.mouseenterGD').mouseleave(function () {
                    $('.jiantou.gaodu').css('display', 'none');
                })
 
                // 点击箭头增加或减少数字
                $('#jingdu-th').click(function () {
                    $('#jingdu-val').val(parseInt($('#jingdu-val').val()) + 1);
                })
                $('#jingdu-td').click(function () {
                    $('#jingdu-val').val(parseInt($('#jingdu-val').val()) - 1);
                })
 
                $('#weidu-th').click(function () {
                    $('#weidu-val').val(parseInt($('#weidu-val').val()) + 1);
                })
                $('#weidu-td').click(function () {
                    $('#weidu-val').val(parseInt($('#weidu-val').val()) - 1);
                })
                $('#gaodu-th').click(function () {
                    $('#gaodu-val').val(parseInt($('#gaodu-val').val()) + 1);
                })
                $('#gaodu-td').click(function () {
                    $('#gaodu-val').val(parseInt($('#gaodu-val').val()) - 1);
                })
 
                // 拖拽盒子
                $('.CoorPosition-zbdw').mousedown(function (e) {
                    var positionDiv = $(this).offset();
                    var distenceX = e.pageX - positionDiv.left;
                    var distenceY = e.pageY - positionDiv.top;
 
                    $(document).mousemove(function (e) {
                        var x = e.pageX - distenceX;
                        var y = e.pageY - distenceY;
                        if (x < 0) {
                            x = 0;
                        } else if (x > $(document).width() - $('.CoorPosition-zbdw').outerWidth(true)) {
                            x = $(document).width() - $('.CoorPosition-zbdw').outerWidth(true);
                        }
                        if (y < 0) {
                            y = 0;
                        } else if (y > $(document).height() - $('.CoorPosition-zbdw').outerHeight(true)) {
                            y = $(document).height() - $('.jimu-widget-CoorPosition').outerHeight(true);
                        }
                        $('.jimu-widget-CoorPosition').css({
                            'left': x + 'px',
                            'top': y + 'px'
                        });
                    });
                    $(document).mouseup(function () {
                        $(document).off('mousemove');
                    });
                });
 
                // 点击确定flyTo
                $('.queDing').click(function () {
                    console.log($('#jingdu-val').val());
                    var lng = $('#jingdu-val').val();
                    var lat = $('#weidu-val').val();
                    var gaodu = $('#gaodu-val').val();
                    that.map.camera.flyTo({
                        destination: Cesium.Cartesian3.fromDegrees(lng, lat, gaodu)
                    });
                })
 
            },
 
            onOpen: function () {
 
            },
 
            onClose: function () {
                //面板关闭的时候触发 (when this panel is closed trigger)
            },
 
            onMinimize: function () {
                this.resize();
            },
 
            onMaximize: function () {
                this.resize();
            },
 
            resize: function () {
 
            },
 
            destroy: function () {
                //销毁的时候触发
                //todo
                //do something before this func
                this.inherited(arguments);
            }
 
        });
    });