/* 2017-12-5 16:47:31| 修改 木遥(微信: http://marsgis.cn/weixin.html ) */ //模块: var widgetPointQy = mars3d.widget.bindClass(mars3d.widget.BaseWidget.extend({ options: { resources: ['map.css'], }, dataSource: null, //初始化[仅执行1次] create: function () { //图标点 this.billboardCollection = new Cesium.BillboardCollection({ scene: viewer.scene }); //文字 this.labelCollection = new Cesium.LabelCollection({ scene: viewer.scene }); //添加到图层控制 if (window.bindToLayerControl) { this.viewer.scene.primitives.destroyPrimitives = false; var that = this; this.layerWork = bindToLayerControl({ pid: 30, name: '企业', visible: true, onAdd: function () {//显示回调 if (!that.viewer.scene.primitives.contains(that.billboardCollection)) { that.viewer.scene.primitives.add(that.billboardCollection); } if (!that.viewer.scene.primitives.contains(that.labelCollection)) { that.viewer.scene.primitives.add(that.labelCollection); } }, onRemove: function () {//隐藏回调 if (that.viewer.scene.primitives.contains(that.billboardCollection)) { that.viewer.scene.primitives.remove(that.billboardCollection); } if (that.viewer.scene.primitives.contains(that.labelCollection)) { that.viewer.scene.primitives.remove(that.labelCollection); } }, onCenterAt: function (duration) {//定位回调 that.viewer.flyTo(that.billboardCollection, { duration: duration }); }, }); } //从图层控制中 移除 // if(this.layerWork){ // unbindLayerControl(this.layerWork); // } }, arrdata: [], //打开激活 activate: function () { if (!this.viewer.scene.primitives.contains(this.billboardCollection)) { this.viewer.scene.primitives.add(this.billboardCollection); } if (!this.viewer.scene.primitives.contains(this.labelCollection)) { this.viewer.scene.primitives.add(this.labelCollection); } this.arrdata = this.config.dataQy; if (this.arrdata) { this.addFeature(this.arrdata); } else { var that = this; $.getJSON(serverURL_file+ "/apidemo/qiye/point.json", function (result) { that.arrdata = result.Data; for (var j = 0; j < that.arrdata.length; j++) { var item = that.arrdata[j]; //为了详情面板展示,所绑定的示例数据 item.QYZP = 5; item.CPZP = 4; item.QYJJ = "有"; item.JJ = [ { "NF": "2015", "ZCZ": 6000 + haoutil.math.random(10, j * 1000), "LY": 1000 + haoutil.math.random(10, j * 1000), "NSE": 1000 + haoutil.math.random(10, j * 1000) }, { "NF": "2016", "ZCZ": 10000 + haoutil.math.random(10, j * 1000), "LY": 3000 + haoutil.math.random(10, j * 1000), "NSE": 3000 + haoutil.math.random(10, j * 1000) }, { "NF": "2017", "ZCZ": 25000 + haoutil.math.random(10, j * 1000), "LY": 5000 + haoutil.math.random(10, j * 1000), "NSE": 5000 + haoutil.math.random(10, j * 1000) } ]; } that.addFeature(that.arrdata, true); }); } }, //关闭释放 disable: function () { if (this.viewer.scene.primitives.contains(this.billboardCollection)) { this.viewer.scene.primitives.remove(this.billboardCollection); } if (this.viewer.scene.primitives.contains(this.labelCollection)) { this.viewer.scene.primitives.remove(this.labelCollection); } }, clear: function () { this.viewer.mars.tooltip.close(); this.billboardCollection.removeAll() this.labelCollection.removeAll() }, objData: {}, addFeature: function (arr, iscenter) { this.clear(); var that = this; var positions = []; that.objData = {}; $(arr).each(function (i, item) { that.objData[item.ID] = item; var jd = Number(item.JD); var wd = Number(item.WD); //var z = 0; //===========无坐标数据=========== if (isNaN(jd) || jd == 0 || isNaN(wd) || wd == 0) return; item.JD = jd; item.WD = wd; var inthtml = `