7

I have a geojson with height informations in it. I tried adding the geojson to the scene using

var viewer = new Cesium.Viewer('cesiumContainer', {
sceneMode : Cesium.SceneMode.SCENE3D,
timeline : false,
animation : false
});

var dataSource = Cesium.GeoJsonDataSource.load('../../SampleData/Buildings_3D_Elevation.geojson');
viewer.dataSources.add(dataSource);
viewer.zoomTo(dataSource);

I can view the data as below. What should be done to use the height information and view as 3D? enter image description here

4

You need to extrude polygons:

entity.polygon.extrudedHeight = entity.properties.your_height_field

You may need to loop over records, for example:

    var p = dataSource.entities.values;   
    for (var i = 0; i < p.length; i++) {
         p.polygon.extrudedHeight = entity.properties.your_height_field
2

The accepted answer is wrong. Here is the correct example:

<div id="cesiumContainer"></div>
<script>
    var viewer = new Cesium.Viewer('cesiumContainer');
    var dataSource = Cesium.GeoJsonDataSource.load('buildings.geojson').then(
        function(dataSource) {
            var p = dataSource.entities.values;
            for (var i = 0; i < p.length; i++) {
                p[i].polygon.extrudedHeight = 15; // or height property
            }
            viewer.dataSources.add(dataSource);
            viewer.zoomTo(dataSource);
        }
    );
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.