Cesium快速上手5-地形影像的加载
地形的加载
http://localhost:8080/Apps/Sandcastle/index.html?src=Terrain.html&label=Development
//更改地形数据,这里viewer.terrainProvider其实是个快捷方式,完整的是viewer.scene.globe.terrainProvider
//地形数据只能加一个
viewer.terrainProvider = worldTerrain;
viewer.scene.globe.enableLighting = true
关键点
EllipsoidTerrainProvider
VRTheWorldTerrainProvider
CesiumTerrainProvider/createWorldTerrain
影像的加载
http://localhost:8080/Apps/Sandcastle/index.html?src=Imagery%20Layers.html&label=Development
影像图层是一个数组,可以加载很多个影像
Cesium.ImageryProvider() //图层提供者
viewer.scene.imageryLayers :Cesium.ImageryLayerCollection() //拥有图层提供者,另外还有其他属性:亮度 色调
影像图层的管理(删除图层/提升显示层级/增加图层)。。。
Cesium.ImageryLayerCollection(). addImageryProvider(imageryProvider, index)
影像的某些功能
** 图层的叠加**
http://localhost:8080/Apps/Sandcastle/index.html?src=Imagery%20Layers%20Manipulation.html&label=Development
** 通过键盘 控制点亮区域 **
http://localhost:8080/Apps/Sandcastle/index.html?src=Imagery%20Cutout.html&label=Development
增加一个地图的地图,开启夜间模式;
增加一个图层,根据键盘控制旋转的角度
// Add an Earth at Night layer and a "traveling" cutout
var earthAtNight = layers.addImageryProvider(new Cesium.IonImageryProvider({ assetId: 3812 }));
earthAtNight.cutoutRectangle = Cesium.Rectangle.fromDegrees(-100, 10, -60, 50);
earthAtNight.alpha = 0.9;
。。。
var travelingRectangle = earthAtNight.cutoutRectangle;
。。。
travelingRectangle.east = wrapLongitude(travelingRectangle.east);
travelingRectangle.west = wrapLongitude(travelingRectangle.west);
});
function wrapLongitude(value) {
if (value < -Cesium.Math.PI) {
return value + Cesium.Math.TWO_PI;
}
if (value > Cesium.Math.PI) {
return value - Cesium.Math.TWO_PI;
}
return value;
}
** 只显示地球的某一边界之内的图层 **
http://localhost:8080/Apps/Sandcastle/index.html?src=Cartographic%20Limit%20Rectangle.html&label=Development
// Tropics of Cancer and Capricorn
var coffeeBeltRectangle = Cesium.Rectangle.fromDegrees(-180.0, -23.43687, 180.0, 23.43687);
viewer.scene.globe.cartographicLimitRectangle = coffeeBeltRectangle; //地图限制矩形区域 设置成似咖啡杯的区域
viewer.scene.globe.showSkirts = true;//是否显示地形群
viewer.scene.skyAtmosphere.show = false;//天空的氛围笼罩