|
|
@@ -39,7 +39,7 @@
|
|
|
|
|
|
<script>
|
|
|
import AMapLoader from '@amap/amap-jsapi-loader'
|
|
|
-import { addGeoPosition, addMyPosition, getGeoPoint } from '@/api/map'
|
|
|
+import {addGeoPosition, addMyPosition, addPath, getGeoPoint} from '@/api/map'
|
|
|
|
|
|
export default {
|
|
|
name: 'AMap',
|
|
|
@@ -139,35 +139,12 @@ export default {
|
|
|
this.map.on('zoomchange', (e) => {
|
|
|
console.log('当前缩放级别: ' + this.map.getZoom())
|
|
|
})
|
|
|
+
|
|
|
+ // this.onPathNavigator()
|
|
|
}).catch((e) => {
|
|
|
console.log(e)
|
|
|
})
|
|
|
},
|
|
|
- // 轨迹巡航
|
|
|
- loadPathSimplifier() {
|
|
|
- AMapUI.load(['ui/misc/PathSimplifier'], (PathSimplifier) => {
|
|
|
- if (!PathSimplifier.supportCanvas) {
|
|
|
- alert('当前环境不支持 Canvas!')
|
|
|
- return
|
|
|
- }
|
|
|
- // 创建组件实例
|
|
|
- var pathSimplifierIns = new PathSimplifier({
|
|
|
- map: this.map,
|
|
|
- zIndex: 100, // 图层叠加顺序
|
|
|
- data: this.path, // 巡航路径
|
|
|
- // 获取巡航路径中的路径坐标数组
|
|
|
- getPath: (pathData, pathIndex) => {
|
|
|
- return pathData.path
|
|
|
- }
|
|
|
- })
|
|
|
- // 创建巡航器
|
|
|
- var pathNavigator = pathSimplifierIns.createPathNavigator(0, {
|
|
|
- loop: false, // 是否循环
|
|
|
- speed: 2000 // 速度(km/h)
|
|
|
- })
|
|
|
- pathNavigator.start()
|
|
|
- })
|
|
|
- },
|
|
|
getDistrict(map) {
|
|
|
// 创建行政区查询对象
|
|
|
var district = new AMap.DistrictSearch({
|
|
|
@@ -244,6 +221,7 @@ export default {
|
|
|
that.circleEditor = circleEditor
|
|
|
})
|
|
|
},
|
|
|
+ // 轨迹巡航
|
|
|
onPathNavigator() {
|
|
|
getGeoPoint().then(resp => {
|
|
|
if (resp.code === 0) {
|
|
|
@@ -271,7 +249,7 @@ export default {
|
|
|
// 创建巡航器
|
|
|
var pathNavigator = pathSimplifierIns.createPathNavigator(0, {
|
|
|
loop: false, // 是否循环
|
|
|
- speed: 2000 // 速度(km/h)
|
|
|
+ speed: 3600 // 速度(km/h)
|
|
|
})
|
|
|
pathNavigator.start()
|
|
|
})
|
|
|
@@ -285,7 +263,13 @@ export default {
|
|
|
} else {
|
|
|
this.enableAddPath = false
|
|
|
this.addPathText = '添加路径'
|
|
|
- console.log(this.pathPointList)
|
|
|
+ addPath(this.pathPointList).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }).finally(() => {
|
|
|
+ this.pathPointList = []
|
|
|
+ })
|
|
|
|
|
|
const pathTrail = { path: [] }
|
|
|
for (const item of this.pathPointList) {
|