html>
创建实体@import url(../Build/Cesium/Widgets/widgets.css);
html, body, #cesiumContainer {
width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden;
}
.cesium-viewer .cesium-widget-credits{ display:none }
var myurl = "http://mt1.google.cn/vt/lyrs=s&hl=zh-CN&x={x}&y={y}&z={z}&s=Gali";
var mapprovider = new Cesium.UrlTemplateImageryProvider({url:myurl});
var myviewer = new Cesium.Viewer("cesiumContainer",{
baseLayerPicker:false,
imageryProvider: mapprovider,
navigationHelpButton:false,
infoBox:true, //可显示description
});
//1、box盒子,dimensions为尺寸(长宽高),outline为边界(默认false不显示)
var redBox = myviewer.entities.add({
show:false,
id:"0204",
name:"盒子",
description:"一个长条盒子......................",
position:Cesium.Cartesian3.fromDegrees(113,31,10000),
//orientation:Cesium.Cartesian3.fromDegrees(113,31),
box:{
dimensions: new Cesium.Cartesian3(400,300,100000),
material:Cesium.Color.RED,
outline:true,
outlineColor:Cesium.Color.BLUE,
//shadows:true
}
});
//2、旋转的圆形或者椭圆
var xza = new Cesium.EllipseGraphics({
semiMinorAxis:100000,
semiMajorAxis:300000,
height:100000,
extrudedHeight:10000,//拉升,拔高,单位米
rotation:Cesium.Math.toRadians(30),//一种数字属性,指定从北逆时针方向椭圆的旋转。
material:Cesium.Color.BLUE.withAlpha(0.5),
outline:true
})
var greencircle = myviewer.entities.add({
show:false,
name:"一个圆",
position:Cesium.Cartesian3.fromDegrees(113,31,10000),
ellipse:xza
})
//3、走廊形状
var redCorr =myviewer.entities.add({
name:"走廊形状",
corridor:{
positions:Cesium.Cartesian3.fromDegreesArray([113,31,114,36,115,33]),
width:1000,
extrudedHeight:1000,//实体的拉升高度
height:0,//实体的海拔高度
material:Cesium.Color.RED.withAlpha(0.5),
outline:true,
outlineColor:Cesium.Color.BLACK
//granularity:Cesium.Math.RADIANS_PER_DEGREE(30)
}
});
//4、polygon
var myPolygon1 = new Cesium.PolygonGraphics({
extrudedHeight:10000,
//height:1000,
closeTop:false,
closeButton:false,
//fromDegreesArrayHeights(113,31,高程),则直接显示高程
hierarchy : Cesium.Cartesian3.fromDegreesArray([113, 31.0,
113.0, 32.0,
114.0, 33.0]),
material : Cesium.Color.RED
});
var polygonshow = myviewer.entities.add({
name:"polygon01",
polygon:myPolygon1
})