define([ 'dojo/_base/declare', 'dojo/_base/lang', 'dojo/_base/array', 'dojo/_base/html', "dojo/topic", 'jimu/BaseWidget', 'dojo/on', 'jimu/dijit/Popup', './GeologicalDisasterPanel' ], function (declare, lang, array, html, topic, BaseWidget, on, Popup, GeologicalDisasterPanel ) { return declare([BaseWidget], { baseClass: 'jimu-widget-PathShow', name: 'PathShow', shidiLayer: null, datas: null, polyline: null, layer: null, startup: function () { this.inherited(arguments); var self = this; $.ajax({ url: 'widgets/PathShow/jddatas.json', type: "POST", dataType: "json", success: function success(data) { self.datas = data.data; self.createList(data.data); } }); //添加地图点击事件 this.addHandler(); }, onMinimize: function () { // this.resize(); }, onMaximize: function () { // this.resize(); }, onOpen: function () { //面板打开的时候触发,添加标签到地图上 var self = this; window.openAudioName = this.name; self.map.camera.flyTo({ destination: Cesium.Cartesian3.fromDegrees(115.737419, 28.747867, 32000) }); }, onClose: function () { //面板打开的时候触发,删除地图上标签 var self = this; self.map.entities.removeAll(); self._controlSendAll(false); $('#chosePage').attr('style', 'display:block;'); $('#intro').attr('style', 'display:none'); $('#PathShow_qj').attr('src', ''); $("#PathShow_bgMusic").attr('src', ''); for (var i = 0; i < this.datas.length; i++) { clearTimeout(this.datas[i].settimeoutId); } }, // resize: function() { // }, destroy: function () { this.inherited(arguments); }, //关键字过滤 query: function () { var text = this.keyNode.value; if (text != "" && text.length > 0) { var list = array.filter(this.datas, function (g) { if (g.name.indexOf(text) > -1) { return true; } else { return false; } }, this); $('.jimu-widget-PathShow ul li').remove(); this.createList(list); } else { $('.jimu-widget-PathShow ul li').remove(); this.createList(this.datas); } }, createList: function (dataList) { var self = this; dataList.forEach(function (element, index) { $(".jimu-widget-PathShow .PathShow-listul").append("
  • " + (index + 1) + "、" + element.name + "

  • "); }, this); //添加li点击事件,地图定位 $('.jimu-widget-PathShow .PathShow-listul li span').click(function () { $(".jimu-widget-PathShow .PathShow-listul li span").removeClass("bck_color"); $(this).addClass("bck_color"); }); //添加li点击事件,地图定位 $('.jimu-widget-PathShow .PathShow-listul li').click(function () { let selectItem = this.innerText.trim(); selectItem = selectItem.split("、")[1]; var ids = $(this).attr("id"); var ar = dataList.find(function (elem) { return elem.name == selectItem && elem.id == ids; }); //清除地图点 self.map.entities.removeAll(); self.addPoint(ar); $.ajax({ url: 'widgets/PathShow/datas.json', type: "POST", dataType: "json", success: function success(res) { for (var i = 0; i < res.features.length; i++) { if (res.features[i].attributes.Name == selectItem) { self.addLines(res.features[i]); self.map.camera.flyTo({ destination: Cesium.Cartesian3.fromDegrees(res.features[i].attributes.x, res.features[i].attributes.y, res.features[i].attributes.height) }); } } } }); }); }, loadChirden: function (item) { //切换显示 $('#chosePage').attr('style', 'display:none'); $('#intro').attr('style', 'display:block'); $(".hudong-head").stop().hide(); //添加图片 $('.jimu-widget-PathShow .PathShow-enlarge-img .PathShow-enlarge-main .PathShow-enlarge-content ul').empty(); $('.jimu-widget-PathShow .PathShow-child-text div .PathShow-child-img-main .PathShow-child-img-content ul').empty(); // 单张图片的处理方式 $(".jimu-widget-PathShow .PathShow-enlarge-img .PathShow-enlarge-main .PathShow-enlarge-left").stop().hide(); $(".jimu-widget-PathShow .PathShow-enlarge-img .PathShow-enlarge-main .PathShow-enlarge-right").stop().hide(); $(".jimu-widget-PathShow .PathShow-child-text div .PathShow-child-img-main .PathShow-child-img-left").stop().hide(); $(".jimu-widget-PathShow .PathShow-child-text div .PathShow-child-img-main .PathShow-child-img-right").stop().hide(); $('.jimu-widget-PathShow .PathShow-enlarge-img .PathShow-enlarge-main .PathShow-enlarge-content ul').append("
  • "); $('.jimu-widget-PathShow .PathShow-child-text div .PathShow-child-img-main .PathShow-child-img-content ul').append("
  • "); }, addHandler: function () { var handler = new Cesium.ScreenSpaceEventHandler(this.map.scene.canvas); handler.setInputAction(lang.hitch(this, this.clickHandler), Cesium.ScreenSpaceEventType.LEFT_CLICK); }, clickHandler: function (movement) { var self = this; var pickedObjects = self.map.scene.drillPick(movement.position); if (Cesium.defined(pickedObjects)) { for (var i = 0; i < pickedObjects.length; ++i) { var obj = pickedObjects[i].id; for (var j = 0; j < self.datas.length; j++) { if (obj.id.split("path")[1] == self.datas[j].id) { self.openWindow(obj.id.split("path")[0], self.datas[j]); return; } } } } }, addLines: function (result) { var res = result.geometry.paths[0]; var id = result.OBJECTID; var self = this; if (self.polyline != null) { self.layer.remove(self.polyline); } var positions = ''; for (var i = 0; i < res.length; i++) { if (i != res.length - 1) { positions += res[i][0] + ',' + res[i][1] + ';'; } else { positions += res[i][0] + ',' + res[i][1]; } } self.layer = new DC.VectorLayer('layer') window.dcViewer.addLayer(self.layer) self.polyline = new DC.Polyline(positions); //let polyline = new DC.Polyline("115.70683949300007,28.80868520100006;115.70593267000004,28.80891538000003;115.70573287000002,28.809185460000037;115.7057028700001,28.809355380000056;115.70575282000004,28.809495260000062;115.70592263000003,28.809634940000024;115.70629213000007,28.80977433000004;115.70646180000006,28.809953920000055;115.70678137000004,28.810113400000034;115.70741052000005,28.810772090000057;115.70783996000011,28.81156093000004;115.70788980000009,28.811910580000074;115.70778984000003,28.81311990000006;115.7079396800001,28.81314966000008;115.70895838000001,28.813328150000075;115.70968745000005,28.813437160000035;115.71056640000006,28.813515900000027;115.71211457000004,28.81349400000005;115.71248412000011,28.813423560000047;115.71356299000001,28.813042490000043;115.71410242000002,28.812881970000035;115.71435212000006,28.812811690000046;115.71552091000001,28.812470510000026;115.71587055000009,28.812370180000073;115.71622027000001,28.81221990000006;115.71666985000002,28.811819650000075;115.71668980000004,28.811809640000035;115.71701948000009,28.811619350000058;115.71729922000009,28.81149915000003;115.71731926000007,28.811489150000057;115.71758895000005,28.811418890000027;115.71838819000004,28.81134804000004;115.71859801000005,28.811267860000044;115.7187678900001,28.811157740000056;115.71946731000003,28.81055734000006;115.71984702000009,28.81017722000007;115.72001692000003,28.809747300000026;115.72008691000008,28.809467510000047;115.72006693000003,28.809317560000068;115.72000694000008,28.80918777000005;115.7198670900001,28.809038000000044;115.71907790000012,28.808179460000076;115.71879820000004,28.80783009000004;115.71871824000004,28.807660240000075;115.71860836000008,28.80728062000003;115.71859843000004,28.807120740000073;115.71869836000008,28.806770940000035;115.71881536700005,28.806550792000053;115.71894816000008,28.80630094000003;115.71915807000005,28.80567121000007;115.71925796000005,28.80553117000005;115.71940780000011,28.805451090000076;115.72030710000001,28.805300190000025;115.72103645000004,28.805229420000046;115.72123626000007,28.80516932000006;115.72134625000001,28.805079200000023;115.72156602000007,28.804779190000033;115.7217059300001,28.804679170000043;115.72225551000008,28.80450865000006;115.72320486000001,28.80404806000007;115.72342470000001,28.804017860000044;115.72391438000011,28.80403733000003;115.72426408000001,28.803947030000074;115.72452390000001,28.803766950000067;115.72493368000005,28.803176980000046;115.72513363000007,28.80298688000005;115.72583321000002,28.80253657000003;115.72608304000005,28.802416410000035;115.72626292000007,28.802356260000067;115.72643281,28.802356090000046;115.72693254,28.80244558000004;115.72741227000006,28.802365250000037;115.72759209000003,28.80233510000005;115.72870154000009,28.802134210000077;115.72962110000003,28.801933620000057;115.73037078000004,28.80144333000004;115.73158032000003,28.80097268000003;115.73205015000008,28.800882390000027;115.7322700200001,28.80087227000007;115.7324500100001,28.800912100000062;115.73267991000012,28.801021840000033;115.73337961000004,28.80142107000006;115.73388942000008,28.801770480000073;115.7344391900001,28.80217981000004;115.7349390600001,28.802559170000052;115.7359787900001,28.803327960000047;115.73613875000001,28.80344776000004;115.7366385900001,28.80381717000006;115.73701844000004,28.803946910000036;115.73723843000005,28.803946790000055;115.73845828000003,28.80362634000005;115.73986818000003,28.803235920000077;115.74010815000008,28.803205810000065;115.74106817000006,28.803275350000035;115.74139818000003,28.803255240000055;115.74156817000005,28.803215150000028;115.74191813000004,28.80301516000003;115.74209823000001,28.80280528000003;115.74323836000008,28.800946260000046;115.74335838000002,28.800756360000037;115.74387855000009,28.799886810000032;115.7447387200001,28.798647450000033;115.74487875000011,28.79846757000007;115.74506881000002,28.798157710000055;115.74521883000011,28.79782797000007;115.74530890000005,28.79763808000007;115.74549890000003,28.79731828000007;115.74578899000005,28.79697839000005;115.74626911000007,28.796598610000046;115.74686931000008,28.796188820000054;115.74706933000004,28.795998890000078;115.74827974000004,28.794559780000043;115.74838983000006,28.794419880000078;115.74890002000006,28.793790280000053;115.74915008000005,28.793570420000037;115.74967030000005,28.793280620000075;115.75012047000007,28.79313078000007;115.75207125000009,28.792571260000045;115.75314176000006,28.792241560000036;115.75325184000008,28.792211630000054;115.75341192000008,28.79216167000004;115.75361198000007,28.792101770000045;115.75579329000004,28.791432710000038;115.7555131900001,28.790403320000053;115.75551322000001,28.790063580000037;115.75561325000001,28.789374140000064;115.75563340000008,28.788694640000074;115.75501319000011,28.78659594000004;115.75482304000002,28.78599638000003;115.75476308000009,28.785806500000035;115.7546430000001,28.78552663000005;115.75440289000005,28.785016970000072;115.75422287000004,28.784637160000045;115.7538727000001,28.783957600000065;115.75386271000002,28.78376774000003;115.75393281000004,28.78362782000005;115.75398282000003,28.783567920000053;115.75413292000007,28.78332811000007;115.75420295000004,28.78313821000006;115.7541829700001,28.782898440000054;115.7540829400001,28.782688500000063;115.75389286000006,28.782498660000044;115.75361270000008,28.782398640000054;115.75332257000002,28.78240864000003;115.75297239000008,28.782558420000043;115.7527922700001,28.782538430000045;115.75268227000004,28.782458490000067;115.75257223000006,28.78228856000004;115.75252218000003,28.782108750000077;115.75240221000001,28.781239330000062;115.75237225000001,28.780899560000023;115.75237219000007,28.78062974000005;115.75241223000012,28.780459850000057;115.75258239000004,28.77994022000007;115.7526224400001,28.77971038000004;115.75261238000007,28.77961049000004;115.75256236000007,28.779510540000047;115.7524023200001,28.779370640000025;115.75232229000005,28.77920073000007;115.75234228000011,28.779070820000072;115.75251243000002,28.77870112000005;115.75251247000006,28.77861112000005;115.7524424400001,28.77846123000006;115.7523323900001,28.77822144000004;115.75233234000007,28.77811151000003;115.75258249000001,28.777721830000075;115.7528726600001,28.777451980000023;115.75308279000001,28.777312160000065;115.75326289000009,28.777142250000054;115.75332293000008,28.776982390000057;115.7533329800001,28.776832530000036;115.75320290000002,28.776472700000056;115.75304285000004,28.775793220000025;115.75294287000008,28.775513360000048;115.75257270000009,28.77492372000006;115.75239261000002,28.774723830000028;115.75211250000007,28.774503990000028;115.75100210000005,28.773794390000035;115.7506920400001,28.77345457000007;115.75025181000001,28.773034860000053;115.74997181000003,28.772695140000053;115.74944168000002,28.77184567000006;115.7489215700001,28.771056230000056;115.74857146000011,28.77035679000005;115.74819142000001,28.769447370000023;115.74808136000001,28.769227560000047;115.74800141000003,28.76908769000005;115.74774131000004,28.76885788000004;115.7470811500001,28.768448240000055;115.74674110000001,28.768158450000044;115.74665116000006,28.768008550000047;115.74654109000005,28.767638800000043;115.74612108000008,28.76665956000005;115.74578113000007,28.765670270000044;115.74542108000003,28.765190700000062;115.7452910400001,28.76495091000004;115.74501110000006,28.764091490000055;115.74488110000004,28.76371178000005;115.74484109000002,28.76364190000004;115.74467106000009,28.763382080000042;115.74444101000006,28.76316225000005;115.74420107000003,28.762972450000063;115.74376100000006,28.76255289000005;115.74372361400003,28.76250723900006;115.74313097000004,28.761783580000042;115.74296104000007,28.76159376000004;115.7426710200001,28.761184100000037;115.74245099000007,28.760854390000077;115.74241100000006,28.760784510000065;115.74233100000004,28.760634610000068;115.74214104000009,28.760304940000026;115.74200107000001,28.76006509000007;115.7417010800001,28.759595510000054;115.7414710700001,28.759075950000067;115.74134110000011,28.75898612000003;115.74111110000001,28.758906230000036;115.74063113000011,28.75879653000004;115.74046118000001,28.75873658000006;115.74037120000003,28.758666670000025;115.74008120000008,28.758327080000072;115.7394612600001,28.757817660000057;115.73921131000009,28.75756800000005;115.73915134000003,28.757438120000074;115.73915134000003,28.757308200000068;115.7392013000001,28.757128280000074;115.73939136000001,28.756708440000068;115.73946132000003,28.756588470000054;115.7396813900001,28.75624866000004;115.74004134000006,28.75593870000006;115.7400713400001,28.755878720000055;115.74006136000003,28.755768790000047;115.73997142000007,28.755628890000025;115.7396914200001,28.755329250000045;115.73959142000001,28.755079460000047;115.73955150000006,28.754849630000024;115.73955147000004,28.754569840000045;115.73969154000008,28.754070090000027;115.73972150000009,28.753860170000053;115.73969155000009,28.753730310000037;115.73963150000009,28.75365037000006;115.73916163000001,28.753140940000037;115.73915162000003,28.753100950000032;115.73886169000002,28.75281134000005;115.73876168000004,28.75243162000004;115.73877174000006,28.752311690000056;115.73878173000003,28.752111850000063;115.73887171000001,28.751662080000074;115.73913181000012,28.750912430000028;115.73914178000007,28.750792500000045;115.73920183000007,28.750052960000062;115.73917187000006,28.74962325000007;115.7392119000001,28.74934348000005;115.7394419100001,28.748533890000033;115.73943198000006,28.747894280000025;115.73935201000006,28.747564580000073;115.73912209000002,28.746865120000052;115.73893212000007,28.74648546000003;115.7387322300001,28.746155830000077;115.73842227000011,28.745486370000037;115.73787241000002,28.744317430000024;115.73768252000002,28.744057760000032;115.73747260000005,28.743598140000074;115.73737256000004,28.743388320000065;115.73692274000007,28.74265907000006;115.73686272000009,28.742469280000023;115.7368828000001,28.74231934000005;115.73686278000002,28.742149470000") self.polyline.setStyle({ width: 10, material: new DC.PolylineImageTrailMaterialProperty({ speed: 20, image: './images/arrow.png', repeat: {x: 40, y: 1} }), clampToGround: true }); self.layer.addOverlay(self.polyline); let position = new DC.Position(115.70683949300007, 28.80868520100006); let circle = new DC.Circle(position, 2000) circle.setStyle({ material: new DC.ImageMaterialProperty({ image: './images/circle_bg.png' }) }) circle.rotateAmount = 0.01 let model = new DC.Model(position, './images/zhui.glb') model.setStyle({ scale: 100 }) model.rotateAmount = 4 self.layer.addOverlay(model).addOverlay(circle) }, addPoint: function (res) { var result = res.lx; var self = this; for (var i = 0; i < result.length; i++) { var imgs = ""; imgs = "./widgets/PathShow/img/viewpoint.png"; self.map.entities.add({ id: result[i].id + "path" + res.id, position: Cesium.Cartesian3.fromDegrees(Number(result[i].x), Number(result[i].y), 200), label: { text: result[i].title, font: "700 16px '黑体'", fillColor: Cesium.Color.PALETURQUOISE, outlineColor: Cesium.Color.BLACK, outlineWidth: 2, style: Cesium.LabelStyle.FILL_AND_OUTLINE, horizontalOrigin: Cesium.HorizontalOrigin.TOP, verticalOrigin: Cesium.VerticalOrigin.BOTTOM, // heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, pixelOffset: new Cesium.Cartesian2(0, -9), pixelOffsetScaleByDistance: new Cesium.NearFarScalar(1.5e2, 3.0, 1.5e7, 0.5) }, billboard: { image: imgs, scale: 0.8, width: 30, height: 35, pixelOffset: new Cesium.Cartesian2(0, 0), // heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, } }); } }, // 点击弹出面板; openWindow: function (id, item) { for (var i = 0; i < item.lx.length; i++) { if (id == item.lx[i].id) { var xb = i; layer.open({ title: item.lx[xb].title, type: 2, shadeClose: true, shade: false, maxmin: false, //开启最大化最小化按钮 area: ['802px', '526px'], content: "./widgets/Scenic/popup/popup.html", id: "popup", closeBtn: 1, success: function (layero, index) { // 传递index给子页面 //var iframe = window['layui-layer-iframe' + index]; //iframe.child(item.lx[xb]); } }); } } }, }); });