treating each polygon in geojson as seperate entity

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

I have a geojson which has multiple polygons in it as shown in the file. Now i want to feature picker on it as the cesium demo of polygons but it is giving me the error that the entity of id lets say 1234 already exists. Cesium has allotted the same entity id to all the polygons of the geojson. Is there a way to alter this and treat each polygon as a separate entity

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

var promise = Cesium.GeoJsonDataSource.load(’…/…/assets/geojsons/try1.geojson’);

promise.then(function(dataSource) {


    //Get the array of entities

    var entities = dataSource.entities.values;

    var colorHash = {};

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

        //For each entity, create a random color based on the state name.

        //Some states have multiple entities, so we store the color in a

        //hash so that we use the same color for the entire state.

        var entity = entities[i];

        var name =;


      //  console.log({name});

        var color;

        if (name=='yes') 


            color = Cesium.Color.RED;








        //Set the polygon material to our random color.

        entity.polygon.material =  color;

        //Remove the outlines.

        entity.polygon.outline = false;

        //Extrude the polygon based on the state's population.  Each entity

        //stores the properties for the GeoJSON feature it was created from

        //Since the population is a huge number, we divide by 50.

        //entity.polygon.extrudedHeight = 10.0;



    //Display any errrors encountered while loading.



var pickedEntities = new Cesium.EntityCollection();

// console.log({pickedEntities});

var pickColor = Cesium.Color.YELLOW.withAlpha(0.5);

function makeProperty(entity, color) {

var colorProperty = new Cesium.CallbackProperty(function(time, result) {

if (pickedEntities.contains(entity)) {


return pickColor.clone(result);


return color.clone(result);

}, false);

entity.polygon.material = new Cesium.ColorMaterialProperty(colorProperty);

var abc=entity.polygon.material;



// Move the primitive that the mouse is over to the top.

handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);

handler.setInputAction(function(movement) {

// get an array of all primitives at the mouse position

var pickedObjects = scene.drillPick(movement.endPosition);

if (Cesium.defined(pickedObjects)) {

//Update the collection of picked entities.


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

var entity = pickedObjects[i].id;





}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

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

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

try1.geojson (25.2 KB)

I’m not able to reproduce any error with the GeoJSON file and code you provided. Each polygon here is indeed a separate entity. You can verify this by printing our the entities array’s length to see that there are 41 entities created here.