CesiumJS
-
CesiumJS API:https://cesium.com/learn/cesiumjs/ref-doc/index.html
-
CesiumJS 是一个开源的 JavaScript 库,它用于在网页中创建和控制 3D 地球仪(地图)
一、添加图片图层
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ImageryProvider - 添加图片图层</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");
// 创建图片图层
const imageryProvider = new Cesium.SingleTileImageryProvider({
url: "../img/test.jpg",
});
const imageryLayer = viewer.imageryLayers.addImageryProvider(imageryProvider);
</script>
</html>
二、添加图片图层并覆盖指定区域
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ImageryProvider - 添加图片图层并覆盖指定区域</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");
const west = 0; // 西经(西经为负)
const south = 0; // 南纬(南纬为负)
const east = 10; // 东经(东经为正)
const north = 10; // 北纬(北纬为正)
// 创建图片图层
const imageryProvider = new Cesium.SingleTileImageryProvider({
url: "../img/test.jpg",
rectangle: Cesium.Rectangle.fromDegrees(west, south, east, north),
});
const imageryLayer = viewer.imageryLayers.addImageryProvider(imageryProvider);
</script>
</html>
标签:const,100%,添加,Cesium,图层,图片
From: https://blog.csdn.net/weixin_52173250/article/details/143252752