liuyg
2021-07-02 25ce610f6ecca7325e7a743dc032c4a76559c63d
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
///////////////////////////////////////////////////////////////////////////
// Copyright © 2019 zhongsong. All Rights Reserved.
// 模块描述: 查询定位
///////////////////////////////////////////////////////////////////////////
define(['dojo/_base/declare', 'dojo/_base/lang', 'dojo/_base/array', 'dojo/_base/html', "dojo/topic", 'jimu/BaseWidget', 'dojo/on', 'dstore/Memory', 'dstore/Trackable', 'dgrid/Grid', 'dgrid/Keyboard', 'dgrid/Selection', 'dstore/RequestMemory', 'dgrid/test/data/createSyncStore', './CommonPointLayer3D', "libs/jquery.pagination"], function (declare, lang, array, html, topic, BaseWidget, on, Memory, Trackable, Grid, Keyboard, Selection, RequestMemory, createSyncStore, CommonPointLayer3D) {
    return declare([BaseWidget], {
        baseClass: 'jimu-widget-Location',
        name: 'Location',
        layer: null,
        mapsId: [],
        graph: [],
        shape: null,
        DWindex: 0,
        startup: function startup() {
            // 数组用于存放添加点的Id删除实体点的时候会用到
            var pointId = [];
 
            // 鼠标事件
            var waterEntity;
            // 点击绘制按钮开始绘制
            var that = this;
            var yanmo;
            var flag = false;
            var flagScend = false;
            // 海拔
            var altitude = [];
            var drawingMode = 'polygon';
            var activeShape;
            var boildOne = null;
            var boildTwo = null;
            var boildThree = null;
            // 向三维场景中添加的点的集合
            var tempPoints = [];
 
            var positions = [];
            var handler = new Cesium.ScreenSpaceEventHandler(that.map.scene.canvas);
            var maps = "";
 
            this.layer = new CommonPointLayer3D({
                id: 'location',
                map: this.map
            });
 
            var self = this;
            var flag = true;
 
            // 暴露在外的接口
            topic.subscribe("Re/graph", lang.hitch(this, this.drawShape));
 
            var patterning;
            $('.dongDraw').click(function () {
 
                //矩形
                if ($(this)[0].id == "rectangle") {
                    patterning = "rectangle";
                    //圆形
                } else if ($(this)[0].id == "circle") {
                    patterning = "circle";
                    //多边形
                } else if ($(this)[0].id == "polygon") {
                    patterning = "polygon";
                }
 
                $(".location-m-style").hide();
                self.DWindex = 0;
 
                maps = "";
                $("#loc-tab1-grid").html("");
                $("#loc-tab2-grid").html("");
                $("#loc-tab3-grid").html("");
                that.deleteEntitys(that, pointId, that.shape, boildOne, boildTwo, boildThree, waterEntity, that.mapsId);
 
                $('#dong_time').val(0.5);
                $('.dong-progress .container #progress_bar').width(0);
                $('.dong-progress').stop().hide();
                $('#dong_echarts').stop().hide();
                $('.jimu-widget-AnalysisOfBarrierLake p').stop().hide();
                //if (handler != null) handler.destroy();
                handler = new Cesium.ScreenSpaceEventHandler(that.map.scene.canvas);
 
                clearInterval(yanmo);
                yanmo = null;
                positions = [];
                var polygon = null;
                var cartesian = null;
                var floatingPoint; //浮动点
                var activeShapePoints = [];
                var active = null;
                tempPoints = [];
                altitude = [];
                that.map.scene.globe.depthTestAgainstTerrain = false;
 
                // handler = new Cesium.ScreenSpaceEventHandler(that.map.scene.canvas);
                // 取消双击事件-追踪该位置
                that.map.cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
 
                // 鼠标左键点击事件
                handler.setInputAction(function (movement) {
                    // 给鼠标点击增加的点添加随机的ID便于删除
                    var randomId = Math.random() * 100 + 8 + (Math.random() * 500 + 102);
 
                    var ray = that.map.camera.getPickRay(movement.position);
                    cartesian = that.map.scene.globe.pick(ray, that.map.scene);
                    if (positions.length == 0) {
                        positions.push(cartesian.clone());
                        flagScend = true;
                    }
                    // positions.pop();
                    positions.push(cartesian);
                    // 向三维场景中添加点
                    var cartographic = Cesium.Cartographic.fromCartesian(positions[positions.length - 1]);
                    var longitudeString = Cesium.Math.toDegrees(cartographic.longitude);
                    var latitudeString = Cesium.Math.toDegrees(cartographic.latitude);
                    var heightString = cartographic.height;
                    tempPoints.push({
                        lon: longitudeString,
                        lat: latitudeString,
                        hei: heightString
                    });
                    altitude.push(Math.round(cartographic.height));
                    if (Cesium.defined(cartesian)) {
                        if (activeShapePoints.length === 0) {
                            floatingPoint = that.map.entities.add({
                                // 给实体点添加ID
                                id: '1a-2b-3c',
                                name: '多边形面积',
                                position: positions[positions.length - 1],
                                point: {
                                    pixelSize: 6,
                                    color: Cesium.Color.RED,
                                    heightReference: Cesium.HeightReference.CLAMP_TO_GROUND
                                }
                            });
                            pointId.push('1a-2b-3c');
 
                            activeShapePoints.push(cartesian);
                            var dynamicPositions = new Cesium.CallbackProperty(function () {
                                if (drawingMode === 'polygon') {
                                    return new Cesium.PolygonHierarchy(activeShapePoints);
                                }
                                return activeShapePoints;
                            }, false);
                            that.graph = dynamicPositions;
                            active = that.drawShape(patterning); //绘制动态图
                        }
                        activeShapePoints.push(cartesian);
                        floatingPoint = that.map.entities.add({
                            // 给实体点添加ID
                            id: randomId,
                            name: '多边形面积',
                            position: positions[positions.length - 1],
                            point: {
                                pixelSize: 6,
                                color: Cesium.Color.RED,
                                heightReference: Cesium.HeightReference.CLAMP_TO_GROUND
                            }
                        });
 
                        pointId.push(randomId);
                    }
                }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
 
                // 鼠标移动事件
                handler.setInputAction(function (event) {
                    if (positions.length == 0) {
                        that.map.entities.remove(boildOne);
                        var pick1 = new Cesium.Cartesian2(event.endPosition.x, event.endPosition.y);
                        var newPosition = that.map.scene.globe.pick(viewer.camera.getPickRay(pick1), that.map.scene);
                        boildOne = that.map.entities.add({
                            position: newPosition,
                            label: {
                                show: true,
                                text: '单击开始绘制',
                                font: '16px',
                                pixelOffset: new Cesium.Cartesian2(80, 0),
                                showBackground: true,
                                backgroundColor: Cesium.Color.fromBytes(126, 126, 126, 210)
                            }
                        });
                    }
                    if (positions.length == 2) {
                        that.map.entities.remove(boildOne);
                        that.map.entities.remove(boildTwo);
                        var pick1 = new Cesium.Cartesian2(event.endPosition.x, event.endPosition.y);
                        var newPosition = that.map.scene.globe.pick(viewer.camera.getPickRay(pick1), that.map.scene);
                        boildTwo = that.map.entities.add({
                            position: newPosition,
                            label: {
                                show: true,
                                text: '单击增加点',
                                font: '16px',
                                pixelOffset: new Cesium.Cartesian2(80, 0),
                                showBackground: true,
                                backgroundColor: Cesium.Color.fromBytes(126, 126, 126, 210)
                            }
                        });
                    }
                    if (positions.length > 2) {
                        that.map.entities.remove(boildOne);
                        that.map.entities.remove(boildTwo);
                        that.map.entities.remove(boildThree);
                        var pick1 = new Cesium.Cartesian2(event.endPosition.x, event.endPosition.y);
                        var newPosition = that.map.scene.globe.pick(viewer.camera.getPickRay(pick1), that.map.scene);
                        boildThree = that.map.entities.add({
                            position: newPosition,
                            label: {
                                show: true,
                                text: '单击增加点,右键点击完成绘制',
                                font: '16px',
                                pixelOffset: new Cesium.Cartesian2(120, 0),
                                showBackground: true,
                                backgroundColor: Cesium.Color.fromBytes(126, 126, 126, 210)
                            }
                        });
                    }
 
                    if (Cesium.defined(floatingPoint)) {
                        var pick1 = new Cesium.Cartesian2(event.endPosition.x, event.endPosition.y);
                        var newPosition = that.map.scene.globe.pick(viewer.camera.getPickRay(pick1), that.map.scene);
                        if (Cesium.defined(newPosition)) {
                            floatingPoint.position.setValue(newPosition);
                            activeShapePoints.pop();
                            activeShapePoints.push(newPosition);
                        }
                    }
                }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
 
                // 鼠标右键点击事件
                handler.setInputAction(function (movement) {
                    var cartographic = Cesium.Cartographic.fromCartesian(that.map.scene.globe.pick(that.map.camera.getPickRay(movement.position), that.map.scene));
                    // 向三维场景中添加点
                    var longitudeString = Cesium.Math.toDegrees(cartographic.longitude);
                    var latitudeString = Cesium.Math.toDegrees(cartographic.latitude);
                    var heightString = cartographic.height;
                    tempPoints.push({
                        lon: longitudeString,
                        lat: latitudeString,
                        hei: heightString
                    });
 
                    positions.push(activeShapePoints[activeShapePoints.length - 1]);
                    if (positions.length >= 2) {
                        if (!Cesium.defined(polygon)) {
                            polygon = new PolygonPrimitive(positions);
                        } else {
                            positions.pop();
                            positions.push(cartesian);
                        }
                    }
                    if (activeShapePoints.length) {
                        that.graph = activeShapePoints;
                        activeShape = that.drawShape(patterning); //绘制最终图
                    }
                    // that.map.entities.remove(floatingPoint);
                    that.map.entities.remove(active);
                    that.map.entities.remove(boildOne);
                    that.map.entities.remove(boildTwo);
                    that.map.entities.remove(boildThree);
                    if (!flagScend) return;
                    flagScend = false;
                    altitude.push(Math.round(cartographic.height));
                    altitude.sort(function (a, b) {
                        if (a > b) return 1;else if (a < b) return -1;else return 0;
                    });
                    $('#dong_max_height').val(altitude[altitude.length - 1]);
                    $('#dong_min_height').val(altitude[0]);
                    handler.destroy();
                    flag = true;
 
                    // 提取坐标信息
                    var list = waterEntity.polygon.hierarchy.getValue().positions;
                    // 存放坐标信息,做请求数据使用
                    var echartRings = [[]];
 
                    // 处理坐标信息,将世界坐标转换成经纬度
                    for (var i = 1; i < list.length; i++) {
                        var cartographic = Cesium.Cartographic.fromCartesian(list[i]);
                        var lat = Cesium.Math.toDegrees(cartographic.latitude);
                        var lng = Cesium.Math.toDegrees(cartographic.longitude);
                        echartRings[0].push(["[" + lng, lat + "]"]);
                    }
                    // 发请求数据
                    maps = '{"rings":[[' + echartRings + ']],"spatialReference": {"wkid": 4490}}';
 
                    return;
                }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
 
                var PolygonPrimitive = function () {
                    function _(positions) {
                        this.options = {
                            name: '多边形',
                            polygon: {
                                hierarchy: [],
                                material: Cesium.Color.WHITE.withAlpha(0)
                            }
                        };
 
                        this.positions = positions;
                        this._init();
                    }
                    _.prototype._init = function () {
                        var _self = this;
                        //实时更新polygon.hierarchy
                        this.options.polygon.hierarchy = new Cesium.CallbackProperty(function () {
                            return new Cesium.PolygonHierarchy(positions);
                        }, false);
                        waterEntity = that.map.entities.add(this.options);
                        that.fixedWaterEntity = waterEntity;
                    };
                    return _;
                }();
            });
 
            $('#loc_delet').click(function () {
                //隐藏分页栏,清除分页下标
                $(".location-m-style").hide();
                self.DWindex = 0;
 
                maps = "";
                that.deleteEntitys(that, pointId, that.shape, boildOne, boildTwo, boildThree, waterEntity, that.mapsId);
                $("#loc-tab1-grid").html("");
                $("#loc-tab2-grid").html("");
                $("#loc-tab3-grid").html("");
                $('#loc_input').val("");
            });
 
            $('.location-head-th-xx').click(function () {
                //隐藏分页栏,清除分页下标
                $(".location-m-style").hide();
                self.DWindex = 0;
 
                maps = "";
                that.deleteEntitys(that, pointId, that.shape, boildOne, boildTwo, boildThree, waterEntity, that.mapsId);
                $("#loc-tab1-grid").html("");
                $("#loc-tab2-grid").html("");
                $("#loc-tab3-grid").html("");
                $('#loc_input').val("");
 
                $('.jimu-widget-Location').hide();
            });
 
            $('#loc_query').click(function () {
 
                // 获取当前选中的文本
                var target = document.getElementsByClassName("loc_click on");
                var txt = target[0].innerText;
                var input = $('#loc_input').val();
                var where = "";
                self.DWindex = 0;
 
                if (txt == '水文站') {
                    url = "http://171.35.109.175:18080/arcgis/rest/services/GZSW/swzwzt/MapServer/0/query";
                    where = "STNM like '%" + input + "%'";
                } else if (txt == '水位站') {
                    url = "http://171.35.109.175:18080/arcgis/rest/services/GZSW/swzwzt/MapServer/1/query";
                    where = "STNM like '%" + input + "%'";
                } else if (txt == '雨量站') {
                    url = "http://171.35.109.175:18080/arcgis/rest/services/GZSW/swzwzt/MapServer/2/query";
                    where = "STNM like '%" + input + "%'";
                } else if (txt == '水质站') {
                    url = "http://171.35.109.175:18080/arcgis/rest/services/GZSW/swzwzt/MapServer/3/query";
                    where = "zhswStationName like '%" + input + "%'";
                } else if (txt == '中小河流站') {
                    url = "http://171.35.109.175:18080/arcgis/rest/services/GZSW/swzwzt/MapServer/4/query";
                    where = "STNM like '%" + input + "%'";
                }
 
                if (input != "" || maps != "") {
                    self.getLocData(url, self, txt, maps, where);
                } else if (input == "") {
                    self.getLocData(url, self, txt, maps, "1=1");
                }
            });
 
            $('.loc_click').on('click', function () {
                // 当前选中添加类名,兄弟移除类名
                $(this).removeClass("off").addClass("on").siblings().removeClass("on").addClass("off");
 
                $('#loc_query').click();
 
                // 获取当前选中的文本
                var txt = $(this).text();
                // 调方法,将文本传进去,做判断,是否显示或者隐藏
                self.tab(txt);
            });
 
            //地图定位
            $('.location-box-list').on('click', '.location-lb', function (event) {
                var index = $(this).index() + self.DWindex;
                topic.publish("gis/map/setCenter", {
                    'lgtd': datas[index].x,
                    'lttd': datas[index].y
                }); //进行地图定位
            });
            //打开水面线工具
            $('#loc_openWin').click(function () {
                that.deleteEntitys(that, pointId, that.shape, boildOne, boildTwo, boildThree, waterEntity, []);
                $('.jimu-widget-DynamicRiver').show();
                topic.publish("openWin", {});
            });
 
            this.closeDeleteEntity = function () {
                that.deleteEntitys(that, pointId, that.shape, boildOne, boildTwo, boildThree, waterEntity, that.mapsId);
            };
        },
 
        // 控制显示隐藏
        tab: function tab(pid) {
            if (pid == "水文站") {
                document.getElementById('SWZD').style.display = "block";
                document.getElementById('SWZ').style.display = "none";
                document.getElementById('YLZ').style.display = "none";
                document.getElementById('SZZ').style.display = "none";
                document.getElementById('ZXHLZ').style.display = "none";
            } else if (pid == "水位站") {
                document.getElementById('SWZD').style.display = "none";
                document.getElementById('SWZ').style.display = "block";
                document.getElementById('YLZ').style.display = "none";
                document.getElementById('SZZ').style.display = "none";
                document.getElementById('ZXHLZ').style.display = "none";
            } else if (pid == "雨量站") {
                document.getElementById('SWZD').style.display = "none";
                document.getElementById('SWZ').style.display = "none";
                document.getElementById('YLZ').style.display = "block";
                document.getElementById('SZZ').style.display = "none";
                document.getElementById('ZXHLZ').style.display = "none";
            } else if (pid == "水质站") {
                document.getElementById('SWZD').style.display = "none";
                document.getElementById('SWZ').style.display = "none";
                document.getElementById('YLZ').style.display = "none";
                document.getElementById('SZZ').style.display = "block";
                document.getElementById('ZXHLZ').style.display = "none";
            } else if (pid == "中小河流站") {
                document.getElementById('SWZD').style.display = "none";
                document.getElementById('SWZ').style.display = "none";
                document.getElementById('YLZ').style.display = "none";
                document.getElementById('SZZ').style.display = "none";
                document.getElementById('ZXHLZ').style.display = "block";
            }
        },
        getLocData: function getLocData(url, self, txt, maps, where) {
            $.ajax({
                url: url,
                type: 'post',
                dataType: 'json',
                data: {
                    f: 'pjson',
                    Where: where,
                    outFields: "*",
                    geometry: maps,
                    geometryType: "esriGeometryPolygon"
                },
                success: function success(result) {
                    datas = [];
                    if (result.features.length > 0) {
                        for (var i = 0; i < result.features.length; i++) {
                            if (result.features[i].attributes.STCD != 0 && result.features[i].attributes.STCD != null) {
                                datas.push($.extend(result.features[i].attributes, result.features[i].geometry));
                                self.mapsId.push("location" + result.features[i].attributes.OBJECTID);
                            }
                        };
                    }
 
                    //同时显示到layer
                    self.layer.getData(datas, txt, this);
 
                    var cont = Math.ceil(datas.length / 5);
                    $('.Pagination').pagination({
                        mode: 'fixed',
                        jump: true,
                        coping: false,
                        pageCount: cont,
                        count: 3,
                        callback: function callback(index) {
                            var listdata = [];
                            //显示页数
                            self.DWindex = (index.getCurrent() - 1) * 5;
                            var index = self.DWindex;
                            for (var i = index; i < index + 5; i++) {
                                listdata.push(datas[i]);
                                if (i == datas.length - 1) {
                                    break;
                                }
                            }
                            self.createTable(listdata, txt);
                            self.layer.updateColor(listdata, txt);
                        }
                    });
 
                    //首次加载前5条数据
                    var data = [];
                    if (datas.length > 5) {
                        for (var i = 0; i < 5; i++) {
                            data.push(datas[i]);
                        }
                    } else {
                        for (var i = 0; i < datas.length; i++) {
                            data.push(datas[i]);
                        }
                    }
                    self.createTable(data, txt);
                    self.layer.updateColor(data, txt);
                }
            });
        },
        createTable: function createTable(data, txt) {
            var column, tab;
            $('#location-tab .location-box-list').empty();
            var CustomGrid = declare([Grid, Keyboard, Selection]);
            if (txt == '水文站') {
                if (data.length > 0) {
                    for (var i = 0; i < data.length; i++) {
                        var div = "<div class='location-lb'>" +
                        //'<img style="width: 20px;height: 20px" src=http://www.sw797.com:10011/gzsw3D/v2/images/icon/swenz.png>'+
                        '<a>' + (i + 1 + this.DWindex) + '、' + data[i].STNM + '</a>' + '&ensp;(' + data[i].STCD + ')' + '<div class=location-zb><lable>所在乡镇:</lable>' + data[i]['所在乡镇、'] + '</div>' + "</div>";
                        $("#loc-tab1-grid").append(div);
                    }
                } else {
                    var div = "<div class='location-lb'><a>无数据</a></div>";
                    $("#loc-tab1-grid").append(div);
                }
            } else if (txt == '水位站') {
                if (data.length > 0) {
                    for (var i = 0; i < data.length; i++) {
                        var div = "<div id='location-lb' class='location-lb'>" +
                        //'<img style="width: 20px;height: 20px" src=http://www.sw797.com:10011/gzsw3D/v2/images/icon/swenz.png>'+
                        '<a>' + (i + 1 + this.DWindex) + '、' + data[i].STNM + '</a>' + '&ensp;(' + data[i].STCD + ')' + '<div class=location-zb><lable>所在乡镇:</lable>' + data[i]['所在乡镇、'] + '</div>' + "</div>";
                        $("#loc-tab2-grid").append(div);
                    }
                } else {
                    var div = "<div class='location-lb'><a>无数据</a></div>";
                    $("#loc-tab2-grid").append(div);
                }
            } else if (txt == '雨量站') {
                if (data.length > 0) {
                    for (var i = 0; i < data.length; i++) {
                        var div = "<div id='location-lb' class='location-lb'>" +
                        //'<img style="width: 20px;height: 20px" src=http://www.sw797.com:10011/gzsw3D/v2/images/icon/swenz.png>'+
                        '<a>' + (i + 1 + this.DWindex) + '、' + data[i].STNM + '</a>' + '&ensp;(' + data[i].STCD + ')' + '<div class=location-zb><lable>所在乡镇:</lable>' + data[i]['所在乡镇、村'] + '</div>' + "</div>";
                        $("#loc-tab3-grid").append(div);
                    }
                } else {
                    var div = "<div class='location-lb'><a>无数据</a></div>";
                    $("#loc-tab3-grid").append(div);
                }
            } else if (txt == '水质站') {
                tab = 'loc-tab4-grid';
            } else if (txt == '中小河流站') {
                tab = 'loc-tab5-grid';
            }
        },
        drawShape: function drawShape(patterning) {
            var that = this;
            //当positionData为数组时绘制最终图,如果为function则绘制动态图
            var arr = typeof that.graph.getValue === 'function' ? that.graph.getValue(0).positions : that.graph;
 
            //矩形
            if (patterning == "rectangle") {
                that.shape = that.map.entities.add({
                    rectangle: {
                        coordinates: new Cesium.CallbackProperty(function () {
                            var obj = Cesium.Rectangle.fromCartesianArray(arr);
                            //if(obj.west==obj.east){ obj.east+=0.000001};
                            //if(obj.south==obj.north){obj.north+=0.000001};
                            return obj;
                        }, false),
                        material: Cesium.Color.RED.withAlpha(0.5)
                    }
                });
                that.fixedShape = that.shape;
                //圆形
            } else if (patterning == "circle") {
                that.shape = that.map.entities.add({
                    position: arr[0],
                    name: 'Blue translucent, rotated, and extruded ellipse with outline',
                    type: 'Selection tool',
                    ellipse: {
                        semiMinorAxis: new Cesium.CallbackProperty(function () {
                            //半径 两点间距离
                            var r = Math.sqrt(Math.pow(arr[0].x - arr[arr.length - 1].x, 2) + Math.pow(arr[0].y - arr[arr.length - 1].y, 2));
                            return r ? r : r + 1;
                        }, false),
                        semiMajorAxis: new Cesium.CallbackProperty(function () {
                            var r = Math.sqrt(Math.pow(arr[0].x - arr[arr.length - 1].x, 2) + Math.pow(arr[0].y - arr[arr.length - 1].y, 2));
                            return r ? r : r + 1;
                        }, false),
                        material: Cesium.Color.BLUE.withAlpha(0.5),
                        outline: true
                    }
                });
                that.fixedShape = that.shape;
                //多边形
            } else if (patterning == "polygon") {
                that.shape = that.map.entities.add({
                    polygon: {
                        hierarchy: that.graph,
                        material: Cesium.Color.fromBytes(252, 193, 10, 130)
                    }
                });
                that.fixedShape = that.shape;
            }
 
            return that.shape;
        },
 
        onOpen: function onOpen() {
            $('.location-m-style').hide();
            this.layer ? this.layer.setVis(true) : '';
        },
 
        onClose: function onClose() {
            $('.location-m-style').hide();
            //面板关闭的时候触发 (when this panel is closed trigger)
            $("#loc-tab1-grid").html("");
            $("#loc-tab2-grid").html("");
            $("#loc-tab3-grid").html("");
            $('#loc_input').val("");
            this.closeDeleteEntity();
            this.layer ? this.layer.setVis(false) : '';
        },
 
        onMinimize: function onMinimize() {
            this.resize();
        },
 
        onMaximize: function onMaximize() {
            this.resize();
        },
 
        resize: function resize() {},
 
        destroy: function destroy() {
            //销毁的时候触发
            //todo
            //do something before this func
            this.inherited(arguments);
        },
 
        deleteEntitys: function deleteEntitys(that, pointId, shape, boildOne, boildTwo, boildThree, waterEntity, mapsId) {
 
            if (pointId.length > 0) {
                for (var i = 0; i < pointId.length; i++) {
                    that.map.entities.removeById(pointId[i]);
                }
 
                pointId = [];
            }
 
            if (mapsId.length > 0) {
                for (var i = 0; i < mapsId.length; i++) {
                    that.map.entities.removeById(mapsId[i]);
                }
                that.mapsId = [];
            }
            that.map.entities.remove(shape);
            that.map.entities.remove(boildOne);
            that.map.entities.remove(boildTwo);
            that.map.entities.remove(boildThree);
            if (waterEntity != null) {
                that.map.entities.removeById(waterEntity._id);
            }
        }
    });
});