# Show/Hide entities using Cesium.CallbackProperty

**URL:** <https://community.cesium.com/t/show-hide-entities-using-cesium-callbackproperty/12736>\
**Category:** CesiumJS\
**Created:** [March 24, 2021, 1:14pm UTC](https://community.cesium.com/t/show-hide-entities-using-cesium-callbackproperty/12736 "2021-03-24T13:14:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LukeV111](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/lukev111/32/4392_2.png) [@LukeV111](https://community.cesium.com/u/LukeV111)\
**Post date:** [March 24, 2021, 1:14pm UTC](https://community.cesium.com/t/show-hide-entities-using-cesium-callbackproperty/12736/1 "2021-03-24T13:14:16Z")

</div>

I’m trying to show/hide entities using `Cesium.CallbackProperty` . My code is below:

```auto
viewer.entities.add({
      id,
      position: position,
      image: image,
      verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
      width: size,
      height: size,
      pixelOffset: Cesium.Cartesian2.fromElements(0, 0),
      heightReference: Cesium.HeightReference.NONE,
      eyeOffset: new Cesium.Cartesian3(0.0, 0.0, -1.0),
      show: new Cesium.CallbackProperty(toggleCallback, true),
    })

```

The callback code is just simple for a test:

```auto
function toggleCallback() {
    return false
  }

```

Now, whether I return true or false, the entity still shows.

Is `Cesium.CallbackProperty` perhaps not available on the `show` property?

What is a strategy for doing this? I imagine it’s quite a common use-case. I’m trying to hide/show an entity based on the position of the timeline.

---

<div class="post-metadata">

**Author:** ![dzung](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/dzung/32/2996_2.png) [@dzung](https://community.cesium.com/u/dzung)\
**Post date:** [April 5, 2021, 2:39pm UTC](https://community.cesium.com/t/show-hide-entities-using-cesium-callbackproperty/12736/2 "2021-04-05T14:39:03Z")

</div>

Welcome to the Cesium Community!

There are actually two ways you can indicate an entity’s visibility: one in the outer entity element itself and one in the entity type. For example:

```auto
var greenCylinder = viewer.entities.add({
  name: "Green cylinder with black outline",
  position: Cesium.Cartesian3.fromDegrees(-100.0, 40.0, 200000.0),
  cylinder: {
    length: 400000.0,
    topRadius: 200000.0,
    bottomRadius: 200000.0,
    material: Cesium.Color.GREEN.withAlpha(0.5),
    outline: true,
    outlineColor: Cesium.Color.DARK_GREEN,
    show: true, // SHOW CAN BE PLACED INSIDE THE CYLINDER 
  },
});

```

```auto
var greenCylinder = viewer.entities.add({
  name: "Green cylinder with black outline",
  position: Cesium.Cartesian3.fromDegrees(-100.0, 40.0, 200000.0),
  show: true, // SHOW CAN ALSO BE PLACED OUTSIDE THE CYLINDER 
  cylinder: {
    length: 400000.0,
    topRadius: 200000.0,
    bottomRadius: 200000.0,
    material: Cesium.Color.GREEN.withAlpha(0.5),
    outline: true,
    outlineColor: Cesium.Color.DARK_GREEN,
  },
});

```

In the first case, `show` is of type `Boolean`. In the second case, `show` is of type `Property`. Since `CallbackProperty` is of parent type `Property`, for the `CallbackProperty` to work, you would need to put it inside the cylinder.

Here is a [Sandcastle example](https://sandcastle.cesium.com/#c=rVPRbpswFP2VK55AYoZ26wuj0SoS9WHTNmXTnpAmB27AqrGRbYjSKf8+2yRLQ/tQVePBwodzzr0+14xUwchwhwpuQeAOCtRs6Mgvj4VlUPl9IYWhTKAqg+hjKUoxWp3C2uJohZMDQWGYYagJrevwTykABO0wgzJYYw2V5ZZB7OBeakuUIjuVK6gy9o2K92SrZLfERiHq8N1VekPSGD6kbr1O3UPSyHtUe85EjSoDXwmAo2hMm1nyRIsn2Mh+TWs26AzO4EYaI7sTfn2p6KhBxSg/dye5VGS9WnrCwa6HcwquU1Ecm3lNFvdO8K992DHTwobT6gHkYCz4hpDS/xjSLIy3JHW/Xq2+EnewO963NEzJTXRUHI+YgVEDXmJeO3Na3q0///Z2R65u5S57elELyvnGhvddyR6V2YdGNg3HExz7QtF8cNtBVC5buGSH0ZSTQjMoAVvKNVr+wc96muujlN1PGc6m7FyDOMi12XNcTK0CfGJdL5WBQfGQkMRg13ObmE42Q/WAhlTaCx01T55K85qNwOrbF34/qDjV2n7ZDpz/YI/2tizyxPKfSbm0QxPNtxEVp3tHa68WXyaQEJIndvuy0khp41Az578).
