fangmingyue 2 years ago
parent
commit
1bbe2a1d29
2 changed files with 13 additions and 6 deletions
  1. 8
    5
      src/components/map/index.jsx
  2. 5
    1
      src/components/map/style.module.less

+ 8
- 5
src/components/map/index.jsx View File

1
 import React from 'react';
1
 import React from 'react';
2
 import Taro from '@tarojs/taro';
2
 import Taro from '@tarojs/taro';
3
-import { View, Map } from '@tarojs/components';
3
+import { View, Map, CoverView } from '@tarojs/components';
4
+import { Icon } from '@antmjs/vantui'
4
 import { getLocation } from '@/utils/authorize';
5
 import { getLocation } from '@/utils/authorize';
5
 import iconPath from '@/assets/icons/marker.png';
6
 import iconPath from '@/assets/icons/marker.png';
6
 import style from './style.module.less';
7
 import style from './style.module.less';
18
     markers,
19
     markers,
19
     lngLat,
20
     lngLat,
20
   ] = React.useMemo(() => {
21
   ] = React.useMemo(() => {
21
-    const loc = location || currentPos || '116.354259,31.415587';    
22
+    const loc = location || currentPos || '116.354259,31.415587';
22
     const [longitude, latitude] = loc.split(',');
23
     const [longitude, latitude] = loc.split(',');
23
 
24
 
24
     const mks = [{
25
     const mks = [{
35
       [longitude, latitude]
36
       [longitude, latitude]
36
     ]
37
     ]
37
   }, [location, currentPos]);
38
   }, [location, currentPos]);
38
-  
39
+
39
   React.useEffect(() => {
40
   React.useEffect(() => {
40
     getLocation().then((res) => {
41
     getLocation().then((res) => {
41
       setCurPos([res.longitude, res.latitude].join(','));
42
       setCurPos([res.longitude, res.latitude].join(','));
56
       onLocChange(loc);
57
       onLocChange(loc);
57
     }
58
     }
58
   }, [location, currentPos]);
59
   }, [location, currentPos]);
59
-  
60
+
60
   return (
61
   return (
61
     <View className={style['map-wrapper']}>
62
     <View className={style['map-wrapper']}>
62
       <Map
63
       <Map
63
         longitude={lngLat[0]}
64
         longitude={lngLat[0]}
64
         latitude={lngLat[1]}
65
         latitude={lngLat[1]}
65
         markers={markers}
66
         markers={markers}
66
-      ></Map>
67
+      >
68
+        <CoverView className={style['control']}><Icon name="aim" size="26px" color="rgb(18,183,245)" /></CoverView>
69
+      </Map>
67
     </View>
70
     </View>
68
   )
71
   )
69
 }
72
 }

+ 5
- 1
src/components/map/style.module.less View File

1
-
2
 .map-wrapper {
1
 .map-wrapper {
3
   width: 100%;
2
   width: 100%;
4
   height: 0;
3
   height: 0;
11
     position: absolute;
10
     position: absolute;
12
     top: 0;
11
     top: 0;
13
     left: 0;
12
     left: 0;
13
+    .control {
14
+      position: absolute;
15
+      bottom: 14%;
16
+      right: 4%;
17
+    }
14
   }
18
   }
15
 }
19
 }