首页 / 浏览问题 / WebGIS / 问题详情
cesium绘制点
23EXP 2023年11月08日

在使用cesium的绘制工具绘制点的时候,生成的实体点不能通过viewer.entities.remove来删除吗?

pointHandler = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Point);

pointHandler.drawEvt.addEventListener((res: any) => {
				commStore.changeShowEditPlot(true);
				pointEntity = res.object;
				pointEntity.color = new Cesium.Color(1, 0, 0, 0.6);
				pointEntity.outlineColor = new Cesium.Color(1, 1, 0, 1);
				pointEntity.pixelSize = 20; //大小
				pointEntity.outlineWidth = 5; //外线宽度
			});


viewer.entities.remove(pointEntity); //这里删除实体不生效

1个回答

如果要单独移除实体,可以打印pointHandler,获取pointHandler中的对应id,通过removeById的方式即可
4,151EXP 2023年11月08日
但是这里拿到的id是undefined,改怎么处理呢
您的获取id的代码是怎么写的呢
...