Files
4.0/static/example/添加多边形.html

53 lines
1.0 KiB
HTML
Raw Normal View History

2025-07-03 17:39:09 +08:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="../sdk/YJEarth.min.js"></script>
<script src="vue.js"></script>
<style>
body {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="app" class="fullSize">
<button class="button" @Click="ExportKml">导出kml</button>
</div>
</body>
</html>
<script>
new Vue({
el: "#app",
data: {
sdk: null,
PolygonObject: null
},
async mounted() {
await YJ.on()
this.createEarth()
},
methods: {
createEarth() {
this.sdk = new YJ.YJEarth("app")
let Draw = new YJ.Draw.DrawPolygon(this.sdk)
Draw.start((a,positions)=>{
let PolygonObject = new YJ.Obj.PolygonObject(this.sdk, {positions: positions})
PolygonObject.edit(true)
this.PolygonObject = PolygonObject
PolygonObject.flyTo()
})
},
ExportKml() {
YJ.Global.ExportKml([this.PolygonObject])
}
}
})
</script>