Cesium实战系列文章总目录
:
传送门
1.报错问题
在使用Primitive方式加载Geojson数据时,报错An error occurred while rendering. Rendering has stopped. DeveloperError: _workerName must be defined for asynchronous geometry Error
,截图如下:
2.解决方法
之前也使用primitive加载过geojson数据,但都是正常运行。
(1)首先看一下报错信息
提示信息是必须为geometry定义异步的workerName
。
然后去看一下官方文档的Primitive
接口,传送门
(2)发现其有一个属性asynchronous
,用于确定primitive是否是异步创建
。
将其值设置为false
即可解决问题,代码如下:
let primitive = new Cesium.Primitive({
geometryInstances: instances,
appearance: new Cesium.PerInstanceColorAppearance(),
asynchronous: false,
});