Load geojson from IONASSET and create entity

Is there some example code to load a geojson multipolygon file from ion asset and put it in an entity so that colours and styles can be modified ( similar to the Texas example in Sandcastle).
The polygons form curved planes above the ground (not terrain)
I have tried it, but it just loads as the default polygons colours.
Cesium.IonResource.fromAssetId(287424)
Thanks,

Here is an example of loading multipolygon GeoJSON (not from Cesium ion, but you can just replace the hard coded GeoJSON data with your asset.

Example.

Thanks,

So is this the correct way to refer to the asset?
const geojson = Cesium.IonResource.fromAssetId(276924);
My test polygons appear in the Cesium ion, but not in the Sandcastle.

@QuartzReservoir that line basically loads the URL from which to load the GeoJSON. To load it from ion and add it to the viewer you need to:

// Load the GeoJSON file from Cesium ion.
  const geoJSONURL = await Cesium.IonResource.fromAssetId(your_asset_id);
  // Create the geometry from the GeoJSON, and clamp it to the ground.
  const geoJSON = await Cesium.GeoJsonDataSource.load(geoJSONURL, { clampToGround: true });
  // Add it to the scene.
  const dataSource = await viewer.dataSources.add(geoJSON);

This code snippet is from this tutorial: Visualize a Proposed Building in a 3D City | cesium.com

Thanks Omar,
My polygons load from ion and now appear on the terrain,
Keith

1 Like