# How to create dataSource from entities?

**URL:** <https://community.cesium.com/t/how-to-create-datasource-from-entities/8666>\
**Category:** CesiumJS\
**Created:** [September 16, 2019, 11:57am UTC](https://community.cesium.com/t/how-to-create-datasource-from-entities/8666 "2019-09-16T11:57:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniele\_Suppo](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/daniele_suppo/32/2143_2.png) [@Daniele\_Suppo](https://community.cesium.com/u/Daniele_Suppo)\
**Post date:** [September 16, 2019, 11:57am UTC](https://community.cesium.com/t/how-to-create-datasource-from-entities/8666/1 "2019-09-16T11:57:17Z")

</div>

**1. A concise explanation of the problem you’re experiencing.**

I have created some billboards and some labels, and I’d like to put them in a cluster to control their visibility through pixelRange.

I’ve read that I need to create a dataSource, but how to create a dataSource from entities?

**2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.**

viewer.entities.add({

position: Cesium.Cartesian3.fromDegrees(longitude, latitude),

billboard: {

image: ‘images/pin\_icon.svg’,

width: 16.3,

height: 21.3,

verticalOrigin: Cesium.VerticalOrigin.BOTTOM,

heightReference: Cesium.HeightReference.RELATIVE\_TO\_GROUND,

}

/// now I should put this entity in a dataSource / cluster

**3. Context. Why do you need to do this? We might know a better way to accomplish your goal.**

to control their visibility through pixelRange.

**4. The Cesium version you’re using, your operating system and browser.**

1.61

---

<div class="post-metadata">

**Author:** ![Daniele\_Suppo](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/daniele_suppo/32/2143_2.png) [@Daniele\_Suppo](https://community.cesium.com/u/Daniele_Suppo)\
**Post date:** [September 16, 2019, 2:36pm UTC](https://community.cesium.com/t/how-to-create-datasource-from-entities/8666/2 "2019-09-16T14:36:05Z")

</div>

This is the solution

```auto
var dataSource = new Cesium.CustomDataSource('myData');

var entity = dataSource.entities.add({
   position : Cesium.Cartesian3.fromDegrees(1, 2, 0),
   billboard : {
       image : 'image.png'
   }
});

viewer.dataSources.add(dataSource);

```
