svvner
svvner

Reputation: 11

How to add json from variable to Cesium viewer?

i want to load an Json from a variable straight to the Cesium viewer, but the API only supports Json loading from file.

Normaly you would add the datasource to Cesium.GeoJsonDataSource.load, so I tried to add the variable with the raw jsondata to the function. The problem is that Cesium expects a file to load.

var Buildingspromise = Cesium.GeoJsonDataSource.load(BuildingJson);
var Buildings;

I would like to load the raw json data into the Cesium viewer

Upvotes: 1

Views: 1190

Answers (1)

emackey
emackey

Reputation: 12418

You need to parse the JSON first, like this:

var Buildingspromise = Cesium.GeoJsonDataSource.load(JSON.parse(BuildingJson));

Upvotes: 1

Related Questions