XWWitPark/witpark_szjsc/xw_szjsc_web/public/widgets/queryRoute/widget.js

2 lines
7.6 KiB
JavaScript
Raw Permalink Normal View History

2024-09-12 00:10:00 +00:00
/* 2020-9-24 14:48:24 | 版权所有 军懋国兴 */
mars3d.widget.bindClass(mars3d.widget.BaseWidget.extend({options:{resources:["./lib/cesiumjs/plugins/class/GaodeRoute.js","./lib/cesiumjs/plugins/class/GaodePOI.js"],view:{type:"window",url:"view.html",windowOptions:{width:350}}},create:function(){},viewWindow:null,winCreateOK:function(t,e){this.viewWindow=e},gaodeRoute:null,gaodePOI:null,activate:function(){this.gaodeRoute=new GaodeRoute,this.gaodePOI=new GaodePOI},disable:function(){this.gaodeRoute=null,this.startLnglat=null,this.endLnglat=null,this.startPoint&&(this.viewer.mars.draw.deleteEntity(this.startPoint),this.viewer.entities.remove(this.startPoint),this.startPoint=null),this.endPoint&&(this.viewer.mars.draw.deleteEntity(this.endPoint),this.viewer.entities.remove(this.endPoint),this.endPoint=null),this.alreadyCompute=!1,this.gaodePOI=null,this.gaodeRoute=null,this.startLnglat=null,this.startPoint=null,this.endLnglat=null,this.endPoint=null,this.clearCoumpute()},queryPOI:function(t,e){var i;t&&e&&((i={success:function(t){this.viewWindow.setHtmlInMCXD(t,e)},error:function(t){window.toastr.error(t),haoutil.loading.close()}}).text=t,this.gaodePOI&&this.gaodePOI.queryText(i))},startLnglat:null,startPoint:null,drawStartPoint:function(o){var a=this;a.viewer.mars.draw.startDraw({type:"billboard",style:{image:this.path+"img/start.png"},success:function(t){var e=a.viewer.clock.currentTime,i=t.position.getValue(e),r=Cesium.Cartographic.fromCartesian(i),n=Number(Cesium.Math.toDegrees(r.longitude).toFixed(6)),s=Number(Cesium.Math.toDegrees(r.latitude).toFixed(6));o&&o(n+","+s),a.startLnglat=[n,s],a.startPoint?(a.viewer.mars.draw.deleteEntity(t),a.startPoint.position.setValue(i)):a.startPoint=t,a.startCompute()}})},inputStartPoint:function(t,e){var i,r;t&&e&&(this.startPoint&&(this.viewer.mars.draw.deleteEntity(this.startPoint),this.viewer.entities.remove(this.startPoint)),this.startLnglat=[t,e],i=Cesium.Cartesian3.fromDegrees(t,e),r=this.viewer.entities.add({position:i,billboard:{image:this.path+"img/start.png",horizontalOrigin:Cesium.HorizontalOrigin.CENTER,verticalOrigin:Cesium.VerticalOrigin.BOTTOM,scale:1,heightReference:Cesium.HeightReference.CLAMP_TO_GROUND}}),this.startPoint=r,this.locateByJWD({jd:t,wd:e}),this.startCompute())},queryStartPoint:function(t){t?this.queryPOI(t,"start"):window.toastr.error("请输入查询条件!")},endPoint:null,endLnglat:null,drawEndPoint:function(o){var a=this;a.viewer.mars.draw.startDraw({type:"billboard",style:{image:this.path+"img/end.png"},success:function(t){var e=a.viewer.clock.currentTime,i=t.position.getValue(e),r=Cesium.Cartographic.fromCartesian(i),n=Number(Cesium.Math.toDegrees(r.longitude).toFixed(6)),s=Number(Cesium.Math.toDegrees(r.latitude).toFixed(6));o&&o(n+","+s),a.endLnglat=[n,s],a.endPoint?(a.viewer.mars.draw.deleteEntity(t),a.endPoint.position.setValue(i)):a.endPoint=t,a.startCompute()}})},inputEndPoint:function(t,e){var i,r;t&&e&&(this.endPoint&&(this.viewer.mars.draw.deleteEntity(this.endPoint),this.viewer.entities.remove(this.endPoint)),this.endLnglat=[t,e],i=Cesium.Cartesian3.fromDegrees(t,e),r=this.viewer.entities.add({position:i,billboard:{image:this.path+"img/end.png",horizontalOrigin:Cesium.HorizontalOrigin.CENTER,verticalOrigin:Cesium.VerticalOrigin.BOTTOM,scale:1,heightReference:Cesium.HeightReference.CLAMP_TO_GROUND}}),this.endPoint=r,this.locateByJWD({jd:t,wd:e}),this.startCompute())},queryEndPoint:function(t){t?this.queryPOI(t,"end"):window.toastr.error("请输入查询条件!")},clearCoumpute:function(){for(var t=this.colorStep=0;t<this.routeArr.length;t++){var e=this.routeArr[t];e&&this.viewer.entities.remove(e)}this.routeArr=[],this.viewWindow.clearRouteContent();for(var i=0;i<this.flyLineArr.length;i++){var r=this.flyLineArr[i];r&&r.destroy()}this.flyLineArr=[],this.removeTrack(),this.nowFline&&(this.nowFline.destroy(),this.nowFline=null),$("#mapDH_speed").remove()},alreadyCompute:!1,startCompute:function(){var r;this.startLnglat&&0!=this.startLnglat.length&&this.endLnglat&&0!=this.endLnglat.length&&(this.alreadyCompute&&this.clearCoumpute(),(r=this).gaodeRoute.query({type:3,points:[this.start