李志伟 2 years ago
parent
commit
46f7c74398
2 changed files with 4 additions and 23 deletions
  1. 2
    21
      src/components/GISMap/index.jsx
  2. 2
    2
      src/components/GISMap/marker.js

+ 2
- 21
src/components/GISMap/index.jsx View File

@@ -6,28 +6,9 @@ import './style.less';
6 6
 export default (props) => {
7 7
   const { lineArr } = props
8 8
   const container = useRef()
9
+  //生成地图
9 10
   const { amapRef, map } = useMap(container);
10
-  // var lineArr = [
11
-  //   [116.478935, 39.997761],
12
-  //   [116.478939, 39.997825],
13
-  //   [116.478912, 39.998549],
14
-  //   [116.478912, 39.998549],
15
-  //   [116.478998, 39.998555],
16
-  //   [116.478998, 39.998555],
17
-  //   [116.479282, 39.99856],
18
-  //   [116.479658, 39.998528],
19
-  //   [116.480151, 39.998453],
20
-  //   [116.480784, 39.998302],
21
-  //   [116.480784, 39.998302],
22
-  //   [116.481149, 39.998184],
23
-  //   [116.481573, 39.997997],
24
-  //   [116.481863, 39.997846],
25
-  //   [116.482072, 39.997718],
26
-  //   [116.482362, 39.997718],
27
-  //   [116.483633, 39.998935],
28
-  //   [116.48367, 39.998968],
29
-  //   [116.484648, 39.999861],
30
-  // ];
11
+  //生成marker
31 12
   useMarker(amapRef, map, lineArr);
32 13
 
33 14
   return (

+ 2
- 2
src/components/GISMap/marker.js View File

@@ -6,7 +6,7 @@ export function useMarker(amapRef, map, lujing) {
6 6
     if (!amapRef.current) return;
7 7
     marker = new amapRef.current.Marker({
8 8
       icon: 'https://a.amap.com/jsapi_demos/static/demo-center-v2/car.png',
9
-      offset: new amapRef.current.Pixel(0, 0),
9
+      offset: new amapRef.current.Pixel(-13, -26),
10 10
     });
11 11
   }, [map]);
12 12
 
@@ -42,7 +42,7 @@ export function useMarker(amapRef, map, lujing) {
42 42
     });
43 43
     //地图跟随marker移动
44 44
     map.setFitView();
45
-  }, [map, amapRef, lujing]);
45
+  }, [map, lujing]);
46 46
 }
47 47
 export function startAnimation() {
48 48
   if (marker) {