2025-05-21 11:24:53 +08:00
|
|
|
<template>
|
|
|
|
<div class="ol-map" id="olMap"></div>
|
2025-06-18 19:56:54 +08:00
|
|
|
<el-button class="btn" type="primary" @click="drawRectangle">绘制矩形</el-button>
|
2025-05-21 11:24:53 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
2025-06-18 19:56:54 +08:00
|
|
|
import { workScheduleDel } from '@/api/progress/plan';
|
|
|
|
import { renderFacilitiesToCesium } from '@/views/gisHome/js/renderFacilities';
|
|
|
|
let sdk = null;
|
|
|
|
|
|
|
|
const initFacilities = async () => {
|
|
|
|
const res = await workScheduleDel('1933358821565095951');
|
|
|
|
console.log(res);
|
|
|
|
|
|
|
|
renderFacilitiesToCesium(sdk.viewer, res.data.photovoltaicPanelPositionList, 'Polygon', { flyToFirst: true });
|
|
|
|
renderFacilitiesToCesium(sdk.viewer, res.data.photovoltaicPanelPointPositionList, 'Point', { flyToFirst: true });
|
|
|
|
};
|
|
|
|
|
|
|
|
// 初始化 Cesium 地球
|
2025-05-21 11:24:53 +08:00
|
|
|
const createEarth = () => {
|
2025-06-18 19:56:54 +08:00
|
|
|
sdk = new YJ.YJEarth('olMap');
|
|
|
|
|
2025-05-21 11:24:53 +08:00
|
|
|
YJ.Global.setDefaultView(sdk, {
|
|
|
|
destination: { lng: 100, lat: 30, alt: 22099000 },
|
|
|
|
orientation: {
|
|
|
|
heading: 0.0,
|
|
|
|
pitch: -90.0,
|
|
|
|
roll: 0.0
|
|
|
|
}
|
|
|
|
});
|
2025-06-18 19:56:54 +08:00
|
|
|
|
|
|
|
new YJ.Obj.ArcgisWXImagery(sdk, {
|
2025-05-21 11:24:53 +08:00
|
|
|
show: true,
|
|
|
|
layer_index: 1
|
|
|
|
});
|
2025-06-18 19:56:54 +08:00
|
|
|
|
2025-05-21 11:24:53 +08:00
|
|
|
YJ.Global.CesiumContainer(sdk, {
|
2025-06-18 19:56:54 +08:00
|
|
|
compass: false
|
2025-05-21 11:24:53 +08:00
|
|
|
});
|
2025-06-18 19:56:54 +08:00
|
|
|
|
2025-05-21 11:24:53 +08:00
|
|
|
new YJ.Tools(sdk).flyHome(0);
|
|
|
|
};
|
|
|
|
|
2025-06-18 19:56:54 +08:00
|
|
|
// 点击按钮时绘制一个矩形并飞行过去
|
|
|
|
const drawRectangle = () => {
|
|
|
|
const viewer = sdk.viewer;
|
|
|
|
const rectangleEntity = viewer.entities.add({
|
|
|
|
name: '测试矩形',
|
|
|
|
rectangle: {
|
|
|
|
coordinates: Cesium.Rectangle.fromDegrees(100.0, 30.0, 102.0, 32.0), // 西南角到东北角
|
|
|
|
material: Cesium.Color.YELLOW.withAlpha(0.5),
|
|
|
|
outline: true,
|
|
|
|
height: 2.5,
|
|
|
|
outlineColor: Cesium.Color.BLACK
|
|
|
|
}
|
|
|
|
});
|
|
|
|
viewer.flyTo(viewer.entities);
|
|
|
|
};
|
|
|
|
|
2025-05-21 11:24:53 +08:00
|
|
|
onMounted(async () => {
|
2025-06-18 19:56:54 +08:00
|
|
|
// 最早执行
|
|
|
|
window.CESIUM_BASE_URL = '/Cesium/';
|
|
|
|
|
2025-05-21 11:24:53 +08:00
|
|
|
await YJ.on();
|
|
|
|
createEarth();
|
2025-06-18 19:56:54 +08:00
|
|
|
await initFacilities();
|
2025-05-21 11:24:53 +08:00
|
|
|
console.log(YJ);
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import '../css/gis.scss';
|
|
|
|
.ol-map {
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: calc(100vh);
|
|
|
|
}
|
2025-06-18 19:56:54 +08:00
|
|
|
.btn {
|
|
|
|
position: absolute;
|
|
|
|
top: 20px;
|
|
|
|
left: 20px;
|
|
|
|
z-index: 10;
|
|
|
|
}
|
2025-05-21 11:24:53 +08:00
|
|
|
</style>
|