2 lines
7.3 KiB
JavaScript
2 lines
7.3 KiB
JavaScript
|
/* 2020-9-24 14:48:23 | 版权所有 军懋国兴 */
|
||
|
mars3d.widget.bindClass(mars3d.widget.BaseWidget.extend({options:{resources:["./lib/dom2img/dom-to-image.js"],view:{type:"window",url:"view.html",windowOptions:{width:250,position:{top:50,right:5,bottom:5}}}},drawControl:null,getServerURL:function(){return this.viewer.mars.config.serverURL},getGltfServerURL:function(){return serverURL_gltf},create:function(){var i=this;this.drawControl=new mars3d.Draw(this.viewer,{hasEdit:!1,nameTooltip:!0}),this.drawControl.on(mars3d.draw.event.DrawCreated,function(t){var e=t.entity;i.startEditing(e)}),this.drawControl.on(mars3d.draw.event.EditStart,function(t){var e=t.entity;i.startEditing(e)}),this.drawControl.on(mars3d.draw.event.EditMovePoint,function(t){var e=t.entity;i.startEditing(e)}),this.drawControl.on(mars3d.draw.event.EditRemovePoint,function(t){var e=t.entity;i.startEditing(e)}),this.drawControl.on(mars3d.draw.event.EditStop,function(t){var e=t.entity;i.stopEditing(e),i.sendSaveEntity(e),i.showTable()}),this.drawControl.on(mars3d.draw.event.Delete,function(t){i.sendDeleteEntity(t.entity),i.showTable()}),window.bindToLayerControl&&(this.layerWork=bindToLayerControl({pid:0,name:"标绘",visible:!0,onAdd:function(){i.drawControl.setVisible(!0)},onRemove:function(){i.drawControl.setVisible(!1)},onCenterAt:function(t){var e=i.drawControl.getEntitys();i.viewer.flyTo(e,{duration:t})},compare:{onCreate:function(t){this.drawControlEx=new mars3d.Draw(t,{hasEdit:!1,nameTooltip:!0})},onAdd:function(){this.drawControlEx.loadJson(i.getGeoJson()),this.drawControlEx.setVisible(!0)},onRemove:function(){this.drawControlEx.setVisible(!1)}}})),this.sendGetList()},viewWindow:null,winCreateOK:function(t,e){this.viewWindow=e},activate:function(){this.drawControl.hasEdit(!0)},disable:function(){this.stopEditing(),this.viewWindow=null,this.drawControl.stopDraw(),this.drawControl.hasEdit(!1)},getDefStyle:function(t){return mars3d.draw.util.getDefStyle(t)},startDraw:function(t){t&&"model"===t.type&&haoutil.msg("模型根据其大小需要一点加载时间,请稍等片刻。"),this.drawControl.startDraw(t)},endDraw:function(){this.drawControl.endDraw()},startEditingById:function(t){var e=this.drawControl.getEntityById(t);null!=e&&(this.viewer.mars.flyTo(e),this.drawControl.startEditing(e))},startEditing:function(t){var e,i,n=this;null!=this.viewWindow&&(e=this.drawControl.getCoordinates(t),clearTimeout(this.timeTik),(i=mars3d.widget.getClass("widgets/plotAttr/widget.js"))&&i.isActivate?i.startEditing(t,e):mars3d.widget.activate({uri:"widgets/plotAttr/widget.js",entity:t,lonlats:e,deleteEntity:function(t){n.deleteCurrentEntity(t)},updateAttr:function(t){n.updateAttr2map(t)},updateGeo:function(t){n.updateGeo2map(t)},centerAt:function(t){n.centerCurrentEntity(t)}}))},stopEditing:function(){this.timeTik=setTimeout(function(){mars3d.widget.disable("widgets/plotAttr/widget.js")},200)},updateAttr2map:function(t){this.drawControl.updateAttribute(t)},updateGeo2map:function(t){return this.drawControl.setPositions(t),t},centerCurrentEntity:function(t){this.viewer.mars.flyTo(t,{scale:.5,radius:1e3})},getGeoJson:function(){return this.drawControl.toGeoJSON()},getCurrentEntityGeoJson:function(){var t=this.drawControl.getCurrentEntity();if(null!=t)return this.drawControl.toGeoJSON(t)},jsonToLayer:function(t,e,i){if(null!=t)return this.showTable(t),this.drawControl.loadJson(t,{clear:e,flyTo:i})},deleteAll:function(){this.drawControl.deleteAll(),this.sendDeleteAll(),this.showTable()},deleteEntity:function(t){var e=this.drawControl.getEntityById(t);null!=e&&this.drawControl.deleteEntity(e)},isOnDraw:!1,deleteCurrentEntity:function(t){null!=(t=t||this.drawControl.getCurrentEntity())&&this.drawControl.deleteEntity(t)},hasEdit:function(t){this.drawControl.hasEdit(t)},query:function(t,e){for(var i=this.drawControl.getEntitys(),n=[],o=0,r=0;r<i.length;r++){var a,s=i[r];if("label"===s.attribute.type?a=s.attribute.style.text:s.attribute.attr&&(a=s.attribute.attr.name),null!=a&&-1!=a.indexOf(t)&&(n.push({name:a,type:"标绘 - "+s.attribute.name,_datatype:"plot",_entity:s}),e&&e<++o))break}return n},last_window_param:null,s
|