|
@@ -2,7 +2,26 @@ import Taro, { Component } from '@tarojs/taro'
|
2
|
2
|
import { Map } from '@tarojs/components'
|
3
|
3
|
import icons from './icons'
|
4
|
4
|
|
|
5
|
+function ObjEqual (a = {}, b = {}) { return JSON.stringify(a) === JSON.stringify(b) }
|
|
6
|
+
|
5
|
7
|
export default class PoiAround extends Component {
|
|
8
|
+ map = null;
|
|
9
|
+
|
|
10
|
+ componentDidMount () {
|
|
11
|
+ this.map = wx.createMapContext('poi-around', this)
|
|
12
|
+ }
|
|
13
|
+
|
|
14
|
+ componentWillReceiveProps (nextProps) {
|
|
15
|
+ if (this.map) {
|
|
16
|
+ if (!ObjEqual(nextProps.markers, this.props.markers)) {
|
|
17
|
+ const tk = setTimeout(() => {
|
|
18
|
+ this.map.moveToLocation()
|
|
19
|
+ console.log(this.map)
|
|
20
|
+ clearTimeout(tk)
|
|
21
|
+ }, 1000)
|
|
22
|
+ }
|
|
23
|
+ }
|
|
24
|
+ }
|
6
|
25
|
|
7
|
26
|
handleTap = (e) => {
|
8
|
27
|
const marker = this.props.markers.filter(x => x.id === e.markerId)[0]
|
|
@@ -26,7 +45,9 @@ export default class PoiAround extends Component {
|
26
|
45
|
|
27
|
46
|
return this.props.longitude && (
|
28
|
47
|
<Map
|
|
48
|
+ id="poi-around"
|
29
|
49
|
showLocation
|
|
50
|
+ show-location={true}
|
30
|
51
|
scale={12}
|
31
|
52
|
markers={markers}
|
32
|
53
|
longitude={this.props.longitude}
|