From 3667807a7b7418efc090ee3fa6a6b734bc3080bf Mon Sep 17 00:00:00 2001
From: xieb <vip_xiaobin810@163.com>
Date: Wed, 13 Sep 2023 20:36:29 +0800
Subject: [PATCH] Merge branch 'develop' of http://s16s652780.51mypc.cn:49896/r/yskj/iot_drone_web into develop
---
src/hooks/use-g-map-tsa.ts | 37 ++++++++++++++++++++-----------------
1 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/src/hooks/use-g-map-tsa.ts b/src/hooks/use-g-map-tsa.ts
index 6db59d8..f71217c 100644
--- a/src/hooks/use-g-map-tsa.ts
+++ b/src/hooks/use-g-map-tsa.ts
@@ -1,25 +1,24 @@
import store from '/@/store'
import { getRoot } from '/@/root'
-import { ELocalStorageKey } from '/@/types'
+import { ELocalStorageKey, EDeviceTypeName } from '/@/types'
import { getDeviceBySn } from '/@/api/manage'
import { message } from 'ant-design-vue'
+import dockIcon from '/@/assets/icons/dock.png'
+import rcIcon from '/@/assets/icons/rc.png'
+import droneIcon from '/@/assets/icons/drone.png'
export function deviceTsaUpdate () {
const root = getRoot()
- const AMap = root.$aMap
+ let AMap = root.$aMap
- const icons: {
- [key: string]: string
- } = {
- 'sub-device': '/@/assets/icons/drone.png',
- 'gateway': '/@/assets/icons/rc.png',
- 'dock': '/@/assets/icons/dock.png'
- }
+ const icons = new Map([
+ [EDeviceTypeName.Aircraft, droneIcon],
+ [EDeviceTypeName.Gateway, rcIcon],
+ [EDeviceTypeName.Dock, dockIcon]
+ ])
const markers = store.state.markerInfo.coverMap
const paths = store.state.markerInfo.pathMap
- // Fix: 航迹初始化报错
- // TODO: 从时序上解决
let trackLine = null as any
function getTrackLineInstance () {
if (!trackLine) {
@@ -31,26 +30,30 @@
return trackLine
}
- function initIcon (type: string) {
+ function initIcon (type: number) {
return new AMap.Icon({
- image: icons[type],
- imageSize: new AMap.Size(40, 40)
+ image: icons.get(type),
+ imageSize: new AMap.Size(40, 40),
+ size: new AMap.Size(40, 40)
})
}
- function initMarker (type: string, name: string, sn: string, lng?: number, lat?: number) {
+ function initMarker (type: number, name: string, sn: string, lng?: number, lat?: number) {
if (markers[sn]) {
return
}
+ if (root.$aMap === undefined) {
+ return
+ }
+ AMap = root.$aMap
markers[sn] = new AMap.Marker({
- position: new AMap.LngLat(lng || 113.935913, lat || 22.525335),
+ position: new AMap.LngLat(lng || 113.943225499, lat || 22.577673716),
icon: initIcon(type),
title: name,
anchor: 'top-center',
offset: [0, -20],
})
root.$map.add(markers[sn])
-
// markers[sn].on('moving', function (e: any) {
// let path = paths[sn]
// if (!path) {
--
Gitblit v1.9.3