Browse Source

fix map around

张延森 5 years ago
parent
commit
5fd85a3b3f

+ 4
- 4
config/dev.js View File

7
     // WSS_HOST: '"wss://47.101.36.130:8085"',
7
     // WSS_HOST: '"wss://47.101.36.130:8085"',
8
     // HOST:  '"https://dev.jinchengjiaye.com"',//测试
8
     // HOST:  '"https://dev.jinchengjiaye.com"',//测试
9
     // WSS_HOST: '"wss://dev.jinchengjiaye.com"',
9
     // WSS_HOST: '"wss://dev.jinchengjiaye.com"',
10
-    // HOST: '"https://lt.pawoma.cn"',
11
-    // WSS_HOST: '"wss://lt.pawoma.cn"',
12
-    HOST: '"http://192.168.0.238:8080"',
13
-    WSS_HOST: '"ws://192.168.0.238:8080"',
10
+    HOST: '"https://lt.pawoma.cn"',
11
+    WSS_HOST: '"wss://lt.pawoma.cn"',
12
+    // HOST: '"http://192.168.0.238:8080"',
13
+    // WSS_HOST: '"ws://192.168.0.238:8080"',
14
   },
14
   },
15
   weapp: {},
15
   weapp: {},
16
   h5: {}
16
   h5: {}

+ 2
- 2
src/pages/project/detail/Around/Pannel.js View File

36
 
36
 
37
   initData = (props) => {
37
   initData = (props) => {
38
     const { data = [] } = props.dataset || {}
38
     const { data = [] } = props.dataset || {}
39
-    const markerList = JSON.parse(data)
39
+    const markerList = data
40
     let activeIndex = -1
40
     let activeIndex = -1
41
     let currentMarkerPos = undefined
41
     let currentMarkerPos = undefined
42
 
42
 
100
             })
100
             })
101
           }
101
           }
102
           {
102
           {
103
-            manualData.length && (
103
+            manualData.length && this.state.markerList.length && (
104
               <View className="around-cell-title">其他</View>
104
               <View className="around-cell-title">其他</View>
105
             )
105
             )
106
           }
106
           }

+ 12
- 10
src/pages/project/detail/Around/index.js View File

3
 import PoiAround from '@components/amap/PoiAround'
3
 import PoiAround from '@components/amap/PoiAround'
4
 import Tab from './Tab'
4
 import Tab from './Tab'
5
 import Pannel from './Pannel'
5
 import Pannel from './Pannel'
6
+import { POI_TYPES } from '@utils/amap'
6
 import './style.scss'
7
 import './style.scss'
7
 
8
 
8
 export default function Around(props) {
9
 export default function Around(props) {
9
   const detail = props.building || {}
10
   const detail = props.building || {}
10
   
11
   
11
   const [lat, lng] = (detail.coordinate || '').split(',')
12
   const [lat, lng] = (detail.coordinate || '').split(',')
12
-  const poiDatas = detail.mapJson ? JSON.parse(detail.mapJson) : []
13
-  const ty = Object.prototype.toString
13
+  const poiDatas = typeof detail.mapJson === 'string' ? JSON.parse(detail.mapJson) : []
14
 
14
 
15
   // 展示内容数组
15
   // 展示内容数组
16
-  const dataList = poiDatas.map((item) => {
17
-    const key = item.key
18
-    const manualData = (detail[`building${key}`] === '' ? [] : (detail[`building${key}`] || '').split(','))
19
-    
16
+  const dataList = POI_TYPES.map((poi) => {
17
+    const jsonData = poiDatas.filter(x => x.key === poi.key)[0] || {}
18
+    const data = JSON.parse(jsonData.data || '[]')
19
+    const manualData = (detail[`building${poi.key}`] === '' ? [] : (detail[`building${poi.key}`] || '').split(','))
20
+
20
     return {
21
     return {
21
-      ...item,
22
+      ...poi,
23
+      data,
22
       manualData,
24
       manualData,
23
-      num: (ty.call(item.data) === '[object String]' ? JSON.parse(item.data) : []).length + manualData.length,
25
+      num: data.length + manualData.length,
24
     }
26
     }
25
   }).filter(x => x.num)
27
   }).filter(x => x.num)
26
-
28
+  
27
   // 所有的 markers
29
   // 所有的 markers
28
   const markersList = dataList.map((item) => {
30
   const markersList = dataList.map((item) => {
29
-    const mapJson = JSON.parse(item.data) 
31
+    const mapJson = item.data || '[]'
30
     return (mapJson || []).map((it) => {
32
     return (mapJson || []).map((it) => {
31
       const [longitude, latitude] = (it.location || '').split(',')
33
       const [longitude, latitude] = (it.location || '').split(',')
32
 
34
 

+ 40
- 0
src/utils/amap.js View File

1
+const POI_TYPES = [
2
+  {
3
+    key: 'Transport',
4
+    label: '交通',
5
+    types: ['150100', '150200', '150300', '150400', '150500', '150600'],
6
+  },
7
+  {
8
+    key: 'Mall',
9
+    label: '商业',
10
+    types: ['060100', '060200', '060300', '060400', '060500', '060600',
11
+            '060700', '060800', '060900', '061000', '061100', '061200',
12
+            '061300', '061400', '080100', '080200', '080300', '080400',
13
+            '080500', '080600'],
14
+  },
15
+  {
16
+    key: 'Edu',
17
+    label: '学校',
18
+    types: ['141200'],
19
+  },
20
+  {
21
+    key: 'Hospital',
22
+    label: '医院',
23
+    types: ['090100', '090200', '090300', '090400', '090500', '090600', '090700'],
24
+  },
25
+  {
26
+    key: 'Bank',
27
+    label: '银行',
28
+    types: ['160100'],
29
+  },
30
+  {
31
+    key: 'Restaurant',
32
+    label: '餐饮',
33
+    types: ['050100', '050200', '050300', '050400', '050500', '050600',
34
+            '050700', '050800', '050900'],
35
+  },
36
+]
37
+
38
+export {
39
+  POI_TYPES,
40
+}