1、点
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>增加点 cesium (自定义图标)</title>
<link rel="stylesheet" href="/Cesium-1.72/Build/Cesium/Widgets/widgets.css">
<script src="/Cesium-1.72/Build/Cesium/Cesium.js"></script>
</head>
<body>
<div style="width:1500px;height:700px;">
<div id="cesiumContainer" style="width:100%;height:100%;"></div>
</div>
</body>
</html>
<script>
var viewer = new Cesium.Viewer('cesiumContainer', {
geocoder:false, //一种地理位置搜索工具,用于显示相机访问的地理位置。默认使用微软的Bing地图。
homeButton:true, //首页位置,点击之后将视图跳转到默认视角。
sceneModePicker:true, //切换2D、3D 和 Columbus View (CV) 模式。
baseLayerPicker:false, //选择三维数字地球的底图(imagery and terrain)。
navigationHelpButton:true, //帮助提示,如何操作数字地球。
animation:false,//控制视窗动画的播放速度。
creditsDisplay:false, //展示商标版权和数据源。
timeline:false, //展示当前时间和允许用户在进度条上拖动到任何一个指定的时间。
fullscreenButton:true, //视察全屏按钮
imageryProvider:new Cesium.UrlTemplateImageryProvider({
url : Cesium.buildModuleUrl('Assets/Textures/NaturalEarthII') + '/{z}/{x}/{reverseY}.jpg',
credit : '© Analytical Graphics, Inc.',
tilingScheme : new Cesium.GeographicTilingScheme(),
maximumLevel : 5
}),
});
viewer.scene.globe.enableLighting = true;//启用以太阳为光源的地球
//增加点
//静态方法,直接调用,返回->new Cesium.Cartesian3 ( x , y , z )
//Cesium.Cartesian3.fromDegrees (longitude, latitude, height , ellipsoid , result )
//前三个参数分别是经纬高
viewer.entities.add({
position:Cesium.Cartesian3.fromDegrees( 75.59, 40, 0),
billboard:{
image:'/Cesium-1.72/Apps/Sandcastle/images/facility.gif'
},
id:'MyCesium',
name:'Cesium-Station',
label : {
text : 'Citizens Bank Park',
font : '14pt monospace',
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
outlineWidth : 2,
verticalOrigin : Cesium.VerticalOrigin.BOTTOM,
pixelOffset : new Cesium.Cartesian2(0, -10),
fillColor:Cesium.Color.GREEN
},
description:'自定义增加的点'
})
</script>
2、线
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>增加线 cesium </title>
<link rel="stylesheet" href="/Cesium-1.72/Build/Cesium/Widgets/widgets.css">
<script src="/Cesium-1.72/Build/Cesium/Cesium.js"></script>
</head>
<body>
<div style="width:1500px;height:700px;">
<div id="cesiumContainer" style="width:100%;height:100%;"></div>
</div>
</body>
</html>
<script>
var viewer = new Cesium.Viewer('cesiumContainer', {
geocoder:false, //一种地理位置搜索工具,用于显示相机访问的地理位置。默认使用微软的Bing地图。
homeButton:true, //首页位置,点击之后将视图跳转到默认视角。
sceneModePicker:true, //切换2D、3D 和 Columbus View (CV) 模式。
baseLayerPicker:false, //选择三维数字地球的底图(imagery and terrain)。
navigationHelpButton:true, //帮助提示,如何操作数字地球。
animation:false,//控制视窗动画的播放速度。
creditsDisplay:false, //展示商标版权和数据源。
timeline:false, //展示当前时间和允许用户在进度条上拖动到任何一个指定的时间。
fullscreenButton:true, //视察全屏按钮
imageryProvider:new Cesium.UrlTemplateImageryProvider({
url : Cesium.buildModuleUrl('Assets/Textures/NaturalEarthII') + '/{z}/{x}/{reverseY}.jpg',
credit : '© Analytical Graphics, Inc.',
tilingScheme : new Cesium.GeographicTilingScheme(),
maximumLevel : 5
}),
});
viewer.scene.globe.enableLighting = true;//启用以太阳为光源的地球
//添加线
for(var p = 0 ; p <2;p++){
var data = new Array();
for(var i = 0 ; i< 360;i++){
data.push(i);
data.push(0);
data.push(p*1000000);
}
viewer.entities.add({
polyline : {
positions : Cesium.Cartesian3.fromDegreesArrayHeights(data),
width : 5,
material : new Cesium.PolylineOutlineMaterialProperty({
color : Cesium.Color.ORANGE,
outlineWidth : 2,
outlineColor : Cesium.Color.BLACK
})
}
})
}
</script>
3、立方体
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>增加box cesium </title>
<link rel="stylesheet" href="/Cesium-1.72/Build/Cesium/Widgets/widgets.css">
<script src="/Cesium-1.72/Build/Cesium/Cesium.js"></script>
</head>
<body>
<div style="width:1500px;height:700px;">
<div id="cesiumContainer" style="width:100%;height:100%;"></div>
</div>
</body>
</html>
<script>
var viewer = new Cesium.Viewer('cesiumContainer', {
geocoder:false, //一种地理位置搜索工具,用于显示相机访问的地理位置。默认使用微软的Bing地图。
homeButton:true, //首页位置,点击之后将视图跳转到默认视角。
sceneModePicker:true, //切换2D、3D 和 Columbus View (CV) 模式。
baseLayerPicker:false, //选择三维数字地球的底图(imagery and terrain)。
navigationHelpButton:true, //帮助提示,如何操作数字地球。
animation:false,//控制视窗动画的播放速度。
creditsDisplay:false, //展示商标版权和数据源。
timeline:false, //展示当前时间和允许用户在进度条上拖动到任何一个指定的时间。
fullscreenButton:true, //视察全屏按钮
imageryProvider:new Cesium.UrlTemplateImageryProvider({
url : Cesium.buildModuleUrl('Assets/Textures/NaturalEarthII') + '/{z}/{x}/{reverseY}.jpg',
credit : '© Analytical Graphics, Inc.',
tilingScheme : new Cesium.GeographicTilingScheme(),
maximumLevel : 5
}),
});
viewer.scene.globe.enableLighting = true;//启用以太阳为光源的地球
//添加3Dbox
viewer.entities.add({
name:'red 3D BOX',
position: Cesium.Cartesian3.fromDegrees(-107.0,42.0,300000.0),
box:{
dimensions:new Cesium.Cartesian3(400000.0,300000.0,500000.0),
material:Cesium.Color.RED.withAlpha(0.5),
outline:true,
outlineColor:Cesium.Color.BLACK
}
})
viewer.zoomTo(viewer.entities);
</script>
4、相机定位
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>cesium 相机控制</title>
<link rel="stylesheet" href="/Cesium-1.72/Build/Cesium/Widgets/widgets.css">
<script src="/Cesium-1.72/Build/Cesium/Cesium.js"></script>
<script src="/Cesium-1.72/Apps/Sandcastle/Sandcastle-header.js"></script>
<link rel="stylesheet" href="/Cesium-1.72/Apps/Sandcastle/templates/bucket.css">
</head>
<body style="background-color: #fff;">
<div style="width:1500px;height:700px;">
<div id="toolbar" style="z-index: 999;"></div>
<div id="cesiumContainer" style="width:100%;height:100%;"></div>
</div>
</body>
</html>
<script>
var viewer = new Cesium.Viewer('cesiumContainer', {
imageryProvider:new Cesium.UrlTemplateImageryProvider({
url:'http://localhost:8099/basemap_0-10/{z}/{y}/{x}.png', //本机地图服务
fileExtension : "png",
}),
geocoder:false, //一种地理位置搜索工具,用于显示相机访问的地理位置。默认使用微软的Bing地图。
homeButton:true, //首页位置,点击之后将视图跳转到默认视角。
sceneModePicker:true, //切换2D、3D 和 Columbus View (CV) 模式。
baseLayerPicker:false, //选择三维数字地球的底图(imagery and terrain)。
navigationHelpButton:true, //帮助提示,如何操作数字地球。
animation:false,//控制视窗动画的播放速度。
creditsDisplay:false, //展示商标版权和数据源。
timeline:false, //展示当前时间和允许用户在进度条上拖动到任何一个指定的时间。
fullscreenButton:true, //视察全屏按钮
});
viewer.scene.globe.enableLighting = true;//启用以太阳为光源的地球
Sandcastle.addDefaultToolbarButton('相机定位', function() {
//相机定位
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(-117.16, 32.71, 150000.0),
});
});
function flyInACity(){
//相机定位
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(116.2, 39.4, 550000.0),
});
}
Sandcastle.addToolbarMenu([
{
text: "Camera Options",
},
{
text: "Fly in a Beijing",
onselect: function () {
flyInACity();
Sandcastle.highlight(flyInACity);
},
}
]);
</script>
5、平面矩形填充
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>平面矩形填充</title>
<link rel="stylesheet" href="/Cesium-1.72/Build/Cesium/Widgets/widgets.css">
<script src="/Cesium-1.72/Build/Cesium/Cesium.js"></script>
</head>
<body>
<div style="width:1500px;height:700px;">
<div id="cesiumContainer" style="width:100%;height:100%;"></div>
</div>
</body>
</html>
<script>
var viewer = new Cesium.Viewer('cesiumContainer', {
imageryProvider:new Cesium.UrlTemplateImageryProvider({
url:'http://localhost:8099/basemap_0-10/{z}/{y}/{x}.png', //本机地图服务
fileExtension : "png",
}),
geocoder:false, //一种地理位置搜索工具,用于显示相机访问的地理位置。默认使用微软的Bing地图。
homeButton:true, //首页位置,点击之后将视图跳转到默认视角。
sceneModePicker:true, //切换2D、3D 和 Columbus View (CV) 模式。
baseLayerPicker:false, //选择三维数字地球的底图(imagery and terrain)。
navigationHelpButton:true, //帮助提示,如何操作数字地球。
animation:false,//控制视窗动画的播放速度。
creditsDisplay:false, //展示商标版权和数据源。
timeline:false, //展示当前时间和允许用户在进度条上拖动到任何一个指定的时间。
fullscreenButton:true, //视察全屏按钮
});
viewer.scene.globe.enableLighting = true;//启用以太阳为光源的地球
//添加矩形
viewer.entities.add({
name : 'Yellow plane outline',
position: Cesium.Cartesian3.fromDegrees(-100.0, 40.0, 0),
plane : {
plane : new Cesium.Plane(Cesium.Cartesian3.UNIT_Z, 0.0),//平面的法线
dimensions : new Cesium.Cartesian2(400000.0, 300000.0),
fill : true,
//material:Cesium.Color.RED.withAlpha(0.5),透明度
material:new Cesium.GridMaterialProperty({
color : Cesium.Color.YELLOW,
cellAlpha : 0.2,
lineCount : new Cesium.Cartesian2(8, 8),
lineThickness : new Cesium.Cartesian2(2.0, 2.0)
}),
outline : true,
outlineColor : Cesium.Color.RED
}
})
var stripeMaterial = new Cesium.StripeMaterialProperty({
evenColor: Cesium.Color.WHITE.withAlpha(0.5),
oddColor: Cesium.Color.BLUE.withAlpha(0.5),
repeat: 5.0,
});
viewer.entities.add({
polygon: {
hierarchy: new Cesium.PolygonHierarchy(
Cesium.Cartesian3.fromDegreesArray([
-107.0,
27.0,
-107.0,
22.0,
-102.0,
23.0,
-97.0,
21.0,
-97.0,
25.0,
-99.0,
26.0,
])
),
outline: true,
outlineColor: Cesium.Color.WHITE,
outlineWidth: 4,
material: stripeMaterial,
},
});
</script>
6、模拟飞机动态运行
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>增加线 cesium </title>
<link rel="stylesheet" href="/Cesium-1.72/Build/Cesium/Widgets/widgets.css">
<script src="/Cesium-1.72/Build/Cesium/Cesium.js"></script>
</head>
<body>
<div style="width:1500px;height:700px;">
<div id="cesiumContainer" style="width:100%;height:100%;"></div>
</div>
</body>
</html>
<script>
var viewer = new Cesium.Viewer('cesiumContainer', {
imageryProvider:new Cesium.UrlTemplateImageryProvider({
url:'http://localhost:8099/basemap_0-10/{z}/{y}/{x}.png', //本机地图服务
fileExtension : "png",
}),
geocoder:false, //一种地理位置搜索工具,用于显示相机访问的地理位置。默认使用微软的Bing地图。
homeButton:true, //首页位置,点击之后将视图跳转到默认视角。
sceneModePicker:true, //切换2D、3D 和 Columbus View (CV) 模式。
baseLayerPicker:false, //选择三维数字地球的底图(imagery and terrain)。
navigationHelpButton:true, //帮助提示,如何操作数字地球。
animation:false,//控制视窗动画的播放速度。
creditsDisplay:false, //展示商标版权和数据源。
timeline:false, //展示当前时间和允许用户在进度条上拖动到任何一个指定的时间。
fullscreenButton:true, //视察全屏按钮
shouldAnimate: true,
clock:new Cesium.Clock({
currentTime:Cesium.JulianDate.fromDate(new Date())
})
});
viewer.scene.globe.enableLighting = true;//启用以太阳为光源的地球
var arr = new Array();
viewer.entities.add({
id:'star1_t',
name : 'Orange line with black outline at height and following the surface',
description:'Orange Line',//描述
polyline : {
positions : Cesium.Cartesian3.fromDegreesArrayHeights(arr),
width : 5,
material : new Cesium.PolylineOutlineMaterialProperty({
color : new Cesium.Color ( 1 , 1 , 0 , 0.5 ),
outlineWidth : 2,
outlineColor : Cesium.Color.BLACK
})
}
})
//添加矩形
viewer.entities.add({
id:'star1_s1_p',
name: "Red polygon on surface",
polygon: {
hierarchy: Cesium.Cartesian3.fromDegreesArray([
-115.0,
37.0,
-115.0,
32.0,
-107.0,
33.0,
-102.0,
31.0,
]),
material: new Cesium.GridMaterialProperty({
color : Cesium.Color.YELLOW,
cellAlpha : 0.2,
})
},
});
//添加线
viewer.entities.add({
name: "Purple straight arrow at height",
polyline: {
positions: Cesium.Cartesian3.fromDegreesArrayHeights([
-75,
43,
500000,
-75,
43,
0,
]),
width: 10,
arcType: Cesium.ArcType.NONE,
material: new Cesium.PolylineArrowMaterialProperty(
Cesium.Color.PURPLE
),
},
});
//添加卫星模型
ent = new Cesium.Entity({
id:'star1',
name:'star',
description:'卫星',
position:Cesium.Cartesian3.fromDegrees( 10,0,4000000),
model:{
uri: '/Cesium-1.72/Apps/SampleData/models/CesiumAir/Cesium_Air.glb',
minimumPixelSize : 128,
maximumScale : 40000
}
});
viewer.entities.add(ent);
//添加三角型
viewer.entities.add({
id:'lines',
name: "Cyan vertical polygon with per-position heights and outline",
polygon: {
hierarchy: Cesium.Cartesian3.fromDegreesArrayHeights([
-90.0,
41.0,
0.0,
-85.0,
41.0,
500000.0,
-80.0,
41.0,
0.0,
]),
perPositionHeight: true,
material: Cesium.Color.CYAN.withAlpha(0.5),
outline: true,
outlineColor: Cesium.Color.BLACK,
},
});
var x =0;
setInterval(function() {
var data = new Array();
data.push(x+1);
data.push(10);
data.push(x-5);
data.push(10);
data.push(x-5);
data.push(-10);
data.push(x+1);
data.push(-10);
//更改时间
viewer.clock=new Cesium.Clock({
currentTime:Cesium.JulianDate.fromDate(new Date())
})
//图像更改1
var position = Cesium.Cartesian3.fromDegrees(x,0,4000000)
viewer.entities.getById('star1').position=position;
arr.push(x);
arr.push(0);
arr.push(4000000);
viewer.entities.getById('star1_t').polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights(arr);
viewer.entities.getById('star1_s1_p').polygon.hierarchy=Cesium.Cartesian3.fromDegreesArray(data);
x += 10;
},1000);
/* var x = 0;
var ent = null;
setInterval(function() {
if(ent != null){
viewer.entities.remove(ent);
}
//添加卫星模型
ent = new Cesium.Entity({
name:'star',
description:'卫星',
position:Cesium.Cartesian3.fromDegrees( x,0,4000000),
model:{
uri: '/Cesium-1.72/Apps/SampleData/models/CesiumAir/Cesium_Air.glb',
minimumPixelSize : 128,
maximumScale : 40000
}
});
viewer.entities.add(ent);
x+=1;
if(x == 360){
x = 0 ;
}
},1000);*/
</script>
7、官方czml卫星运行案例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>快速开始 cesium</title>
<link rel="stylesheet" href="/Cesium-1.72/Build/Cesium/Widgets/widgets.css">
<script src="/Cesium-1.72/Build/Cesium/Cesium.js"></script>
</head>
<body>
<div style="width:1500px;height:700px;">
<div id="cesiumContainer" style="width:100%;height:100%;"></div>
</div>
</body>
</html>
<script>
var viewer = new Cesium.Viewer('cesiumContainer', {
imageryProvider:new Cesium.UrlTemplateImageryProvider({
url : Cesium.buildModuleUrl('Assets/Textures/NaturalEarthII') + '/{z}/{x}/{reverseY}.jpg',
credit : '© Analytical Graphics, Inc.',
tilingScheme : new Cesium.GeographicTilingScheme(),
maximumLevel : 5
}),
geocoder:false, //一种地理位置搜索工具,用于显示相机访问的地理位置。默认使用微软的Bing地图。
homeButton:true, //首页位置,点击之后将视图跳转到默认视角。
sceneModePicker:true, //切换2D、3D 和 Columbus View (CV) 模式。
baseLayerPicker:false, //选择三维数字地球的底图(imagery and terrain)。
navigationHelpButton:true, //帮助提示,如何操作数字地球。
animation:false,//控制视窗动画的播放速度。
creditsDisplay:false, //展示商标版权和数据源。
timeline:false, //展示当前时间和允许用户在进度条上拖动到任何一个指定的时间。
fullscreenButton:true, //视察全屏按钮
shouldAnimate: true
});
viewer.scene.globe.enableLighting = true;//启用以太阳为光源的地球
viewer.dataSources.add(
Cesium.CzmlDataSource.load("/Cesium-1.72/Apps/SampleData/simple.czml")
)
</script>
8、模拟卫星扫描
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>卫星扫描</title>
<link rel="stylesheet" href="/Cesium-1.72/Build/Cesium/Widgets/widgets.css">
<script src="/Cesium-1.72/Build/Cesium/Cesium.js"></script>
</head>
<body>
<div style="width:1500px;height:700px;">
<div id="cesiumContainer" style="width:100%;height:100%;"></div>
</div>
</body>
</html>
<script>
var viewer = new Cesium.Viewer('cesiumContainer', {
imageryProvider:new Cesium.UrlTemplateImageryProvider({
url:'http://localhost:8099/basemap_0-10/{z}/{y}/{x}.png', //本机地图服务
fileExtension : "png",
}),
});
viewer.scene.globe.enableLighting = true;//启用以太阳为光源的地球
var data = [];
data = [{
longitude: 116.405419,
dimension: 39.918034,
height: 700000,
time: 0
}, {
longitude: 115.2821,
dimension: 39.918145,
height: 700000,
time: 40
}, {
longitude: 114.497402,
dimension: 39.344641,
height: 700000,
time: 100
}, {
longitude: 107.942392,
dimension: 35.559967,
height: 700000,
time: 280
}, {
longitude: 106.549265,
dimension: 34.559967,
height: 700000,
time: 360
}, {
longitude: 95.2821,
dimension: 32.918145,
height: 700000,
time: 400
}, {
longitude: 94.497402,
dimension: 30.344641,
height: 700000,
time: 450
}, {
longitude: 87.942392,
dimension: 25.559967,
height: 700000,
time: 550
}, {
longitude: 66.549265,
dimension: 24.559967,
height: 700000,
time: 600
}];
// 起始时间
var start = Cesium.JulianDate.fromDate(new Date(2020, 7, 11));
// 结束时间
var stop = Cesium.JulianDate.addSeconds(start, 600, new Cesium.JulianDate());
// 设置始时钟始时间
viewer.clock.startTime = start.clone();
// 设置时钟当前时间
viewer.clock.currentTime = start.clone();
// 设置始终停止时间
viewer.clock.stopTime = stop.clone();
// 时间速率,数字越大时间过的越快
viewer.clock.multiplier = 10;
// 时间轴
viewer.timeline.zoomTo(start, stop);
// 循环执行
viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP;
var property = computeFlight(data);
// 添加模型
var planeModel = viewer.entities.add({
// 和时间轴关联
availability: new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({
start: start,
stop: stop
})]),
position: property,
// 根据所提供的速度计算点
orientation: new Cesium.VelocityOrientationProperty(property),
// 模型数据
model: {
uri: '/Cesium-1.72/Apps/SampleData/models/CesiumAir/Cesium_Air.glb',
minimumPixelSize: 128
},
path: {
resolution: 1,
material: new Cesium.PolylineGlowMaterialProperty({
glowPower: .1,
color: Cesium.Color.YELLOW
}),
width: 10
}
});
planeModel.position.setInterpolationOptions({ //设定位置的插值算法
interpolationDegree: 5,
interpolationAlgorithm: Cesium.LagrangePolynomialApproximation
});
var property2 = computeFlight2(data);
var entity_ty = viewer.entities.add({
availability: new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({
start: start,
stop: stop
})]),
position: property2,
orientation: new Cesium.VelocityOrientationProperty(property2),
cylinder: {
HeightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
length: 700000,
topRadius: 0,
bottomRadius: 700000 / 4,
material: Cesium.Color.RED.withAlpha(.4),
outline: !0,
numberOfVerticalLines: 0,
outlineColor: Cesium.Color.RED.withAlpha(.8)
},
});
entity_ty.position.setInterpolationOptions({
interpolationDegree: 5,
interpolationAlgorithm: Cesium.LagrangePolynomialApproximation
});
function computeFlight(source) {
var property = new Cesium.SampledPositionProperty();
for (var i = 0; i < source.length; i++) {
var time = Cesium.JulianDate.addSeconds(start, source[i].time, new Cesium.JulianDate);
var position = Cesium.Cartesian3.fromDegrees(source[i].longitude, source[i].dimension, source[i].height);
// 添加位置,和时间对应
property.addSample(time, position);
}
return property;
}
function computeFlight2(source) {
var property = new Cesium.SampledPositionProperty();
for (var i = 0; i < source.length; i++) {
var time = Cesium.JulianDate.addSeconds(start, source[i].time, new Cesium.JulianDate);
var position = Cesium.Cartesian3.fromDegrees(source[i].longitude, source[i].dimension, source[i].height / 2);
// 添加位置,和时间对应
property.addSample(time, position);
}
return property;
}
</script>
9、时钟
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>clock 时钟</title>
<link rel="stylesheet" href="/Cesium-1.72/Build/Cesium/Widgets/widgets.css">
<script src="/Cesium-1.72/Build/Cesium/Cesium.js"></script>
<script src="/Cesium-1.72/Apps/Sandcastle/Sandcastle-header.js"></script>
<link rel="stylesheet" href="/Cesium-1.72/Apps/Sandcastle/templates/bucket.css">
</head>
<body style="background-color: #fff;">
<div style="width:1500px;height:700px;">
<div id="toolbar" style="z-index: 999;"></div>
<div id="cesiumContainer" style="width:100%;height:100%;"></div>
</div>
</body>
</html>
<script>
var viewer = new Cesium.Viewer('cesiumContainer', {
imageryProvider:new Cesium.UrlTemplateImageryProvider({
url:'http://localhost:8099/basemap_0-10/{z}/{y}/{x}.png', //本机地图服务
fileExtension : "png",
}),
});
viewer.scene.globe.enableLighting = true;//启用以太阳为光源的地球
// Create a clock that loops on Christmas day 2013 and runs in 4000x real time.
var clock = new Cesium.Clock({
startTime: Cesium.JulianDate.fromIso8601("2013-12-25"),
currentTime: Cesium.JulianDate.fromIso8601("2013-12-25"),
stopTime: Cesium.JulianDate.fromIso8601("2013-12-26"),
clockRange: Cesium.ClockRange.LOOP_STOP, // loop when we hit the end time
clockStep: Cesium.ClockStep.SYSTEM_CLOCK_MULTIPLIER,
multiplier: 4000, // how much time to advance each tick
shouldAnimate: true, // Animation on by default
});
viewer.clockViewModel = clock;
viewer.scene.globe.enableLighting = true;
Sandcastle.addToolbarButton("Reset Current Time", function () {
var resetTime = viewer.clockViewModel.startTime;
viewer.clockViewModel.currentTime = resetTime;
viewer.timeline.updateFromClock();
});
Sandcastle.addToolbarButton("Slow Down Clock", function () {
viewer.clockViewModel.multiplier /= 2;
});
Sandcastle.addToolbarButton("Speed Up Clock", function () {
viewer.clockViewModel.multiplier *= 2;
});
</script>
案例代码:https://github.com/zhangxuhui1992/cesium