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-cover.ts | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/src/hooks/use-g-map-cover.ts b/src/hooks/use-g-map-cover.ts
index 1ddf152..f00ff36 100644
--- a/src/hooks/use-g-map-cover.ts
+++ b/src/hooks/use-g-map-cover.ts
@@ -10,16 +10,18 @@
export function useGMapCover () {
const root = getRoot()
- const AMap = root.$aMapObj
+ const AMap = root.$aMap
const normalColor = '#2D8CF0'
const store = rootStore
const coverList = store.state.coverList
+
function AddCoverToMap (cover :any) {
- root.$aMap.add(cover)
+ root.$map.add(cover)
coverList.push(cover)
// console.log('coverList:', store.state.coverList)
}
+
function getPinIcon (color?:string) {
// console.log('color', color)
const colorObj: {
@@ -27,11 +29,10 @@
} = {
'2d8cf0': pin2d8cf0,
'19be6b': pin19be6b,
- '212121': pin212121,
- 'b620e0': pinb620e0,
- 'e23c39': pine23c39,
- 'ffbb00': pineffbb00,
-
+ 212121: pin212121,
+ b620e0: pinb620e0,
+ e23c39: pine23c39,
+ ffbb00: pineffbb00,
}
const iconName = (color?.replaceAll('#', '') || '').toLocaleLowerCase()
return new AMap.Icon({
@@ -41,6 +42,7 @@
// imageSize: new AMap.Size(40, 50)
})
}
+
function init2DPin (name: string, coordinates:GeojsonCoordinate, color?:string, data?:{}) {
console.log(name, coordinates[0], coordinates[1], color, data)
const pin = new AMap.Marker({
@@ -54,8 +56,9 @@
// console.log('coordinates pin', pin)
AddCoverToMap(pin)
}
+
function AddOverlayGroup (overlayGroup) {
- root.$aMap.add(overlayGroup)
+ root.$map.add(overlayGroup)
coverList.push(overlayGroup)
}
function initPolyline (name: string, coordinates:GeojsonCoordinate[], color?:string, data?:{}) {
@@ -74,6 +77,7 @@
})
AddOverlayGroup(polyline)
}
+
function initPolygon (name: string, coordinates:GeojsonCoordinate[], color?:string, data?:{}) {
const path = [] as GeojsonCoordinate[]
coordinates.forEach(coordinate => {
@@ -92,6 +96,7 @@
})
AddOverlayGroup(Polygon)
}
+
function removeCoverFromMap (id:string) {
for (let i = 0; i < coverList.length; i++) {
const ele = coverList[i]
@@ -99,12 +104,13 @@
const extdata = ele?.getExtData()
if (extdata?.id === id) {
console.log(extdata)
- root.$aMap.remove(ele)
+ root.$map.remove(ele)
coverList.slice(i, 1)
break
}
}
}
+
function getElementFromMap (id:string) {
// console.log('start', new Date().getTime())
const ele = coverList.find(ele => ele?.getExtData().id === id)
@@ -118,6 +124,7 @@
// }
// })
}
+
function updatePinElement (id:string, name: string, coordinates:GeojsonCoordinate, color?:string) {
const element = getElementFromMap(id) as any
if (element) {
@@ -133,6 +140,7 @@
})
}
}
+
return {
init2DPin,
initPolyline,
--
Gitblit v1.9.3