From fa611ff2eeaac289931eb0e21a962743fb271ba7 Mon Sep 17 00:00:00 2001
From: sean.zhou <sean.zhou@dji.com>
Date: Fri, 23 Sep 2022 17:46:57 +0800
Subject: [PATCH] Update v1.2.0

---
 src/hooks/use-g-map-cover.ts |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/hooks/use-g-map-cover.ts b/src/hooks/use-g-map-cover.ts
index 1ddf152..38e6d4e 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: {
@@ -31,7 +33,6 @@
       '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