`function DynamicPolygonPrimitive(features, options = {}) {
this.features = features;
this.color = options.color;
this.tag = options.tag;
this.primitive = null;
}`
`DynamicPolygonPrimitive.prototype.update = function (context) {
const geometryInstances = [];
this.features &&
this.features.forEach((feature) => {
const geometry = this.getGeometry(feature);
if (!geometry) {
return false;
}
const id = feature.properties.type
? feature.properties.name + ".plan"
: feature.properties.name + ".real";
const color = feature.properties.type ? "#1f8525" : "#ff0099";
geometryInstances.push(
new Cesium.GeometryInstance({
geometry,
attributes: {
color: Cesium.ColorGeometryInstanceAttribute.fromColor(
Cesium.Color.fromCssColorString(color)
),
},
id,
})
);
});
this.primitive = new Cesium.GroundPrimitive({
geometryInstances,
appearance: new Cesium.PerInstanceColorAppearance(),
asynchronous: false,
});
this.primitive.update(context);
};`
`viewer.scene.primitives.add(new DynamicPolygonPrimitive(features,options))`
This is codes to make a dynamic polygon with Primitive API. It runs with some datas sucessfully, however some in failure. Those datas are not different structurally. Error information is below:
I am very honored to have some one helping me. Thanks a lot!