Viewing a point geojson layer as markers in cesium

I have a point geojson layer and i would like to add and view it using cesium. I tried with the below code

var dataSource1 = new Cesium.GeoJsonDataSource();
var roads = dataSource1.load('Apps/SampleData/layout&area.geojson');
roads.then(function(dataSource1) {
    viewer.dataSources.add(dataSource1);
    viewer.zoomTo(dataSource1);

    //Get the array of entities
    var entities1 = dataSource1.entities.values;

    var colorHash = {};
    for (var i = 0; i < entities1.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 = entities1[i];
        var name = entity.Text;
        var color = colorHash[name];
        if (!color) {
            color = Cesium.Color.BLACK;
            colorHash[name] = color;
        }
        //Set the polygon material to our random color.
        entity.point.material = color;
        //Remove the outlines.
        entity.point.outline = false;

    }
}).otherwise(function(error){
    //Display any errrors encountered while loading.
    window.alert(error);
});

As a result, i get all the points viewed as markers. How should i make changes to view it as a point?

Hello,

The points appear as billboards by default. You can change them to points with the following code:

var entities = dataSource.entities.values;

for (var i = 0; i < entities.length; i++) {
    var entity = entities[i];
    entity.billboard = undefined;
    entity.point = new Cesium.PointGraphics({
        color: Cesium.Color.fromRandom(),
        pixelSize: 10
    });
}

``

Best,

Hannah

1 Like

Thanks Hannah. Worked like a charm.