2.导出
// 导出exportDoc () {this.loading = truelet arrRefs = [this.$refs.endChart, this.$refs.processChart, this.$refs.officeEndChart]setTimeout(() => {Promise.all(arrRefs.map((canvasDom) => {return this.html2canvasHandle(canvasDom)})).then(res => {let arr = res.map(canvas => {return canvas.toDataURL('image/png')})axios.post('/bj_rwgl/business/api/leader/exportStat',{unitId: this.roleId == 500 || this.roleId == 600 ? "" : this.groupId,startTime: Array.isArray(this.form.date) ? this.form.date[0] : '',endTime: Array.isArray(this.form.date) ? this.form.date[1] : '',name: '',// this.activeName,"endChart": arr[0], // 批示办结统计图片"processChart": arr[1], // 在办任务进展情况图片"officeEndChart": arr[2] // 处室办结情况统计图片},{responseType: "blob",}).then(res => {if (res.data) {let blob = new Blob([res.data], {type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'});let downloadElement = document.createElement("a");let href = window.URL.createObjectURL(blob); // 创建下载的链接downloadElement.href = href;downloadElement.download = "统计数据.docx"; // 下载后文件名// document.body.appendChild(downloadElement);downloadElement.click(); // 点击下载// document.body.removeChild(downloadElement); // 下载完成移除元素window.URL.revokeObjectURL(href); // 释放掉blob对象this.loading = falsereturn this.$message.success('导出成功')} else {this.loading = falsereturn this.$message.error('导出失败')}}).catch(err => {this.loading = falsereturn this.$message.error('导出失败')})})}, 100);}
3.地形夸张
- 第一种方式:viewer.scene.globe.terrainExaggeration = 2
- 第二种方式:viewer初始化时设置
new Cesium.Viewer('container', function () {terrainExaggeration: 2
})
javascript
// 创建Cesium Viewer实例
const viewer = new Cesium.Viewer('cesiumContainer');// 设置地形提供者
viewer.terrainProvider = new Cesium.CesiumTerrainProvider({url : Cesium.IonResource.fromAssetId(1) // 替换为您的地形资源
});// 创建并设置地形夸张系数
const exaggeration = new Cesium.TerrainExaggeration({exaggeration : 2.0 // 设置夸张系数为2.0
});// 将夸张系数应用到地形提供者
viewer.scene.terrainExaggeration = exaggeration.exaggeration;
4.查询entity
queryEntityById(id) {const entity = this.viewer.entities.getById(id);if (entity) {console.log(`Found Entity by ID: ${entity.name}`);} else {console.log(`Entity with ID '${id}' not found.`);}},queryEntityByName(name) {const entities = this.viewer.entities.values;const foundEntity = entities.find(entity => entity.name === name);if (foundEntity) {console.log(`Found Entity by Name: ${foundEntity.id}`);} else {console.log(`Entity with name '${name}' not found.`);}}
4.cesium切片缓存
法一:
// const script1 = document.createElement('script');// script1.src = './data/CesiumNetworkPlug.min.js';// script1.onload = () => {// // 这里可以放置 CesiumNetworkPlug 脚本加载后的代码// let OfflineCache = window.CesiumNetworkPlug.OfflineCacheController;// OfflineCache.ruleList.add("*");// };// document.head.appendChild(script1);
法二:
5.地图加载完成监听 e==0
tileLoadProgressEvent
是一个事件,它会在地形或影像瓦片加载过程中被触发。
let helper = new Cesium.EventHelper();
helper.add(Cesium3DViewer.scene.globe.tileLoadProgressEvent, function (e) {// console.log('每次加载地图服务矢量切片都会进入这个回调', e);if (e==0) {helper.removeAll();// console.log("矢量切片加载完成");}
});
6.地形出现底图缝隙-换成火星地形试试
let terrainProvider = new Cesium.CesiumTerrainProvider({url: "http://data.mars3d.cn/terrain",//"/bj_jsc/dzsp/dem",requestWaterMask: true});