代码示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript" src="http://localhost:8888/Cesium/Apps/Sandcastle/Sandcastle-header.js"></script>
<script type="text/javascript" src="http://localhost:8888/Cesium/Build/CesiumUnminified/Cesium.js"></script>
</head>
<body>
<style>
@import url(http://localhost:8888/Cesium/Apps/Sandcastle/templates/bucket.css);
</style>
<div id="cesiumContainer" class="fullSize"></div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<div id="toolbar"></div>
</body>
<script>
window.onload=function () {
if (typeof Cesium !== 'undefined') {
startup(Cesium);
} else if (typeof require === 'function') {
require(['Cesium'], startup);
}
}
function startup(Cesium) {
'use strict';
var terrainProvider= new Cesium.CesiumTerrainProvider({
url : 'http://localhost:8888/ASTGTM' //使用的是Tomcat服务器 ,项目也需要放在Tomcat下,防止跨域的问题
});
var viewer = new Cesium.Viewer('cesiumContainer', {
terrainProvider: terrainProvider
});
viewer.camera.setView( {
destination : Cesium.Cartesian3.fromDegrees( 112.484, 34.591, 30000 )
} );
}
</script>
</html>
预览效果:
地形数据是把 .tif 文件切割成 .terrain 文件
网友评论