# How to remove featurecollection added to cesium?

**URL:** <https://community.cesium.com/t/how-to-remove-featurecollection-added-to-cesium/4814>\
**Category:** CesiumJS\
**Created:** [November 15, 2016, 4:46pm UTC](https://community.cesium.com/t/how-to-remove-featurecollection-added-to-cesium/4814 "2016-11-15T16:46:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sai\_Asuka](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@Sai\_Asuka](https://community.cesium.com/u/Sai_Asuka)\
**Post date:** [November 15, 2016, 4:46pm UTC](https://community.cesium.com/t/how-to-remove-featurecollection-added-to-cesium/4814/1 "2016-11-15T16:46:51Z")

</div>

I have a geojson featurecollection with 300 features added with:

for(var i = 0; myfeatures.length; i++) {

var promise = Cesium.GeoJsonDataSource.load(myfeatures[i]);

promise.then(function(dataSource) {

dataSource.\_name = “TESTFEATURE”

}

}

What is the right way to remove and hide all the features based on a property (in this case, .\_name)?

The following works to only hide it, but not remove it:

var entities = viewer.dataSources;

for (var i = 0; i \< entities.length; i++) {

var entity = entities.\_dataSources[i];

if(entities.\_dataSources[i].name == “TESTFEATURE”) {

viewer.dataSources.\_dataSources[i].\_entityCollection.\_entities.values[0].show = false;

// viewer.dataSources.remove(entity); // when I uncomment out this line, it looks like Cesium only removes half of the features, and not all of them

}

Though I can get the features to hide, what is the proper way to remove all the feature’s I’ve added that match the condition that the \_name is “TESTFEATURE”?
