How to delete a Primitive?

I'm trying to delete a primitive (Polygon or Polyline) previously added like this:




but both methods give me this error:

DeveloperError: This object was destroyed, i.e., destroy() was called.
    at new t (
    at o (
    at o.update (
    at tt (
    at at.render (
    at P.render (
    at t (

That exception indicated that you are doing something causing the primitive to be destroyed twice. I believe primitives get destroyed automatically on remove by default, so no other work should need to be done on your part. Can you post a more complete example so we can help you pinpoint the problem?

Thank you Matthew,
I realized that


is working fine if primitive is a Polygon or a Polyline but give me the same error if it’s a BillboardCollection

Can you post a small snippet of code that reproduces the problem?

Sorry Matthew, I’ve found my problem.
I think the error was caused adding a BillboardCollection twice.