| | |
| | | outlineColor: Cesium.Color.WHITE, |
| | | hierarchy: new Cesium.CallbackProperty(function () { |
| | | return polygon; |
| | | }, false) |
| | | }, false), |
| | | distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 10000000.0) |
| | | } |
| | | }); |
| | | |
| | |
| | | // }) |
| | | // } |
| | | addTreeNode(node, "4"); |
| | | saveDrawEntity("polygon",drawpointArr,measurePolyGonGroundEntity.id); |
| | | } |
| | | for (let i in drawpointArr) { |
| | | viewer.entities.remove(drawpointArr[i]); |
| | |
| | | clampToGround: true, |
| | | width: 1, |
| | | material: options.polylinecolor, |
| | | distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 10000000.0) |
| | | }, |
| | | drawpointArr: [], |
| | | measureLinePositonsArray: measureLinePositonsArray |
| | |
| | | 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 |
| | | } |
| | | }); |
| | | entity.title = "点" + new Date().format("yyyyMMddhhmmss"); |
| | | addTreeNode({ |
| | | "title": entity.title, |
| | | "id": entity.id, |
| | | "field": "Entity", |
| | | "checked": true, |
| | | "spread": true, |
| | | "children": [], |
| | | "ext": { |
| | | "lng": Cesium.Math.toDegrees(cartographic.longitude), |
| | | "lat": Cesium.Math.toDegrees(cartographic.latitude) |
| | | } |
| | | }, "4"); |
| | | }, Cesium.ScreenSpaceEventType.LEFT_CLICK); |
| | | } |
| | | |
| | | /** |
| | | * options{ |
| | | * viewer:CesiumViewer, |
| | | * label:{ |
| | | * text:'文字', |
| | | * font: '24px Helvetica', |
| | | * fillColor: Cesium.Color.SKYBLUE, |
| | | * outlineColor: Cesium.Color.BLACK, |
| | | * outlineWidth: 2, |
| | | * style: Cesium.LabelStyle.FILL_AND_OUTLINE, |
| | | * scaleByDistance: new Cesium.NearFarScalar(100, 1.0, 200, 0.4) |
| | | * } |
| | | * } |
| | | */ |
| | | CesiumDraw.drawLabel = function (options) { |
| | | drawHandler = drawHandler && drawHandler.destroy(); |
| | | drawHandler = new Cesium.ScreenSpaceEventHandler(options.viewer.scene.canvas); |
| | | drawHandler.setInputAction(function (movement) { |
| | | 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: 'drawLabelEtity', |
| | | position: cartesian.clone(), |
| | | 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", |
| | | position:position, |
| | | label: { |
| | | text: options.label.text, |
| | | font: options.label.font, |
| | | fillColor: options.label.fillColor, |
| | | outlineColor: options.label.outlineColor, |
| | | outlineWidth: options.label.outlineWidth, |
| | | style: options.label.style, |
| | | //scaleByDistance: options.label.scaleByDistance, |
| | | //eyeOffset: new Cesium.Cartesian3(0, 0, -10000), |
| | | text: pointText, |
| | | show: true, |
| | | verticalOrigin: Cesium.VerticalOrigin.BOTTOM, |
| | | horizontalOrigin: Cesium.HorizontalOrigin.CENTER, |
| | | font: '10px SimSun', |
| | | fillColor: Cesium.Color.WHITE, |
| | | outlineColor: Cesium.Color.BLACK, |
| | | outlineWidth: 2, |
| | | style: Cesium.LabelStyle.FILL_AND_OUTLINE, |
| | | eyeOffset:new Cesium.Cartesian3(0,20,0), |
| | | verticalOrigin: Cesium.VerticalOrigin.BOTTOM, |
| | | horizontalOrigin: Cesium.HorizontalOrigin.CENTER, |
| | | disableDepthTestDistance: Number.POSITIVE_INFINITY, |
| | | heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, |
| | | distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 10000000000000.0) |
| | | distanceDisplayCondition: window.localStorage.getItem("visualDistance")?new Cesium.DistanceDisplayCondition(0, window.localStorage.getItem("visualDistance")):new Cesium.DistanceDisplayCondition(0, 100000.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: window.localStorage.getItem("visualDistance")?new Cesium.DistanceDisplayCondition(0, window.localStorage.getItem("visualDistance")):new Cesium.DistanceDisplayCondition(0, 100000.0) |
| | | } |
| | | }); |
| | | //entity.title = "文字" + new Date().format("yyyyMMddhhmmss"), |
| | | entity.title =options.label.text,//修改树结构文字标题:zzf |
| | | entity.title = pointText; |
| | | var cartesian = entity._position._value |
| | | let popup = new Popup({ |
| | | viewer:viewer, |
| | | geometry:cartesian, |
| | | entity:entity, |
| | | id: "pop_" + entity.id, |
| | | type:'image', |
| | | content:null, |
| | | }) |
| | | 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); |
| | | } |
| | | |
| | | CesiumDraw.drawLabel = function (options) { |
| | | drawHandler = drawHandler && drawHandler.destroy(); |
| | | drawHandler = new Cesium.ScreenSpaceEventHandler(options.viewer.scene.canvas); |
| | | drawHandler.setInputAction(function (movement) { |
| | | //获取鼠标点击处的坐标 |
| | | 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", |
| | | position:position, |
| | | label: { |
| | | show: true, |
| | | verticalOrigin: Cesium.VerticalOrigin.BOTTOM, |
| | | horizontalOrigin: Cesium.HorizontalOrigin.CENTER, |
| | | font: '30px SimSun', |
| | | fillColor: Cesium.Color.WHITE, |
| | | outlineColor: Cesium.Color.BLACK, |
| | | outlineWidth: 2, |
| | | style: Cesium.LabelStyle.FILL_AND_OUTLINE, |
| | | 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) |
| | | }, |
| | | 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: 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 |
| | | let popup = new Popup({ |
| | | viewer:viewer, |
| | | geometry:cartesian, |
| | | entity:entity, |
| | | id: "pop_" + entity.id, |
| | | type:'label', |
| | | content:null, |
| | | }) |
| | | 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("label",entity,entity.id); |
| | | }, 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, |
| | | outlineColor: Cesium.Color.BLACK, |
| | | outlineWidth: 2, |
| | | style: Cesium.LabelStyle.FILL_AND_OUTLINE, |
| | | text: labelText, |
| | | 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); |
| | | } |
| | |
| | | } else { |
| | | console.log("CesiumDraw already defined."); |
| | | } |
| | | })(window); |
| | | })(window); |
| | | |