Monthly Archives: October 2015

Cesiumjs – How to Load KML without Viewer Widget ?

phpmind-cesiumjs-Load-KML-without-Viewer-Widget

var cesiumWidget = new Cesium.CesiumWidget('cesiumContainer');

var dataSources = new Cesium.DataSourceCollection();

var dataSourceDisplay = new Cesium.DataSourceDisplay({
    scene: cesiumWidget.scene,
    dataSourceCollection: dataSources
});

//dataSourceDisplay.update needs to be called once a frame after all other updates have been made, in this case we call it in the preRender event.
cesiumWidget.scene.preRender.addEventListener(function(scene, time){
    dataSourceDisplay.update(time);
});

//Now that everything is configured, we can load KML and add to list of data sources.
dataSources.add(Cesium.KmlDataSource.load('../../SampleData/kml/facilities/facilities.kml'));
Share

Cesiumjs – How to Animating polyline color

phpmind-cesiumjs-animate-polyline-color1

phpmind-cesiumjs-animate-polyline-color

var viewer = new Cesium.Viewer('cesiumContainer');
viewer.entities.add({
    polyline : {
        positions : Cesium.Cartesian3.fromDegreesArrayHeights([-75, 39, 250000,
                                                               -125, 39, 250000]),
        width : 5,
        material : new Cesium.PolylineOutlineMaterialProperty({
            color : new Cesium.CallbackProperty(

                function (time, result){
                    return Cesium.Color.fromAlpha(
                            Cesium.Color.RED,
                            (new Date(time).getTime() % 1000) / 1000,
                            result);

             }, false),
            outlineWidth : 2,
            outlineColor : Cesium.Color.BLACK
        })
    }
});

viewer.zoomTo(viewer.entities);
Share

Cesiumjs – How to Animating Multipolygons

phpmind-cesiumjs-animate-poygone2

phpmind-cesiumjs-animate-poygone

var viewer = new Cesium.Viewer('cesiumContainer');

var greenCylinder = viewer.entities.add({
    name : 'Green cylinder with black outline',
    position: Cesium.Cartesian3.fromDegrees(-100.0, 40.0, 200000.0),
    cylinder : {
        length : 400000.0,
        topRadius : 200000.0,
        bottomRadius : 200000.0,
        material : Cesium.Color.GREEN.withAlpha(0.5),
        outline : true,
        outlineColor : Cesium.Color.DARK_GREEN
    }
});

var redCone = viewer.entities.add({
    name : 'Red cone',
    position: Cesium.Cartesian3.fromDegrees(-105.0, 40.0, 200000.0),
    cylinder : {
        length : 400000.0,
        topRadius : 0.0,
        bottomRadius : 200000.0,
        material : new Cesium.ColorMaterialProperty(
            new Cesium.CallbackProperty(
                function (time, result){
                    return Cesium.Color.fromAlpha(
                        Cesium.Color.RED,
                        (new Date(time).getTime() % 1000) / 1000,
                        result);
                }, false))
    }
});

viewer.zoomTo(viewer.entities);
Share