CesiumJS
- CesiumJS 是一个开源的 JavaScript 库,它用于在网页中创建和控制 3D 地球仪(地图)
-
CesiumJS 官网:https://www.cesium.com/
-
CesiumJS 下载地址:https://www.cesium.com/platform/cesiumjs/
-
CesiumJS API 文档:https://cesium.com/learn/cesiumjs/ref-doc/index.html
一、3D 视图
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>场景视图 - 3D 视图</title>
<link rel="stylesheet" href="../js/Cesium-1.112/Build/Cesium/Widgets/widgets.css" />
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
}
#container {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="container"></div>
</body>
<script src="../js/Cesium-1.112/Build/Cesium/Cesium.js"></script>
<script>
const viewer = new Cesium.Viewer("container");
// 等效于
// viewer = new Cesium.Viewer("container", {
// sceneMode: Cesium.SceneMode.SCENE3D,
// });
// 可以通过鼠标中键调整视角
</script>
</html>
二、2D 视图
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>场景视图 - 2D 视图</title>
<link rel="stylesheet" href="../js/Cesium-1.112/Build/Cesium/Widgets/widgets.css" />
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
}
#container {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="container"></div>
</body>
<script src="../js/Cesium-1.112/Build/Cesium/Cesium.js"></script>
<script>
viewer = new Cesium.Viewer("container", {
sceneMode: Cesium.SceneMode.SCENE2D,
});
// 不可以通过鼠标中键调整视角
</script>
</html>