75 lines
2.3 KiB
HTML
75 lines
2.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<!-- <title>Title</title><script src="https://cesium.com/downloads/cesiumjs/releases/1.128/Build/Cesium/Cesium.js"></script> -->
|
|
<!-- <script src="http://43.142.48.85:15000/sdk/Cesium/Cesium.js"></script> -->
|
|
<script src="../sdk/YJEarth.min.js"></script>
|
|
<script src="vue.js"></script>
|
|
<style>
|
|
body {
|
|
width: 100%;
|
|
height: 100%;
|
|
margin: 0;
|
|
}
|
|
#app {
|
|
width: 100%;
|
|
height: 100vh;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="app" class="fullSize">
|
|
<button class="button" @Click="start">剖切</button>
|
|
<button class="button" @Click="Section && Section.destroy()">清除</button>
|
|
</div>
|
|
</body>
|
|
|
|
</html>
|
|
|
|
<script>
|
|
new Vue({
|
|
el: "#app",
|
|
data: {
|
|
tileset: null,
|
|
Section: null
|
|
},
|
|
async mounted() {
|
|
await YJ.on()
|
|
this.createEarth()
|
|
},
|
|
methods: {
|
|
async createEarth() {
|
|
window.sdk = await new YJ.YJEarth("app")
|
|
|
|
// 加载模型
|
|
this.tileset = await new YJ.Obj.Tileset(sdk, {
|
|
show: true,
|
|
url: "http://localhost:8891/yjearth4.0/data/tileset/a41ee82c22806bdd07092a26e694ebb8/tileset.json",
|
|
id: "123456",
|
|
position: { lng: 140, lat: 40, alt: 20 }
|
|
})
|
|
await this.tileset.on()
|
|
this.tileset.flyTo()
|
|
// 绘制多边形
|
|
let Draw = new YJ.Draw.DrawPolygon(sdk)
|
|
console.log(this.tileset.entity)
|
|
Draw.start((a, positions) => {
|
|
// 剖切
|
|
this.Section = new YJ.Analysis.Section(sdk, this.tileset.entity, { positions: positions })
|
|
})
|
|
},
|
|
|
|
start() {
|
|
let Draw = new YJ.Draw.DrawPolygon(sdk)
|
|
Draw.start((a, positions) => {
|
|
// if(positions && positions.length >= 3) {
|
|
this.Section = new YJ.Analysis.Section(sdk, this.tileset.entity, { positions: positions })
|
|
// }
|
|
})
|
|
},
|
|
}
|
|
})
|
|
</script> |