GeoJsonDataSource - display data source and display attributes

Hi All,

I am using the Cesium.GeoJsonDataSource to load geojson file. I noticed that on the document (https://cesiumjs.org/Cesium/Build/Documentation/GeoJsonDataSource.html) there is a method called "show" to control whether to show the data. Could you please show me an example of how to use it?

There are some polylines in the geojson data. How to show the polyline's properties when I click on it?

The code I wrote is like this:

const shapeLayer = Cesium.GeoJsonDataSource.load('url_to_XXX.geojson', {
    stroke: Cesium.Color.HOTPINK,
    strokeWidth: 3,
    // do I add "show" here?
    // show: false
});
// do I add "show" here?
// shapeLayer.show = false;
this.viewer.dataSources.add(shapeLayer);

Thanks in advance!

Finally I found a way to get the properties by using entities in the promise. Now the only problem is to use the "show" method.

Sorry you had trouble figuring this out. This is a good reference example on loading GeoJSONs and applying custom styling/changing properties of the loaded entities:

The only options available on load are listed here:

https://cesiumjs.org/Cesium/Build/Documentation/GeoJsonDataSource.html#.load

If you’re asking about showing/hiding everything in the datasource, you can do that by waiting on the promise to resolve, and then setting that after. So in the example in your first post, it would be:

const shapeLayerPromise = Cesium.GeoJsonDataSource.load(‘url_to_XXX.geojson’, {
stroke: Cesium.Color.HOTPINK,
strokeWidth: 3
});

this.viewer.dataSources.add(shapeLayerPromise)
.then(function(shapeLayer){
shapeLayer.show = false;
});

``