赣州市洪水风险预警系统二维版本
xiebin
2023-03-02 b39483c96ae572121d3c619c0b9d37634e682cc4
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
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
define([
    "dojo",
    "dojo/_base/declare",
    "dojo/_base/lang",
    "base/BaseWidget",
    "dojo/text!widgets/mapBrowse/template.html",
    "widgets/mapBrowse/config",
    "widgets/myModules/monitorSpots",
    "base/AppEvent",
    "base/ConfigData",
    "iframe/jcyj/js/dataShow.js",
    "dojo/dom",
    "dojo/dom-construct",
    "dojo/dom-attr",
    "dojo/dom-style",
    "dojo/on",
    "esri/layers/ArcGISDynamicMapServiceLayer",
    "esri/layers/ArcGISTiledMapServiceLayer",
    "esri/layers/FeatureLayer",
    "controls/tab/TabControl",
    "esri/dijit/SymbolStyler",
    "esri/styles/basic",
    "dojo/_base/array",
    "esri/InfoTemplate",
    "esri/renderers/SimpleRenderer",
    "esri/renderers/ClassBreaksRenderer",
    "esri/renderers/UniqueValueRenderer",
    "esri/symbols/PictureMarkerSymbol",
    "esri/layers/GraphicsLayer",
    "esri/graphic",
    "dojo/domReady!"
], function (dojo,
             declare,
             lang,
             BaseWidget,
             template,
             config,
             monitorSpots,
             AppEvent,
             ConfigData,
             dataShow,
             dom,
             domConstruct,
             domAttr,
             domStyle,
             on,
             ArcGISDynamicMapServiceLayer,
             ArcGISTiledMapServiceLayer,
             FeatureLayer,
             TabControl,
             SymbolStyler,
             basic,
             arrayUtils,
             InfoTemplate,
             SimpleRenderer,
             ClassBreaksRenderer,
             UniqueValueRenderer,
             PictureMarkerSymbol,
             GraphicsLayer,
             Graphic) {
    var imgDiv = [];
    var vedioDiv = '';
    var docuDiv = '';
    var panoUrl = '';
    var Widget = declare([BaseWidget], {
        widgetName: "MapBrowseWidget",
        label: "地图浏览",
        templateString: template,
        _map: null,
        _layers: [],
        _styler: null,
        _selectLayer: null,
        MapBrowseObj: null,
        treecheck: null,
        treechecked: null,
        _clicklayer: null,
        _historyBack: null,
        content: null,
        monitorLayer: null,
        constructor: function (options, srcRefNode) {
            this._map = options.map;
            //初始化监测站点图层
            this.monitorLayer = new GraphicsLayer({id: 'monitorLayer'});
            this.monitorLayer.on('click', this.monitorSpotsOnClick);
            this._map.addLayer(this.monitorLayer);
        },
        postCreate: function () {
 
        },
        startup: function () {
            MapBrowseObj = this;
            MapBrowseObj.treecheck = [];
            this._init();
            this.inherited(arguments);
            $('#rMenu').mouseleave(function () {
                $('#rMenu').css({
                    "visibility": "hidden"
                });
                $('#Transparency').css({
                    "visibility": "hidden",
                });
            });
            $('#Transparency').mouseleave(function (evt) {
                $('#Transparency').css({
                    "visibility": "hidden",
                });
            });
            $('#m_del').mouseover(function (evt) {
                $('#Transparency').css({
                    "visibility": "visible",
                });
                $('#rangechange').val(MapBrowseObj._clicklayer.opacity);
            });
            $('#rangechange').change(function (evt) {
                var zhi = $('#rangechange').val();
                MapBrowseObj._setlayeropacity(zhi * 1);
            });
 
            // 绑定tab切换事件--点击切换状态并控制相应的tab标签显示
            $('.tab-container li').click(function () {
                var tabName = $(this).attr('data');
                var containerName = tabName + '-container';
                if (tabName && !$(this).hasClass('tab-selected')) {
                    $('.container-show').removeClass('container-show');
                    switch (tabName) {
                        case 'introduce':
                            $('.tab-selected img').attr('src', 'widgets/mapBrowse/images/layer.png');
                            $('.tab-selected').removeClass('tab-selected');
                            $(this).children('img').attr('src', 'widgets/mapBrowse/images/introduce-selected.png');
                            break;
                        case 'layer':
                            $('.tab-selected img').attr('src', 'widgets/mapBrowse/images/introduce.png');
                            $('.tab-selected').removeClass('tab-selected');
                            $(this).children('img').attr('src', 'widgets/mapBrowse/images/layer-selected.png');
                            break;
                        default:
                            break;
                    }
                    $(this).addClass('tab-selected');
                    $('.' + containerName).addClass('container-show');
                }
            });
            AppEvent.addAppEventListener("clearall", lang.hitch(this, function (evt) {
                if (evt.idname != "MapBrowseWidget") {
                    var treeObj = $.fn.zTree.getZTreeObj("mapBrowseTree");
                    var nodes = treeObj.getCheckedNodes();
                    for (var index in nodes) {
                        if (!nodes[index].isParent) {
                            if (nodes[index].checked) {
                                var nodeobj = nodes[index];
                                nodes[index].checkedOld = false;
                                MapBrowseObj._map.removeLayer(ConfigData.layers[nodes[index].tId]);
                                ConfigData.layers[nodes[index].tId] = null;
 
                                if (dojo.byId("all")) {
                                    dojo.destroy("all");
                                    dojo.destroy("bar_div");
                                }
                            }
                        }
                    }
                    MapBrowseObj._init();
                }
            }));
            //初始化自定义弹窗部件
            var mymonitorSpots = new monitorSpots();
            AppEvent.addAppEventListener('popup', lang.hitch(mymonitorSpots, function (e) {
                this.popup(e)
            }));
            
        },
        open: function () {
            this.inherited(arguments);
        },
        close: function () {
            this.inherited(arguments);
            if (MapBrowseObj._styler) {//摧毁样式弹窗
                MapBrowseObj._styler.destroy();
                MapBrowseObj._styler = null;
            }
        },
        _init: function () {
//             $.ajax({
//                 type: "get",
// //              url: ConfigData.ajaxURL,
//                 url: getNativePath() + "resources/queryResourcesTree.do?soId=bbb7001c67c442540167c4a2a604000b",
//                 data: {
//                     "limit": 10000
//                 },
//                 dataType: "json",
//                 async: true,
//                 success: function (result) {
//                     var _ztreeObj = [];
//                     var resultObj = result.data;
//                     for (var i = 0; i < resultObj.length; i++) {
//                         var searchCatalog = {};
//                         searchCatalog.id = resultObj[i].resourcesId;
//                         searchCatalog.pId = resultObj[i].resourcesPid;
//                         searchCatalog.name = resultObj[i].resourcesName;
//                         searchCatalog.Url = resultObj[i].resourcesUrl;
//                         searchCatalog.isPath = true;
//                         _ztreeObj.push(searchCatalog);
//                     }
 
//                     var setting = {
//                         view: {
//                             addHoverDom: MapBrowseObj.addHoverDom,
//                             removeHoverDom: MapBrowseObj.removeHoverDom
//                         },
//                         check: {
//                             enable: true
//                         },
//                         data: {
//                             simpleData: {
//                                 enable: true
//                             }
//                         },
//                         callback: {
//                             beforeClick: MapBrowseObj._beforeClick,
//                             onCheck: MapBrowseObj._zTreeOnCheck
//                         }
//                     };
//                     ConfigData.treeNodes = _ztreeObj;//将目录树节点存入全局
//                     var treeObj = $.fn.zTree.init($("#mapBrowseTree"), setting, _ztreeObj);
                    
                    
//                     //获取监测站点目录树
//                     $.ajax({
//                         url: ConfigData.monitorSpotURL,
//                         type: 'get',
//                         dataType: 'json',
//                         async: true,
//                         success: function (e) {
//                             var data = e.data;
// //                          console.log(data);
//                             var newNodes = [{//构造湿地监控点父节点
//                                 id: 'monitorNode',
//                                 pId: 0,
//                                 name: '湿地监控点',
//                                 children: data
//                             }];
//                             for (var eKey in data) {//父节点
//                                 data[eKey].pId = "monitorNode";
//                                 var data1 = data[eKey].children;
//                                 for (var data1Key in data1) {//第二层节点
//                                     var data2 = data1[data1Key].children;
//                                     if (!data1[data1Key].hasOwnProperty('name')) {//没有name属性就添加
//                                         data1[data1Key]['name'] = data1[data1Key].text;
//                                     }
//                                     if (data1[data1Key].hasOwnProperty('lon')) {//有没有lon/lat属性,有就添加x/y属性和isPath
//                                         data1[data1Key]['x'] = data1[data1Key].lon;
//                                         data1[data1Key]['y'] = data1[data1Key].lat;
//                                         data1[data1Key]['isPath'] = false;
//                                     }
//                                     for (var data2Key in data2) {//第三层节点
//                                         var data3 = data2[data2Key].children;
//                                         if (!data2[data2Key].hasOwnProperty('name')) {//没有name属性就添加
//                                             data2[data2Key]['name'] = data2[data2Key].text;
//                                         }
//                                         if (data2[data2Key].hasOwnProperty('lon')) {//有没有lon/lat属性,有就添加x/y属性和isPath
//                                             data2[data2Key]['x'] = data2[data2Key].lon;
//                                             data2[data2Key]['y'] = data2[data2Key].lat;
//                                             data2[data2Key]['isPath'] = false;
//                                         }
//                                         for(var data3Key in data3){//最后一层节点
//                                             if (!data3[data3Key].hasOwnProperty('name')) {//没有name属性就添加
//                                                 data3[data3Key]['name'] = data3[data3Key].text;
//                                             }
//                                             if (data3[data2Key].hasOwnProperty('lon')) {//有没有lon/lat属性,有就添加x/y属性和isPath
//                                                 data3[data3Key]['x'] = data3[data3Key].lon;
//                                                 data3[data3Key]['y'] = data3[data3Key].lat;
//                                                 data3[data3Key]['isPath'] = false;
//                                             }
//                                         }
//                                     }
//                                 }
//                             }
//                             treeObj.addNodes(null, newNodes);//给ztree添加新节点
//                         }
//                     });
//                 },
//                 error: function (e) {
//                     console.log(e);
//                     alert("请求失败");
//                 }
//             });
        },
        _beforeClick: function (treeId, treeNode) {
            if (!treeNode.path && treeNode.isParent) {
                var treeObj = $.fn.zTree.getZTreeObj(treeId);
                treeObj.expandNode(treeNode, !treeNode.open, false, true, true);
            }
            return treeNode.path && !treeNode.isParent;
        },
        _zTreeOnCheck: function (event, treeId, treeNode) {
            //复选框选择事件
            var treeObj = $.fn.zTree.getZTreeObj("mapBrowseTree");
            var nodes = treeObj.getChangeCheckedNodes(); //状态改变的节点
            for (var index in nodes) {
                //筛选根节点
                if (!nodes[index].isParent && nodes[index].Url && nodes[index].isPath) {//图层服务
                    //选中的节点
                    if (nodes[index].checked) {
                        nodes[index].checkedOld = true;
                        var nodeobj = nodes[index];
                        var layerobj = nodeobj.Url;
                        var template = new InfoTemplate();
                        template.setTitle(MapBrowseObj._getGraphicTitle);
                        template.setContent(MapBrowseObj._getTextContent);
                        var baseurl = layerobj.substring(0, layerobj.lastIndexOf('/'));
                        var i = layerobj.substring(layerobj.lastIndexOf('/') + 1, layerobj.length) * 1;
                        var selectLayer = new ArcGISDynamicMapServiceLayer(baseurl, {id: nodes[index].tId});
                        var templates = {};
                        templates[i] = {
                            infoTemplate: template
                        };
                        selectLayer.setInfoTemplates(templates);
                        selectLayer.setVisibleLayers([i]);
                        // var selectLayer = new FeatureLayer(layerobj, {infoTemplate: template, outFields: ['*'],mode: FeatureLayer.MODE_ONDEMAND,displayOnPan:false});
                        selectLayer.on("error", function (evt) {
                            var msg = evt.error.message;
                            alert(msg);
                        });
                        ConfigData.layers[nodeobj.tId] = selectLayer;
                        MapBrowseObj._map.addLayer(selectLayer);
                    } else {
                        nodes[index].checkedOld = false;
                        if (ConfigData.layers[nodes[index].tId]) {
                            MapBrowseObj._map.removeLayer(ConfigData.layers[nodes[index].tId]);
                        }
                        ConfigData.layers[nodes[index].tId] = null;
                        delete ConfigData.layers[nodes[index].tId];
                    }
                } else {//监测站点
                    if (nodes[index].checked) {//选中的节点
                        if (nodes[index].hasOwnProperty('x') && nodes[index].hasOwnProperty('y')) {//判断是否包含经纬度,包含则添加到地图上
                            nodes[index].checkedOld = true;
                            if(nodes[index].children){
                                
                            }else{
                                if (!!window.ActiveXObject || "ActiveXObject" in window){ 
                                    var isIE = true;
                                }else{
                                    var isIE = false;
                                }
                                if(isIE){
                                    var x = 5;
                                }else{
                                    var x = -4;
                                }
                                var myPoint = {
                                    "geometry": {
                                        "x": nodes[index].x,
                                        "y": nodes[index].y,
                                        "spatialReference": {"wkid": 4490}
                                    },
                                    "attributes": {
                                        id: nodes[index].id,
                                        pId: nodes[index].pId,
                                        name: nodes[index].name,
                                        quanjingUrl: nodes[index].Url || null,
                                        videoUrl: nodes[index].videoUrl || null,
                                        videoType: nodes[index].videoType || null,
                                        x: nodes[index].x,
                                        y: nodes[index].y,
                                    },
                                    "symbol": {
                                        "type": "esriPMS",
                                        "url": 'images/monitor.png',
                                        "imageData": null,
                                        "contentType": "image/png",
                                        "width": 15,
                                        "height": 20,
                                        "angle": 0,
                                        "xoffset": 0,
                                        "yoffset": 10
                                    }
                                };
                                var text = {
                                    "geometry": {
                                        "x": nodes[index].x,
                                        "y": nodes[index].y,
                                        "spatialReference": {"wkid": 4490}
                                    },
                                    "symbol": {
                                        "type": "esriTS",
                                        "color": [16, 139, 171, 255],
                                        "backgroundColor": [16, 139, 171, 255],
                                        "borderLineSize": 1,
                                        "borderLineColor": [16, 139, 171, 255],
                                        "verticalAlignment": 'bottom',//<baseline | top | middle | bottom>
                                        "horizontalAlignment": 'left',//<left | right | center | justify>
                                        "rightToLeft": true,//<true | false>
                                        "angle": 0,
                                        "xoffset": 8,
                                        "yoffset": x,
                                        "kerning": true,//<true | false>
                                        "font": {
                                            "family": "wryh",
                                            "size": 11,
                                            "style": "normal",//<italic | normal | oblique>
                                            "weight": 'bold',//<bold | bolder | lighter | normal>
                                            "decoration": 'none',//<line-through | underline | none>
                                        },
                                        "text": nodes[index].name //only applicable when specified as a client-side graphic.
                                    }
                                };
                                var gra = new Graphic(myPoint);
                                var textpt = new Graphic(text);
                                ConfigData.monitorSpots[nodes[index].tId] = [gra, textpt];
                                MapBrowseObj.monitorLayer.add(gra);
                                MapBrowseObj.monitorLayer.add(textpt);
                            }                           
                        }
                    } else {
                        nodes[index].checkedOld = false;
                        if (ConfigData.monitorSpots[nodes[index].tId]) {
                            MapBrowseObj.monitorLayer.remove(ConfigData.monitorSpots[nodes[index].tId][0]);
                            MapBrowseObj.monitorLayer.remove(ConfigData.monitorSpots[nodes[index].tId][1]);
                        }
                        ConfigData.monitorSpots[nodes[index].tId] = null;
                        delete ConfigData.monitorSpots[nodes[index].tId];
                    }
                }
            }
        },
        monitorSpotsOnClick: function (e) {
            var graphic = e.graphic;
            graphic.attributes.itemList = {
                '实时数据': '鄱阳湖国家湿地公园',
                '历史数据': '鄱阳湖国家湿地公园',
                '全景': '鄱阳湖国家湿地公园',
                '视频监控': '鄱阳湖国家湿地公园',
            };
            //派发监测点弹窗
            AppEvent.dispatchAppEvent('popup', graphic);
        },
        _getGraphicTitle: function (graphic) {
            var layer = graphic.getLayer();
            if (layer.name.indexOf("城") != -1 && layer.name.indexOf("湿") != -1) {
                var title = graphic.attributes[layer.displayField] + "第" + graphic.attributes["WETLAND_NO"] + "号湿地斑块";
            } else {
                var title = graphic.attributes[layer.displayField];
            }
            if (!title) {
                title = layer.name;
            }
            return title;
        },
        _getTextContent: function (graphic) {
            MapBrowseObj.content = '';
            var id = graphic.attributes.OBJECTID;
            MapBrowseObj.content += "<div class='con'>";
            var layer = graphic.getLayer();
            var layerName = layer.name;
            if (layerName.indexOf("省重要") != -1) {
                panoUrl = graphic.attributes.URL;
            } else {
                panoUrl = '';
            }
            for (var a = 0; a < layer.fields.length; a++) {
                var ming = layer.fields[a].name;
                var ali = layer.fields[a].alias;
                if (ali != "OBJECTID" && graphic.attributes[ming]) {
                    var regs = new RegExp("[\\u4E00-\\u9FFF]+", "g");
                    if (regs.test(ali) && ali.toLowerCase().indexOf("object") == -1 && ali.toLowerCase().indexOf("shape") == -1 && ali.indexOf("area") == -1 &&
                        ali.indexOf("AREA") == -1 && ali.indexOf("Area") == -1 && ali.indexOf("FID") == -1) {
                        MapBrowseObj.content += "<div>" + layer.fields[a].alias + ":<b>" + graphic.attributes[ming] + "</b></div>";
                    }
                }
            }
            if (layer.hasAttachments) {
                var attach = 0; //附件的个数
                var vedio = 0; //视频个数
                var docu = 0; //文件个数
                //根据返回的数据判断是否添加相应的字段;
                //console.log(layer.name);
                layer.queryAttachmentInfos(id, function (result) {
                    //                    console.log(result);
                    imgDiv = [];
                    vedioDiv = '';
                    docuDiv = '';
                    for (var i = 0; i < result.length; i++) {
                        var type = result[i].contentType;
                        if (type.indexOf('image') != -1) {
                            imgDiv.push("<div class='swiper-slide' num=" + attach + "><img src='" + result[i].url + "'/></div>");
                            attach++;
                        } else if (type.indexOf('video') != -1) {
                            vedio++;
                            vedioDiv = "<video controls><source src='" + result[i].url + "' type='video/mp4'></video>";
                        } else if (type.indexOf('application') != -1) {
                            docu++;
                            docuDiv += "<a href='" + result[i].url + "' style='display:block' download='" + result[i].name + "'>" + result[i].name + "</a>";
                        }
                    }
                    $('.actionList').children('a:first').nextAll().remove(); //清除“缩放至”之后的所有元素
                    //判断相应的文件是否存在来添加相应的按钮
                    if (attach > 0) {
                        if (layerName.indexOf("公园") != -1) {
                            $('.actionList').append("<a title=\"图片\" class=\"action zoomTo img\" href=\"javascript:void(0);\"><span>附件</span></a>");
                        } else {
                            $('.actionList').append("<a title=\"图片\" class=\"action zoomTo img\" href=\"javascript:void(0);\"><span>图片</span></a>");
                        }
                    }
                    if (panoUrl.length > 0) {
                        $('.actionList').append("<a title=\"全景\" class=\"action zoomTo qj\" href=\"javascript:void(0);\"><span>全景</span></a>");
                    }
                    if (vedio > 0) {
                        $('.actionList').append("<a title=\"视频\" class=\"action zoomTo vedio\" href=\"javascript:void(0);\"><span>视频</span></a>");
                    }
                    if (docu > 0) {
                        $('.actionList').append("<a title=\"文件\" class=\"action zoomTo docu\" href=\"javascript:void(0);\"><span>文件</span></a>");
                    }
                    if (result.length > 0 || panoUrl.length > 0) {
                        $('.actionList').append("<a title=\"详细信息\" class=\"action zoomTo msg\" href=\"javascript:void(0);\"><span>详细信息</span></a>");
                    }
                    MapBrowseObj.content += "</div>";
                    //相应按钮的点击事件
                    MapBrowseObj._infowindowClick();
                    //                  return MapBrowseObj.content;
                }, function (result) {
                    console.log(result);
                });
            } else {
                $('.actionList').children('a:first').nextAll().remove(); //清除“缩放至”之后的所有元素
                if (layer.name.indexOf("省重要") != -1 && panoUrl.length > 0) {
                    $('.actionList').append("<a title=\"全景\" class=\"action zoomTo qj\" href=\"javascript:void(0);\"><span>全景</span></a>");
                    $('.actionList').append("<a title=\"详细信息\" class=\"action zoomTo msg\" href=\"javascript:void(0);\"><span>详细信息</span></a>");
                }
                MapBrowseObj._infowindowClick();
            }
            return MapBrowseObj.content;
        },
        _infowindowClick: function () {
            //先清除上次弹窗所绑定的事件,防止重复执行
            $('.actionList .img').unbind();
            $('.actionList .qj').unbind();
            $('.actionList .vedio').unbind();
            var html;
            var timer = setTimeout(function () {
                html = $('.contentPane .con').html();
            }, 500); //将记录界面重新写入;
            //“图片”点击事件
            $('.actionList .img').click(function () {
                var inner = "<div class = 'swiper-wrapper'>" + imgDiv[0] + "</div>";
                $('.contentPane .con').html(inner);
                if ($(".titlePane [title = '恢复']").attr("title") == "恢复") {
                    $('.swiper-wrapper , .swiper-slide').css({
                        "width": $('.contentPane').css("width"),
                        "height": $('.contentPane').css("height")
                    });
                    $('.swiper-wrapper .swiper-slide div').css({
                        "width": $('.contentPane').css("width"),
                        "height": $('.contentPane').css("height")
                    });
                    $('.swiper-wrapper .swiper-slide img').css("width", "auto"); //用于控制图片的宽度
                    $('.swiper-wrapper .swiper-slide img').smartZoom({
                        "containerClass": "zoomContainer"
                    });
                } else {
                    $('.swiper-wrapper .swiper-slide img').css("width", $('.contentPane').css("width")); //用于控制图片的宽度
                    $('.swiper-wrapper , .swiper-slide').css({
                        "width": $('.contentPane').css("width"),
                        "height": "auto"
                    });
                    $('.swiper-wrapper .swiper-slide div').css({
                        "width": $('.contentPane').css("width"),
                        "height": "auto"
                    });
                }
                //图片的切换功能,
                var nums = imgDiv.length;
                if (nums > 1) {
                    Btns = "<img src='images/nextBtn.jpg' class='nextBtn'><img src='images/prevBtn.jpg' class='prevBtn'>";
                    $('.contentPane .con').append(Btns);
                    $('.nextBtn').click(function () {
                        var num;
                        num = parseInt($('.swiper-wrapper .swiper-slide').attr('num'));
                        if (num == nums - 1) {
                            num = 0;
                        } else {
                            num++;
                        }
                        ;
                        if ($(".titlePane [title = '恢复']").attr("title") == "恢复") {
                            $('.contentPane .con .swiper-slide').remove();
                            $('.contentPane .con .swiper-wrapper').append(imgDiv[num]);
                            $('.swiper-wrapper , .swiper-slide').css({
                                "width": $('.contentPane').css("width"),
                                "height": $('.contentPane').css("height")
                            });
                            $('.swiper-wrapper .swiper-slide div').css({
                                "width": $('.contentPane').css("width"),
                                "height": $('.contentPane').css("height")
                            });
                            $('.swiper-wrapper .swiper-slide img').css("width", "auto"); //用于控制图片的宽度
                            $('.swiper-wrapper .swiper-slide img').smartZoom({
                                "containerClass": "zoomContainer"
                            });
                        } else {
                            $('.contentPane .con .swiper-slide').remove();
                            $('.contentPane .con .swiper-wrapper').append(imgDiv[num]);
                            $('.swiper-wrapper .swiper-slide img').css("width", $('.contentPane').css("width")); //用于控制图片的宽度
                            $('.swiper-wrapper , .swiper-slide').css({
                                "width": $('.contentPane').css("width"),
                                "height": "auto"
                            });
                            $('.swiper-wrapper .swiper-slide div').css({
                                "width": $('.contentPane').css("width"),
                                "height": "auto"
                            });
                        }
                    });
                    $('.prevBtn').click(function () {
                        var num;
                        num = parseInt($('.swiper-wrapper .swiper-slide').attr('num'));
                        if (num == 0) {
                            num = nums - 1;
                        } else {
                            num--;
                        }
                        ;
                        if ($(".titlePane [title = '恢复']").attr("title") == "恢复") {
                            $('.contentPane .con .swiper-slide').remove();
                            $('.contentPane .con .swiper-wrapper').append(imgDiv[num]);
                            $('.swiper-wrapper , .swiper-slide').css({
                                "width": $('.contentPane').css("width"),
                                "height": $('.contentPane').css("height")
                            });
                            $('.swiper-wrapper .swiper-slide div').css({
                                "width": $('.contentPane').css("width"),
                                "height": $('.contentPane').css("height")
                            });
                            $('.swiper-wrapper .swiper-slide img').css("width", "auto"); //用于控制图片的宽度
                            $('.swiper-wrapper .swiper-slide img').smartZoom({
                                "containerClass": "zoomContainer"
                            });
                        } else {
                            $('.contentPane .con .swiper-slide').remove();
                            $('.contentPane .con .swiper-wrapper').append(imgDiv[num]);
                            $('.swiper-wrapper .swiper-slide img').css("width", $('.contentPane').css("width")); //用于控制图片的宽度
                            $('.swiper-wrapper , .swiper-slide').css({
                                "width": $('.contentPane').css("width"),
                                "height": "auto"
                            });
                            $('.swiper-wrapper .swiper-slide div').css({
                                "width": $('.contentPane').css("width"),
                                "height": "auto"
                            });
                        }
                    });
                }
            });
            //文档点击事件
            $('.actionList .docu').click(function () {
                $('.contentPane .con').html('');
                $('.contentPane .con').html(docuDiv);
            });
            //“全景”点击事件
            $('.actionList .qj').click(function () {
                if ($('.contentPane iframe').css('display') != "block" && $('.contentPane img').length == 0 && $('.contentPane video').length == 0) {
                    html = $('.contentPane .con').html(); //记录现有界面
                }
                $('.contentPane .con').empty();
                $('.contentPane .con').append("<iframe name=\"i\" src=" + panoUrl + "></iframe>");
                $('.contentPane .con iframe').css({
                    "width": $('.contentPane').css("width"),
                    "height": $('.contentPane').css("height")
                });
            });
            //“视频”点击事件
            $('.actionList .vedio').click(function () {
                $('.contentPane .con').html(vedioDiv);
                $('.contentPane .con video').css({
                    "width": $('.contentPane').css("width"),
                    "height": $('.contentPane').css("height")
                });
            });
            //“详细信息”点击事件,点击返回属性页
            $('.actionList .msg').click(function () { //返回按钮点击事件
                $('.contentPane .con').html(html); //将记录界面重新写入
            });
            //关闭按钮点击事件
            $(".close").click(function () {
                if ($(".con").children("iframe").length > 0) {
                    $(".con").text('');
                }
            });
            //“最大化按钮”点击事件,点击改变信息框样式
            $('.titlePane .maximize').unbind().click(function () {
                setTimeout(function () {
                    if ($(".titlePane [title = '恢复']").attr("title") == "恢复" && $('.swiper-wrapper .swiper-slide').length > 0) {
                        var num = parseInt($('.swiper-wrapper .swiper-slide').attr('num'));
                        $('.contentPane .con .swiper-slide').remove();
                        $('.contentPane .con .swiper-wrapper').append(imgDiv[num]);
                        $('.swiper-wrapper , .swiper-slide').css({
                            "width": $('.contentPane').css("width"),
                            "height": $('.contentPane').css("height")
                        });
                        $('.swiper-wrapper .swiper-slide div').css({
                            "width": $('.contentPane').css("width"),
                            "height": $('.contentPane').css("height")
                        });
                        $('.swiper-wrapper .swiper-slide img').css("width", "auto"); //用于控制图片的宽度
                        $('.swiper-wrapper .swiper-slide img').smartZoom({
                            "containerClass": "zoomContainer"
                        });
                    } else {
                        var num = parseInt($('.swiper-wrapper .swiper-slide').attr('num'));
                        $('.contentPane .con .swiper-slide').remove();
                        $('.contentPane .con .swiper-wrapper').append(imgDiv[num]);
                        $('.swiper-wrapper .swiper-slide img').css("width", $('.contentPane').css("width")); //用于控制图片的宽度
                        $('.swiper-wrapper , .swiper-slide').css({
                            "width": $('.contentPane').css("width"),
                            "height": "auto"
                        });
                        $('.swiper-wrapper .swiper-slide div').css({
                            "width": $('.contentPane').css("width"),
                            "height": "auto"
                        });
                        $('.contentPane .con iframe').css({
                            "width": $('.contentPane').css("width"),
                            "height": "auto"
                        });
                    }
                    if ($(".titlePane [title = '恢复']").attr("title") == "恢复") {
                        $('.contentPane .con iframe').css({
                            "width": $('.contentPane').css("width"),
                            "height": $('.contentPane').css("height")
                        });
                    } else {
                        $('.contentPane .con iframe').css({
                            "width": $('.contentPane').css("width"),
                            "height": "auto"
                        });
                    }
                    $('.contentPane .con video').css({
                        "width": $('.contentPane').css("width"),
                        "height": "auto"
                    });
                }, 100);
            });
        },
        //ztree添加自定义图标
        addHoverDom: function (treeId, treeNode) {
            // debugger
            if ($("#diyBtn_" + treeNode.id).length > 0 || treeNode.isParent) {
                return;
            }
 
            var aObj = $("#" + treeNode.tId + "_a");
            var editStr = "<span id='diyBtn_space_" + treeNode.id + "' > </span>"
                + "<button type='button' class='diyBtn1' id='diyBtn_" + treeNode.id
                + "' title='打开编辑' onfocus='this.blur();'></button>";
            aObj.append(editStr);
            var btn = $("#diyBtn_" + treeNode.id);
            if (btn) {
                btn.on("click", function () {
                    //根据节点生成featrueLayer替换原来的dynamicLayer
                    var layerobj = treeNode.Url;
                    var template = new InfoTemplate();
                    template.setTitle(MapBrowseObj._getGraphicTitle);
                    template.setContent(MapBrowseObj._getTextContent);
                    var selectLayer = new FeatureLayer(layerobj, {
                        id: treeNode.tId,
                        infoTemplate: template,
                        outFields: ['*'],
                        mode: FeatureLayer.MODE_ONDEMAND,
                        displayOnPan: false
                    });
                    selectLayer.on("error", function (evt) {
                        var msg = evt.error.message;
                        alert(msg);
                    });
                    //先移除地图上原有的动态图层,在将新图层添加上去,并替换configData里的图层
                    MapBrowseObj._map.removeLayer(ConfigData.layers[treeNode.tId]);
                    MapBrowseObj._map.addLayer(selectLayer);
                    ConfigData.layers[treeNode.tId] = selectLayer;
                    selectLayer.on('load', function (e) {
                        var selectedLayer = e.layer;
                        //点击设置,需要再次获取图层所有符号,因为可能更换过,而不是用初始符号
                        var symbols1 = [];
                        var renderer = selectedLayer.renderer;
                        if (renderer instanceof SimpleRenderer) {
                            symbols1[0] = {
                                label: selectedLayer.name,
                                symbol: renderer.symbol
                            };
                        } else if (renderer instanceof ClassBreaksRenderer) {
                            symbols1 = arrayUtils.map(renderer.infos, function (info) {
                                return {
                                    label: info.value,
                                    symbol: info.symbol
                                };
                            });
                        } else if (renderer instanceof UniqueValueRenderer) {
                            symbols1 = arrayUtils.map(renderer.infos, function (info) {
                                return {
                                    label: info.value,
                                    symbol: info.symbol
                                };
                            });
                        }
                        //调用自定义图层样式函数
                        MapBrowseObj._openSymbolStyler(selectedLayer, symbols1, 0, treeNode);
                    })
                });
            }
        },
        removeHoverDom: function (treeId, treeNode) {
            $("#diyBtn_" + treeNode.id).unbind().remove();
            $("#diyBtn_space_" + treeNode.id).unbind().remove();
        },
        //打开符号设置部件,参数说明,checkedLayer选中的图层,symbols图层符号数组,index符号索引。注意不能一次只能针对一个符号修改
        _openSymbolStyler: function (checkedLayer, symbols, index, treeNode) {
            MapBrowseObj._selectLayer = checkedLayer;
            var defaultSymbol = symbols[index].symbol;
            //判断是否为点图层
            if (MapBrowseObj._selectLayer.geometryType != "esriGeometryPoint") {
                if (MapBrowseObj._styler) {
 
                } else {
                    // if(MapBrowseObj._selectLayer.geometryType != "esriGeometryPoint"){
 
                    // 销毁上次生成的节点,防止重复注册
                    // MapBrowseObj._styler.destroy();
                    // domConstruct.destroy("applySymboldiv");
                    // domConstruct.destroy("styler");
                    domConstruct.create('div', {
                        id: 'styler',
                        style: 'display:none'
                    }, 'editor');
                    var applySymboldiv = domConstruct.create("div", {
                        id: "applySymboldiv",
                        class: "options-panel"
                    });
 
                    domConstruct.place(applySymboldiv, "styler");
 
                    var applySymbolButton = domConstruct.create("input", {
                        type: "button",
                        value: "使用符号"
                    }, applySymboldiv);
                    var canelSymbolButton = domConstruct.create("input", {
                        type: "button",
                        value: "取消使用"
                    }, applySymboldiv);
 
                    on(applySymbolButton, "click", lang.hitch(applySymbolButton, function (a, evt) {
                        var style = MapBrowseObj._styler.getStyle();
 
                        if (MapBrowseObj._selectLayer.renderer instanceof SimpleRenderer) {
                            MapBrowseObj._selectLayer.renderer.symbol = style.symbol;
                        } else if (MapBrowseObj._selectLayer.renderer instanceof ClassBreaksRenderer) {
                            MapBrowseObj._selectLayer.renderer.infos[a].symbol = style.symbol;
                        } else if (MapBrowseObj._selectLayer.renderer instanceof UniqueValueRenderer) {
                            MapBrowseObj._selectLayer.renderer.infos[a].symbol = style.symbol;
                        } else {
 
                        }
                        //刷新图层,并隐藏窗口
                        MapBrowseObj._selectLayer.refresh();
                        domStyle.set("styler", "display", "none");
                    }, index));
 
                    on(canelSymbolButton, "click", lang.hitch(MapBrowseObj, function (evt) {
                        domStyle.set("styler", "display", "none");
                    }));
 
                    //Create instance of SymbolStyler and pass in the domNode,注意跨域会读取不到符号数据,需同源
                    MapBrowseObj._styler = new SymbolStyler({
                        portalUrl: ''
                    }, "styler");
                    //Must call startup
                    MapBrowseObj._styler.startup();
                }
                MapBrowseObj._styler.edit(defaultSymbol, MapBrowseObj._getStylerOptions(defaultSymbol));
                $("#styler").show();
                $("#point_styler").hide();
            } else {
                //自定义点图层样式修改窗体--目前只针对于SimpleRenderer
                // console.log(MapBrowseObj._selectLayer.renderer.symbol);
                $("#styler").hide();
                //为table标签中添加子候选项---即icon列表,并添加点击事件
                $("#icon_table").empty();
                var table_row = ["black", "blue", "green", "red", "yellow"];
                var arr_td = [];
                //获取项目根目录当前所在地址
                var baseUrl = getIndexUrl("/wetlandmap");
                for (var x in table_row) {
                    for (var y = 1; y < 32; y++) {
                        arr_td.push("" + baseUrl + "<td><img src='/widgets/index/images/icon/" + table_row[x] + "/" + table_row[x] + y + ".png' /></td>" + "");
                    }
                }
                $("#icon_table").append("<tr ></tr>");
                var td_num = 0;
                for (var z in arr_td) {
                    if (td_num > 5) {
                        $("#icon_table").append("<tr ></tr>");
                        td_num = 0;
                    }
                    $("#icon_table tr:last").append(arr_td[z]);
                    td_num++;
                }
                $("#icon_table").unbind("click").click(function (evt) {
                    $("#icon_table img").removeClass("on_selected_td");
                    if (evt.target.localName == "img") {
                        $(evt.target).addClass("on_selected_td");
                        $("#original_img").attr("src", $("#icon_table .on_selected_td").attr("src"));
                    }
                });
                //为使用图像按钮添加点击事件,并为图像输入框添加change事件
                $("#custom_img a").unbind("click").click(function () {
                    $("#custom_img input").toggle();
                });
                $("#custom_img input").change(function () {
                    $("#original_img").attr("src", $("#custom_img input").val());
                    var val = parseFloat($("#px_value").val());
                    $("#original_img").css("height", val + "px");
                });
                //像素值输入栏加减按钮添加点击事件,及输入框输入事件
                $("#value_add").unbind("click").click(function () {
                    var val = parseFloat($("#px_value").val()) + 1;
                    $("#px_value").val(val);
                    $("#original_img").css("height", val + "px");
                });
                $("#value_dec").unbind("click").click(function () {
                    var val = parseFloat($("#px_value").val()) - 1;
                    $("#px_value").val(val);
                    $("#original_img").css("height", val + "px");
                });
                $("#px_value").unbind("change").change(function () {
                    var val = parseFloat($("#px_value").val());
                    $("#original_img").css("height", val + "px");
                });
 
                //添加确定和取消按钮并为其添加点击事件
                domConstruct.destroy("applySymboldiv1");
 
                var applySymboldiv1 = domConstruct.create("div", {
                    id: "applySymboldiv1",
                    class: "options-panel"
                });
 
                domConstruct.place(applySymboldiv1, "point_styler");
 
                var applySymbolButton1 = domConstruct.create("input", {
                    type: "button",
                    value: "使用符号"
                }, applySymboldiv1);
                var canelSymbolButton1 = domConstruct.create("input", {
                    type: "button",
                    value: "取消使用"
                }, applySymboldiv1);
 
                on(applySymbolButton1, "click", lang.hitch(applySymbolButton1, function (a, evt) {
                    var imgsrc = null;
                    if ($("#custom_img input").is(":hidden") == false && $.trim($("#custom_img input").val())) {
                        imgsrc = $("#custom_img input").val();
                    } else if ($.trim($("#icon_table .on_selected_td").attr("src"))) {
                        imgsrc = $("#icon_table .on_selected_td").attr("src");
                    } else {
                        var persent = parseFloat(MapBrowseObj._selectLayer.renderer.symbol.width) / parseFloat(MapBrowseObj._selectLayer.renderer.symbol.height);
                        MapBrowseObj._selectLayer.renderer.symbol.height = $("#px_value").val();
                        MapBrowseObj._selectLayer.renderer.symbol.width = parseFloat($("#px_value").val()) * persent;
                    }
                    if (imgsrc) {
                        var icon_size = $("#px_value").val();
                        if (MapBrowseObj._selectLayer.renderer instanceof SimpleRenderer) {
                            var select_symbol = new PictureMarkerSymbol(imgsrc, icon_size, icon_size);
                            MapBrowseObj._selectLayer.renderer.symbol = select_symbol;
                        } else if (MapBrowseObj._selectLayer.renderer instanceof ClassBreaksRenderer) {
                            // MapBrowseObj._selectLayer.renderer.infos[a].symbol = style.symbol;
                        } else if (MapBrowseObj._selectLayer.renderer instanceof UniqueValueRenderer) {
                            // MapBrowseObj._selectLayer.renderer.infos[a].symbol = style.symbol;
                        } else {
 
                        }
                    }
                    //刷新图层,并隐藏窗口
                    MapBrowseObj._selectLayer.refresh();
                    domStyle.set("point_styler", "display", "none");
                    $("#original_img").css("height", "24px");
                }, index));
 
                on(canelSymbolButton1, "click", lang.hitch(this, function (evt) {
                    domStyle.set("point_styler", "display", "none");
                    $("#original_img").css("height", "24px");
                }));
                $("#point_styler").addClass("esriSymbolStyler");
                $("#point_styler #original_img").attr("src", MapBrowseObj._selectLayer.renderer.symbol.url);
                $("#point_styler #original_img").css("height", MapBrowseObj._selectLayer.renderer.symbol.height + "px");
                $("#px_value").val(MapBrowseObj._selectLayer.renderer.symbol.height);
                $("#point_styler").show();
            }
        },
        _getStylerOptions: function (symbol) {
            var styleModule = basic;
            return {
                schemes: styleModule.getSchemes({
                    theme: "default",
                    basemap: "topo",
                    geometryType: MapBrowseObj._getGeometryType(symbol)
                })
            }
 
        },
        _getGeometryType: function (symbol) {
            var type = symbol.type;
            return type === "picturefillsymbol" || type === "simplefillsymbol" ? "polygon" :
                type === "cartographiclinesymbol" || type === "simplelinesymbol" ? "line" :
                    "point";
        },
    });
    return Widget;
});