Cesium-Examples/examples/cesiumEx/2.1.9、影像操作.html
2025-05-20 14:52:40 +08:00

76 lines
2.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!--********************************************************************
* by jiawanlong
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="./../../libs/cesium/Cesium1.98/Widgets/widgets.css">
<script type="text/javascript" src="./../../libs/cesium/Cesium1.98/Cesium.js"></script>
</head>
<body style="margin: 0; overflow: hidden; background: #fff; width: 100%; height: 100%; position: absolute; top: 0">
<div id="map" style="margin: 0 auto; width: 100%; height: 100%"></div>
<script type="text/javascript">
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjM2EzNGJmNy02N2RmLTQ0MDMtYjI2MS1hZTJiMTIwZGYwMTYiLCJpZCI6MzA0MzEyLCJpYXQiOjE3NDc3MjM3MTV9.ePQNhuoVuDsi_z00lTm5W26wyW1Adcr1AWetGM6WSXI'
const viewer = new Cesium.Viewer('map', {});
// 加载单张图片
var imageryProvider = new Cesium.SingleTileImageryProvider({
"url": "./word.jpg",
"credit": "测试",
})
let lay = viewer.imageryLayers.addImageryProvider(imageryProvider)
// http://cesium.xin/cesium/cn/Documentation1.72/ImageryLayer.html
lay.alpha = 0.5; // 0.0 全透明. 1.0 不透明.
lay.brightness = 2.0; // > 1.0 增加亮度 < 1.0减少亮度
lay.contrast = 2.0; //对比度
lay.hue = 2.0; //色调
lay.saturation = 2.0; //饱和度
// http://cesium.xin/cesium/cn/Documentation1.72/ImageryLayerCollection.html?classFilter=ImageryLayerCollection
// 图层顺序
viewer.scene.imageryLayers.lower(lay)
viewer.scene.imageryLayers.lowerToBottom(lay)
viewer.scene.imageryLayers.raise(lay)
viewer.scene.imageryLayers.raiseToTop(lay)
// 获取图层
viewer.scene.imageryLayers.get(0)
viewer.scene.imageryLayers.indexOf(lay)
// 是否包含图层
viewer.scene.imageryLayers.contains(lay)
// 删除图层
// viewer.scene.imageryLayers.remove (lay,true)
// viewer.scene.imageryLayers.removeAll ()
function getLayerIndexById(layerId) {
var imageryLayers = viewer.imageryLayers;
// 遍历imageryLayers中的图层查找指定ID的图层
for (var i = 0; i < imageryLayers.length; i++) {
var layer = imageryLayers.get(i);
// 检查图层的ID是否与指定ID匹配
if (layer.id === layerId) {
// 返回图层在imageryLayers中的索引位置
return i;
}
}
// 如果没有找到指定ID的图层则返回-1
return -1;
}
</script>
</body>
</html>