Now polygon do not support callback,why? if that, how can do it? i

polygon: {
hierarchy: new Cesium.CallbackProperty(function(){ return m_obj.vertexList; }, false)
}

I think that should work if everything is set up correctly. Can you post a full code example on Sandcastle and share it here?

viewer.entities.add({

            name: 'polygon',

            polygon: {

                hierarchy: Cesium.Cartesian3.fromDegreesArray([121.77985082466147, 45.82755690534447,

                    121.92469306468644, 45.80741140225098, 121.90339453936461, 45.74846492085525,

                    121.81711483813052, 45.74476402445927, 121.67304724790127, 45.80900628113477,

                    121.56677650112483, 45.86267409629869

                ]),

                material: Cesium.Color.RED

            }

        });

handler.setInputAction(function (e) {

            // 获取屏幕坐标

            let windowPosition = e.position;

            // 通过屏幕坐标获取当前位置的实体信息

            let pickedObject = viewer.scene.pick(windowPosition);

               console.log(pickedObject)

            // 如果实体信息存在则说明该位置存在实体

            if (Cesium.defined(pickedObject)) {

                // 获取当前点的实体

                let entity = pickedObject.id;

                // 如果实体为面同时没有处于编辑状态,那么保存面的实体 

                if (entity.name === "polygon" && !isEditable) {

                    entityObj = entity;

                    // 生成编辑点

                    for (let cartesian of entityObj.polygon.hierarchy._value.positions) {

                        let point = viewer.entities.add({

                            name: "gon_point",

                            position: cartesian,

                            point: {

                                color: Cesium.Color.WHITE,

                                pixelSize: 8,

                                outlineColor: Cesium.Color.BLACK,

                                outlineWidth: 1

                            }

                        });

                        // 保存点的ID以便删除

                        pointsId.push(point.id);

                    }

                    // 设置编辑状态为true 

                    isEditable = true;

                    // 禁止地球旋转和缩放,地球的旋转会对鼠标移动监听有影响,所以需要禁止

                    viewer.scene.screenSpaceCameraController.enableRotate = false;

                    viewer.scene.screenSpaceCameraController.enableZoom = false;

                } else if (entity.name === "gon_point") {

                    // 如果实体为编辑点,那么设置当前编辑点为该点

                    currentPoint = entity;

                }

            }

        }, Cesium.ScreenSpaceEventType.LEFT_DOWN)

        handler.setInputAction((event) => {

            if (isEditable && currentPoint) {

                let windowPosition = event.startPosition;

                let ellipsoid = viewer.scene.globe.ellipsoid;

                let cartesian = viewer.camera.pickEllipsoid(windowPosition, ellipsoid);

                if (!cartesian) {

                    return;

                }

                currentPoint.position = cartesian;

                let points = [];

                for (let id of pointsId) {

                    points.push(viewer.entities.getById(id).position._value);

                }

                entityObj.polygon.hierarchy = new Cesium.CallbackProperty(() => {

                    return points;

                }, false);

            }

        }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

polygon use a callback to report an error as follows:

An error occurred while rendering. Rendering has stopped.
TypeError: Cannot read property ‘length’ of undefined
TypeError: Cannot read property ‘length’ of undefined

I’m having trouble running your example - I think the code you posted is missing some sections (like “isEditable” is not defined). Can you share a direct link to your code example like the instructions here explain: How to share custom Sandcastle examples ?

var positionList =

  var firstClick = true;

  var pos={positions:null};

  var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);

  handler.setInputAction(function (e) {

       var position = viewer.scene.pickPosition(e.position)

      var cartographic = new Cesium.Cartographic.fromCartesian(position);

      var lon = Cesium.Math.toDegrees(cartographic.longitude)

      var lat = Cesium.Math.toDegrees(cartographic.latitude)

      var height = cartographic.height; 

      positionList.push(lon)

      positionList.push(lat)

    if (firstClick) {

      pos.positions=Cesium.Cartesian3.fromDegreesArray(positionList);

      viewer.entities.add({

        name: 'areaPolygon',

        show: true,

        polygon: {

          hierarchy: new Cesium.CallbackProperty(function () {

            return pos.positions;

          }, false),

          //extrudedHeight:5000,

          material: Cesium.Color.YELLOW.withAlpha(0.8),

        }

      });

      firstClick=false;

    }else{

        pos.positions=Cesium.Cartesian3.fromDegreesArray(positionList);

    }

    console.log(position)

  }, Cesium.ScreenSpaceEventType.LEFT_CLICK)

  handler.setInputAction(function(e){

    var position = viewer.scene.pickPosition(e.position)

      var cartographic = new Cesium.Cartographic.fromCartesian(position);

      var lon = Cesium.Math.toDegrees(cartographic.longitude)

      var lat = Cesium.Math.toDegrees(cartographic.latitude)

      var height = cartographic.height; 

      positionList.push(lon)

      positionList.push(lat)

      pos.positions=Cesium.Cartesian3.fromDegreesArray(positionList);



      handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK)

  },Cesium.ScreenSpaceEventType.RIGHT_CLICK)
  • Please try this code

the error is this:
PolygonGeometry.createGeometry = function (polygonGeometry) {
var vertexFormat = polygonGeometry._vertexFormat;
var ellipsoid = polygonGeometry._ellipsoid;
var granularity = polygonGeometry._granularity;
var stRotation = polygonGeometry._stRotation;
var polygonHierarchy = polygonGeometry._polygonHierarchy;
var perPositionHeight = polygonGeometry._perPositionHeight;
var closeTop = polygonGeometry._closeTop;
var closeBottom = polygonGeometry._closeBottom;
var arcType = polygonGeometry._arcType;

var outerPositions = polygonHierarchy.positions; // this undefined

thank you for your help