VUE中cesium 添加polygon 报错

vue3.0  添加entity polygon  hierarchy属性使用回调函数CallbackProperty报错

 

var PolygonPrimitive = (function () {
    function _(hierarchy) {
        this.options = {
            polygon: {
                show: true,
                hierarchy: [],
                material: Cesium.Color.CORNFLOWERBLUE
            }
        };
        this.hierarchy = hierarchy;
        this._init();
    }
    _.prototype._init = function () {
        var _self = this;
        var _update = function () {
            return _self.hierarchy;
        };
        //实时更新polygon.hierarchy
        this.options.polygon.hierarchy = new Cesium.CallbackProperty(_update, false);
        const viewer = window.earth
        viewer.entities.add(this.options);
    };
    return _;
})();
export { PolygonPrimitive }

调试到源码 是在cesium  添加Polygon的时候出错了 PolygonGeometry.js中 var outerPositions = polygonHierarchy.positions;这个出错了。排查了下原因是因为polygon = new PolygonPrimitive(points) 这样传入的类型有问题,不是一个PolygonHierarchy类型,没有positions属性,而是一个三维坐标的数组,所以在传入的时候需要进行格式强制转换 polygon = new PolygonPrimitive(new Cesium.PolygonHierarchy(points)),但是polyline的话是可以直接传入坐标

之后还发现个奇怪的事,在vue中需要强制转换,在原生js中直接传入是可以的polygon = new PolygonPrimitive(points) 没有深究了

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值