question about deleting objects on Cesium

Hello,

I'm working with Cesium to draw and display polygons. I was able to create a webapp that allows you to draw a custom polygon on the Cesium globe, and then saves it by storing it in the database and generating CZML to be displayed by Cesium. I'm running into an issue when I try to delete the object. I'm currently using the CesiumViewerWidget along with onSelectObject to highlight the different CZML polygons on the globe. However, after deleting the object, I can't seem to get the CesiumViewerWidget to remove just the selected polygon without a complete page refresh. I am able to delete the polygon from the database just fine, but by using the selectedObject I can't seem to cause Cesium to stop showing the polygon after it has been deleted from the DB.

Any ideas as to how this can be done? I have been able to dynamically add polygons to the globe (without refresh) using addCzml, but there doesn't appear to be something other than removeAllCzml for removing objects from being displayed.

Any help would be greatly appreciated.
Thanks,
Paul

Sorry for the slow reply. DynamicObjectCollection doesn’t have a removeObject function yet (though we definitely plan on adding it). I did a quick implementation that should work for you, give this a try. (Note, I didn’t thoroughly test this yet).

DynamicObjectCollection.prototype.removeObject = function(id) {

if (typeof id === ‘undefined’) {

throw new DeveloperError(‘id is required.’);

}

var dynamicObject = this._hash[id];

var result = typeof dynamicObject !== ‘undefined’;

if (result) {

this._hash[id] = undefined;

this._array.splice(this._array.indexof(dynamicObject), 1);

this.objectsRemoved.raiseEvent(this, [dynamicObject]);

}

return result;

};

If it still doesn’t go away, you might need to call “visualizers.removeAllPrimitives();” then remove the object and then call “visualizers.update”. But only take these extra steps if the above doesn’t work as is.

If this doesn’t work, let me know and I’ll look more into it. As soon as I clear my plate of some other items, I plan on spending a lot of time on client-side object manipulation like this.