cesium中json、topojson、geojson、stk,影像切片等数据的加载
一、geojson、topojson,json数据的加载
不管是哪种json,都可以通过GeoJsonDataSource去加载;方式是一样的。
例:
var viewer = new Cesium.Viewer('cesiumContainer');
viewer.dataSources.add(Cesium.GeoJsonDataSource.load('../aa/bb.topojson', {
stroke: Cesium.Color.HOTPINK,
fill: Cesium.Color.PINK,
strokeWidth: 3,
markerSymbol: '?'
}));
二、STK数据的加载
例:
viewer.terrainProvider = new Cesium.CesiumTerrainProvider({
url:http://.....()此处为本地或者线上的http链接
requestVertexNormals: true,
requestWaterMask: false,
options1
})
三、影像切片数据的加载
例:
viewer.imageryLayers.addImageryProvider = new Cesium.GoogleMapsImageryProvider(options2);
var imageryProvider2 = new Cesium.KQGIS3DTileFileImageryProvider(options2);
var imageryLayer2 = new Cesium.ImageryLayer(imageryProvider2, { show: true });
viewer.imageryLayers.add(imageryLayer2);
四、cesium位置初始化
cesium位置初始化,就是在你刚加载3d页面的时候,相机所指向的位置(或者其他一些需要初始化的地方。)
话不多说,直接上案例,有不懂的请加下面的学习群,一起讨论。
1 viewer.scene.camera.flyTo({
2 destination: new Cesium.Cartesian3.fromDegrees(118.16029, 30.15988, 29600.209),
3 orientation: {
4 heading: Cesium.Math.toRadians(0),
5 pitch: Cesium.Math.toRadians(-90),
6 roll: Cesium.Math.toRadians(0)
7 },
8 duration: 3.0
9 })
其中的flyto是你飞到某个位置的一个方法。
118.16029, 30.15988, 29600.209这三个数分别是你的经度、纬度还有高程的位置。
heading: Cesium.Math.toRadians(0),
pitch: Cesium.Math.toRadians(-90),
roll: Cesium.Math.toRadians(0) 请看下面的文档解释:
duration: 3.0这句话的意思是,你飞到这个位置所用的时间是3秒。