addCompany.js 2.94 KB
export default {
    createPoint(opt) {
        return this.viewer.entities.add({
            position: opt.position,
            point: opt.point || {
                pixelSize: 5,
                color: Cesium.Color.YELLOW,
                outlineWidth: 2,
                outlineColor: Cesium.Color.DARKRED,
                disableDepthTestDistance: Number.POSITIVE_INFINITY
            },
            show: false
        });
    },
    createPolyline(positions) {
        let style = this.style || {};
        var polyline = this.viewer.entities.add({
            polyline: {
                positions: new Cesium.CallbackProperty(() => {
                    return positions || this.positions
                }, false),
                show: true,
                material: style.material || Cesium.Color.YELLOW,
                width: style.width || 3,
                clampToGround: style.clampToGround == undefined ? false : true
            }
        });
        polyline.objId = this.objId;
        return polyline;
    },
    createPolygon() {
        return this.viewer.entities.add({
            polygon: {
                hierarchy: new Cesium.CallbackProperty(() => {
                    return new Cesium.PolygonHierarchy(this.positions)
                }, false),
                material: new Cesium.Color.fromCssColorString("#FFD700").withAlpha(.2),
                perPositionHeight: true,
                width: 3,
                outlineColor: Cesium.Color.BLACK,
                outlineWidth: 3,
                outline: true
            }
        });
    }, 
    createRectangle() {
        var that = this;
        var rectangle = this.viewer.entities.add({
            rectangle: {
                coordinates: new Cesium.CallbackProperty(() => {
                    return Cesium.Rectangle.fromCartesianArray([this.leftup, this.rightdown])
                }, false),
                material: new Cesium.Color.fromCssColorString("#FFD700").withAlpha(.2),
                perPositionHeight: true,
                width: 3,
                outlineColor: Cesium.Color.BLACK,
                outlineWidth: 3,
                outline: true
            }
        });
        rectangle.objId = this.objId;
        return rectangle;
    },
    createCircle() {
        var ellipse = this.viewer.entities.add({
            position: this.center,
            ellipse: {
                semiMajorAxis: new Cesium.CallbackProperty(() => {
                    return this.radius
                }, false),
                semiMinorAxis: new Cesium.CallbackProperty(() => {
                    return this.radius
                }, false),
                material: new Cesium.Color.fromCssColorString("#FFD700").withAlpha(.2),
                perPositionHeight: true,
                width: 3,
                outlineColor: Cesium.Color.BLACK,
                outlineWidth: 3,
                outline: true
            }
        });
        ellipse.objId = this.objId;
        return ellipse;
    }
}