Issue with Cesium entity visibility control

27 Views Asked by At

I'm facing an issue with controlling the visibility of entities in Cesium. sometimes it is abnormal when i changed the value of checkedList I'm trying to toggle the visibility of entities, but I'm experiencing unexpected behavior. The entities don't hide/show as expected. like this

enter image description here

The left side is abnormal and the right side is normal display.

this is my thinking:

  1. Upon the initial rendering of the component, create and categorize all points based on their IDs,then put then in diffent arrays,like entityType1Arr,entityType2Arr.

  2. Utilize the useState hook to establish an array named checkedList, which will be linked to the Ant Design Checkbox component.

  3. Implement a listener to monitor changes in the checkList array. When changes occur, dynamically adjust the show property of the associated entities. This approach enables real-time control over the visibility of entities based on the checked or unchecked state of the checkboxes.

useEffect(()=>{
     entityType1Arr.forEach((entity) => {
            entity.show = checkedList.includes("type1");
        });
entityType2Arr.forEach((entity) => {
            entity.show = checkedList.includes("type2");
        });
},[checkedList])
0

There are 0 best solutions below