# Change DataSources without removing all

**URL:** <https://community.cesium.com/t/change-datasources-without-removing-all/20676>\
**Category:** CesiumJS\
**Created:** [October 5, 2022, 11:39pm UTC](https://community.cesium.com/t/change-datasources-without-removing-all/20676 "2022-10-05T23:39:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bok96](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/bok96/32/10224_2.png) [@bok96](https://community.cesium.com/u/bok96)\
**Post date:** [October 5, 2022, 11:39pm UTC](https://community.cesium.com/t/change-datasources-without-removing-all/20676/1 "2022-10-05T23:39:51Z")

</div>

Hello. I’m developer using cesium js to display 3d building models.

```auto
async function loadData() {
	try {
		const extent = getCurrentExtent3D();
		if(extent && !isBuildingLoading) {
			console.log("loading start");
			let geoJsonGBuildings = geoserverOwsUrl + '?service=WFS&version=1.0.0&request=GetFeature&typeName=gucms%3Ag_buildings_with_img&maxFeatures=10000&outputFormat=application%2Fjson&bbox=';
			extent.forEach(function(e, i) {
				geoJsonGBuildings += e;
				if(i != extent.length - 1) geoJsonGBuildings += ',';
			});
			
			if(map3D.dataSources.contains(dataSourceGBuildings)) {
				map3D.dataSources.remove(dataSourceGBuildings);
			}
			isBuildingLoading = true;
			
			dataSourceGBuildings = await Cesium.GeoJsonDataSource.load(geoJsonGBuildings, {
				clampToGround: false,
			});
			dataSourceGBuildings.changedEvent = function() {
				console.log("datasource changed.");
			}
			isBuildingLoading = false;
			console.log("loaded.");

			map3D.dataSources.add(dataSourceGBuildings);
		} else {
			return;
		}
	} catch (err) {
        console.log("Error: ", err);
    }
}

```

I loaded 3d geojson building datas using geoserver.  
when I moved the camera, load the 3d geojson building data and add the buildings to the map.

but now, I remove all 3d buildings when i moved the camera.  
I want to replace some datasources with new building data. (without removing whole data)  
help me.

(variable ‘map3D’ is Cesium.Viewer)

---

<div class="post-metadata">

**Author:** ![Gabby\_Getz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/gabby_getz/32/7838_2.png) [@Gabby\_Getz](https://community.cesium.com/u/Gabby_Getz)\
**Post date:** [October 20, 2022, 1:40pm UTC](https://community.cesium.com/t/change-datasources-without-removing-all/20676/2 "2022-10-20T13:40:59Z")

</div>

Hello there,

You can hide entities loaded from a GeoJson:

```auto
   for (var i = 0; i < dataSourceGBuildings.entities.values.length; i++) {
        var entity = dataSourceGBuildings.entities.values[i];
        // Whatever condition you want to hide the buildings based on
        entity.show = false;
    }

```
