Files
sdk4_demo/example/路径规划.html

73 lines
2.1 KiB
HTML
Raw Permalink Normal View History

2025-07-03 15:12:58 +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="planning">路径规划</button>
<button class="button" @Click="ClearAllRoutePlanning">清除全部路径规划</button>
</div>
</body>
</html>
<script>
new Vue({
el: "#app",
data: {
sdk: null,
i: 0
},
async mounted() {
await YJ.on({
ws: true,
host: '127.0.0.1:8888',
})
this.createEarth()
},
methods: {
async createEarth() {
this.sdk = await new YJ.YJEarth("app")
let tileset = await new YJ.Obj.Tileset(this.sdk, {
show: true,
url: "http://localhost:8891/yjearth4.0/data/tileset/bc3c8f4f3196896b8d7376fe951ce46b/tileset.json",
id: "123456",
// position: { lng: 106, lat: 30.03883, alt: 10 },
})
await tileset.on()
tileset.flyTo()
},
planning() {
this.i++
let routePlanning = new YJ.Obj.RoutePlanning(this.sdk, {gps: true})
routePlanning.Dialog.queryCallBack = () => {
routePlanning.createRoute(
[
{ lng: 100 + this.i, lat: 30 + this.i },
{ lng: 101 + this.i, lat: 30 + this.i },
{ lng: 102 + this.i, lat: 30 + this.i },
{ lng: 103 + this.i, lat: 31 + this.i },
{ lng: 104 + this.i, lat: 32 + this.i },
]
)
}
},
ClearAllRoutePlanning() {
YJ.ClearAllRoutePlanning()
}
}
})
</script>