Recently studied a few days cesium.js, some entry-level harvest, readily recorded, convenient to consult later!
Cesium supports Topojson,geojson and normal JSON formats, and the following shows examples of three different formats
first, Topojson
<Body> <DivID= "cesiumcontainer"></Div> <Script> //Load Topojson varViewer= NewCesium.viewer ('Cesiumcontainer'); varPromise=Viewer.dataSources.add (Cesium.GeoJsonDataSource.load ('.. /.. /apps/china.topojson', {stroke:Cesium.Color.BLACK, fill:Cesium.Color.RED, strokewidth:3, Markersymbol:'?' })); Viewer.flyto (promise); </Script></Body>
second, GEOjson
<Body> <DivID= "cesiumcontainer"></Div> <Script> varViewer= NewCesium.viewer ('Cesiumcontainer'); //Seed the random number generator for repeatable results.Cesium.Math.setRandomNumberSeed (0); varPromise=Cesium.GeoJsonDataSource.load ('.. /.. /apps/testone.json'); Promise.then (function(dataSource) {viewer.dataSources.add (dataSource); varentities=dataSource.entities.values; varColorhash= {}; for (varI= 0; I<entities.length; i++) { varEntity=entities[i]; varname=entity.name; varColor=colorhash[name]; if (!Color) {color=Cesium.Color.fromRandom ({alpha:1.0 }); colorhash[name]=color; } entity.polygon.material=color; Entity.polygon.outline= false; Entity.polygon.extrudedHeight=5000.0; } }); Viewer.flyto (promise); </Script></Body>
third, Ordinary JSON
<Body> <DivID= "cesiumcontainer"></Div> <Script> varViewer= NewCesium.viewer ('Cesiumcontainer'); Cesium.Math.setRandomNumberSeed (0); Cesium.loadjson ('/.. /apps/points.json'). Then (function(jsondata) { for (varI=0; I<=JsonData.features.length-Ten; I++) { varifeature=jsondata.features[i]; for (vark= 0; k<ifeature.geometry.paths[0].length-Ten; k++) { if(ifeature.geometry.paths[0][k].length==2) {viewer.entities.add ({position:Cesium.Cartesian3.fromDegrees (ifeature.geom etry.paths[0][k][0],ifeature.geometry.paths[0][k][1]), point: {pixelsize:Ten, color:Cesium.Color.YELLOW}}); }}}). otherwise (function(error) {}); </Script></Body>
Normal JSON to Geojson reference http://blog.csdn.net/liyan_gis/article/details/50540842
Initial knowledge cesium----loading different JSON format examples