# Dynamically add or remove entities from a geojson datasource. Please help!

**URL:** <https://community.cesium.com/t/dynamically-add-or-remove-entities-from-a-geojson-datasource-please-help/28054>\
**Category:** CesiumJS\
**Created:** [November 14, 2023, 4:45pm UTC](https://community.cesium.com/t/dynamically-add-or-remove-entities-from-a-geojson-datasource-please-help/28054 "2023-11-14T16:45:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Federico\_Marcantogni](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/federico_marcantogni/32/12874_2.png) [@Federico\_Marcantogni](https://community.cesium.com/u/Federico_Marcantogni)\
**Post date:** [November 14, 2023, 4:45pm UTC](https://community.cesium.com/t/dynamically-add-or-remove-entities-from-a-geojson-datasource-please-help/28054/1 "2023-11-14T16:45:57Z")

</div>

Hi all,  
I am stuck trying to filter features in a geojson based on features’ id and a text input field. I can display all the entities in the datasource, do the show=true/false for the entire geojson, but I cannot get my head around how to efficiently show only the entities based on condition.

Since I have two variables - a js object that reduces or increases based on user input, and a datasource with a feature collection, I assume a nested loop should do the job but it does not:

```auto
const entities = viewer.dataSources.getByName(dataSourceName)[0].entities.values;

for (let i = 0; i < entities.length; i++) {
	for(let ii = 0; ii < $filtered_features.features.length; ii++){
		if($filtered_features.features[ii].properties.item_id === entities[i].properties.item_id._value) {
			entities[i].show = true; //console.log("SHOW THIS ENTITY!")
		} else {
			entities[i].show = false; //console.log("HIDE THIS ENTITY!")
		}
	}
}

```

I am picking up the property ‘item\_id’ to do the check between the user-filtered list and the actual features that need to be dynamically shown/hidden from the geojson in viewer. The issue is that I cannot visualize correctly the filtered entities based on the user input field.  
Any heads up?
