| | |
| | | //获取鼠标点击处的坐标 |
| | | drawHandler = drawHandler && drawHandler.destroy(); |
| | | let position = viewer.scene.camera.pickEllipsoid(movement.position, viewer.scene.globe.ellipsoid); |
| | | position = viewer.scene.pickPosition(movement.position); |
| | | let pointText="点" + new Date().format("yyyyMMddhhmmss"); |
| | | var entity=viewer.entities.add({ |
| | | name:"drawPointEntity", |
| | |
| | | font: '10px SimSun', |
| | | fillColor: Cesium.Color.WHITE, |
| | | text: pointText, |
| | | eyeOffset:new Cesium.Cartesian3(0,20,0), |
| | | disableDepthTestDistance: Number.POSITIVE_INFINITY, |
| | | heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, |
| | | distanceDisplayCondition: window.localStorage.getItem("visualDistance")?new Cesium.DistanceDisplayCondition(0, window.localStorage.getItem("visualDistance")):new Cesium.DistanceDisplayCondition(0, 100000.0) |
| | |
| | | //获取鼠标点击处的坐标 |
| | | drawHandler = drawHandler && drawHandler.destroy(); |
| | | let position = viewer.scene.camera.pickEllipsoid(movement.position, viewer.scene.globe.ellipsoid); |
| | | position = viewer.scene.pickPosition(movement.position); |
| | | let labelText="文字" + new Date().format("yyyyMMddhhmmss"); |
| | | var entity=viewer.entities.add({ |
| | | name:"drawLabelEntity", |
| | |
| | | font: '30px SimSun', |
| | | fillColor: Cesium.Color.WHITE, |
| | | text: labelText, |
| | | eyeOffset:new Cesium.Cartesian3(0,20,0), |
| | | disableDepthTestDistance: Number.POSITIVE_INFINITY, |
| | | heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, |
| | | distanceDisplayCondition: window.localStorage.getItem("visualDistance")?new Cesium.DistanceDisplayCondition(0, window.localStorage.getItem("visualDistance")):new Cesium.DistanceDisplayCondition(0, 100000.0) |
| | |
| | | }, Cesium.ScreenSpaceEventType.LEFT_CLICK); |
| | | } |
| | | |
| | | CesiumDraw.drawText = function (options) { |
| | | drawHandler = drawHandler && drawHandler.destroy(); |
| | | drawHandler = new Cesium.ScreenSpaceEventHandler(options.viewer.scene.canvas); |
| | | drawHandler.setInputAction(function (movement) { |
| | | let position = viewer.scene.pickPosition(movement.position); |
| | | let labelText="标签" + new Date().format("yyyyMMddhhmmss"); |
| | | var entity=viewer.entities.add({ |
| | | name:"drawTextEtity", |
| | | position:position, |
| | | label: { |
| | | show: true, |
| | | verticalOrigin: Cesium.VerticalOrigin.BOTTOM, |
| | | horizontalOrigin: Cesium.HorizontalOrigin.CENTER, |
| | | font: '20px LiSu', |
| | | fillColor: Cesium.Color.YELLOW, |
| | | text: labelText, |
| | | eyeOffset:new Cesium.Cartesian3(0,20,0), |
| | | disableDepthTestDistance: Number.POSITIVE_INFINITY, |
| | | heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, |
| | | distanceDisplayCondition: window.localStorage.getItem("visualDistance")?new Cesium.DistanceDisplayCondition(0, window.localStorage.getItem("visualDistance")):new Cesium.DistanceDisplayCondition(0, 100000.0) |
| | | }, |
| | | }); |
| | | entity.title = labelText; |
| | | var cartesian = entity._position._value |
| | | addTreeNode({ |
| | | "title": entity.title, |
| | | "id": entity.id, |
| | | "field": "Entity", |
| | | "checked": true, |
| | | "spread": true, |
| | | "children": [], |
| | | "ext": { |
| | | "lng": Cesium.Math.toDegrees(cartesian.x), |
| | | "lat": Cesium.Math.toDegrees(cartesian.y) |
| | | } |
| | | }, "4"); |
| | | saveDrawEntity("text",entity,entity.id); |
| | | drawHandler = drawHandler && drawHandler.destroy(); |
| | | }, Cesium.ScreenSpaceEventType.LEFT_CLICK); |
| | | } |
| | | |
| | | CesiumDraw.clearDraw = function (options) { |
| | | |
| | | } |