| | |
| | | // }) |
| | | // } |
| | | addTreeNode(node, "4"); |
| | | saveDrawEntity("polygon",drawpointArr,measurePolyGonGroundEntity.id); |
| | | } |
| | | for (let i in drawpointArr) { |
| | | viewer.entities.remove(drawpointArr[i]); |
| | |
| | | measureLineGroundEntity.polyline.positions = new Cesium.CallbackProperty(function () { |
| | | return measureLinePositonsArray; |
| | | }, false) |
| | | |
| | | var drawpointArr = measureLineGroundEntity.drawpointArr; |
| | | //节点添加标签 |
| | | function addPin(carPoi) { |
| | |
| | | // } |
| | | |
| | | addTreeNode(node, "4"); |
| | | saveDrawEntity("polyline",drawpointArr,measureLineGroundEntity.id); |
| | | } |
| | | for (let i in drawpointArr) { |
| | | viewer.entities.remove(drawpointArr[i]); |
| | |
| | | drawHandler.setInputAction(function (movement) { |
| | | //获取鼠标点击处的坐标 |
| | | drawHandler = drawHandler && drawHandler.destroy(); |
| | | var cartesian = options.viewer.scene.pickPosition(movement.position); |
| | | var cartographic = Cesium.Cartographic.fromCartesian(cartesian); |
| | | var height = cartographic.height;//模型高度 |
| | | if (Number(height) < 0) { |
| | | var ray = options.viewer.camera.getPickRay(movement.position); |
| | | cartesian = options.viewer.scene.globe.pick(ray, options.viewer.scene); |
| | | } |
| | | cartographic = Cesium.Cartographic.fromCartesian(cartesian); |
| | | height = cartographic.height;//地形高度 |
| | | // var lng = Cesium.Math.toDegrees(cartographic.longitude); |
| | | // var lat = Cesium.Math.toDegrees(cartographic.latitude); |
| | | // var poiResult = lng + "," + lat + "," + height; |
| | | // document.getElementById(options.printId).value = poiResult; |
| | | // var drawPointEntity = options.viewer.entities.getById("drawPointEntity"); |
| | | // if(drawPointEntity == undefined){ |
| | | var entity = viewer.entities.add({ |
| | | name: 'drawPointEntity', |
| | | position: cartesian.clone(), |
| | | point: { |
| | | color: options.pointcolor, |
| | | pixelSize: 10, |
| | | outlineColor: Cesium.Color.WHITE, |
| | | outlineWidth: 2, |
| | | disableDepthTestDistance: Number.POSITIVE_INFINITY |
| | | // var cartesian = options.viewer.scene.pickPosition(movement.position); |
| | | // var cartographic = Cesium.Cartographic.fromCartesian(cartesian); |
| | | // var height = cartographic.height;//模型高度 |
| | | // if (Number(height) < 0) { |
| | | // var ray = options.viewer.camera.getPickRay(movement.position); |
| | | // cartesian = options.viewer.scene.globe.pick(ray, options.viewer.scene); |
| | | // } |
| | | // cartographic = Cesium.Cartographic.fromCartesian(cartesian); |
| | | // height = cartographic.height;//地形高度 |
| | | // var entity = viewer.entities.add({ |
| | | // name: 'drawPointEntity', |
| | | // position: cartesian.clone(), |
| | | // point: { |
| | | // color: options.pointcolor, |
| | | // pixelSize: 10, |
| | | // outlineColor: Cesium.Color.WHITE, |
| | | // outlineWidth: 2, |
| | | // disableDepthTestDistance: Number.POSITIVE_INFINITY |
| | | // } |
| | | // }); |
| | | let position = viewer.scene.camera.pickEllipsoid(movement.position, viewer.scene.globe.ellipsoid); |
| | | let pointText="点" + new Date().format("yyyyMMddhhmmss"); |
| | | var entity=viewer.entities.add({ |
| | | name:"drawPointEntity", |
| | | position:position, |
| | | label: { |
| | | show: true, |
| | | verticalOrigin: Cesium.VerticalOrigin.BOTTOM, |
| | | horizontalOrigin: Cesium.HorizontalOrigin.CENTER, |
| | | font: 'bold 14px Helvetica', |
| | | fillColor: Cesium.Color.WHITE, |
| | | text: pointText, |
| | | disableDepthTestDistance: Number.POSITIVE_INFINITY, |
| | | heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, |
| | | distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 200000000.0) |
| | | }, |
| | | billboard: { |
| | | image: "../assets/images/icon/icon1.png", |
| | | width: 40, |
| | | height: 40, |
| | | rotation: 0, |
| | | verticalOrigin: Cesium.VerticalOrigin.TOP, |
| | | horizontalOrigin: Cesium.HorizontalOrigin.CENTER, |
| | | disableDepthTestDistance: Number.POSITIVE_INFINITY,//广告牌不进行深度检测 |
| | | heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, |
| | | distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 200000000.0) |
| | | } |
| | | }); |
| | | entity.title = "点" + new Date().format("yyyyMMddhhmmss"); |
| | | var cartesian = entity._position._value |
| | | let popup = new Popup({ |
| | | viewer:viewer, |
| | | geometry:cartesian, |
| | | entity:entity, |
| | | id: "pop_" + entity.id, |
| | | type:'image', |
| | | content:null, |
| | | }) |
| | | entity.title = pointText; |
| | | addTreeNode({ |
| | | "title": entity.title, |
| | | "id": entity.id, |
| | |
| | | "spread": true, |
| | | "children": [], |
| | | "ext": { |
| | | "lng": Cesium.Math.toDegrees(cartographic.longitude), |
| | | "lat": Cesium.Math.toDegrees(cartographic.latitude) |
| | | "lng": Cesium.Math.toDegrees(cartesian.x), |
| | | "lat": Cesium.Math.toDegrees(cartesian.y) |
| | | } |
| | | }, "4"); |
| | | saveDrawEntity("point",entity,entity.id); |
| | | }, Cesium.ScreenSpaceEventType.LEFT_CLICK); |
| | | } |
| | | |
| | |
| | | "lat": Cesium.Math.toDegrees(cartographic.latitude) |
| | | } |
| | | }, "4"); |
| | | saveDrawEntity("label",entity,entity.id); |
| | | drawHandler = drawHandler && drawHandler.destroy(); |
| | | }, Cesium.ScreenSpaceEventType.LEFT_CLICK); |
| | | } |
| | |
| | | } else { |
| | | console.log("CesiumDraw already defined."); |
| | | } |
| | | })(window); |
| | | })(window); |
| | | |