{"action":"created","issue":{"url":"https://api.github.com/repos/qiuxiang/react-native-amap3d/issues/320","repository_url":"https://api.github.com/repos/qiuxiang/react-native-amap3d","labels_url":"https://api.github.com/repos/qiuxiang/react-native-amap3d/issues/320/labels{/name}","comments_url":"https://api.github.com/repos/qiuxiang/react-native-amap3d/issues/320/comments","events_url":"https://api.github.com/repos/qiuxiang/react-native-amap3d/issues/320/events","html_url":"https://github.com/qiuxiang/react-native-amap3d/issues/320","id":324350420,"number":320,"title":"多个界面用到MapView，再次切换到首页MapView，操作（移动）地图时程序崩溃","user":{"login":"brucehelen","id":5308436,"avatar_url":"https://avatars2.githubusercontent.com/u/5308436?v=4","gravatar_id":"","url":"https://api.github.com/users/brucehelen","html_url":"https://github.com/brucehelen","followers_url":"https://api.github.com/users/brucehelen/followers","following_url":"https://api.github.com/users/brucehelen/following{/other_user}","gists_url":"https://api.github.com/users/brucehelen/gists{/gist_id}","starred_url":"https://api.github.com/users/brucehelen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brucehelen/subscriptions","organizations_url":"https://api.github.com/users/brucehelen/orgs","repos_url":"https://api.github.com/users/brucehelen/repos","events_url":"https://api.github.com/users/brucehelen/events{/privacy}","received_events_url":"https://api.github.com/users/brucehelen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-05-18T10:11:17Z","updated_at":"2018-05-18T14:08:51Z","closed_at":null,"author_association":"NONE","body":"<!--\r\n进行问题反馈之前：\r\n  - 提供你正在使用的版本、RN 版本、设备信息\r\n  - 请尽可能详细地描述问题\r\n  - 在提编译问题之前，请先检查最新的编译测试\r\n\r\n以下情况 issue 会被 close：\r\n  - 确定是环境配置的问题，且没有提供足够的信息\r\n  - 问题不具备普遍性，且缺乏讨论\r\n\r\n问题被关闭，仍可继续讨论。\r\n-->\r\n\r\n### 用到的版本`package.json`\r\n\r\n```json\r\n{\r\n  \"name\": \"eTracking\",\r\n  \"version\": \"0.0.1\",\r\n  \"private\": true,\r\n  \"scripts\": {\r\n    \"start\": \"node node_modules/react-native/local-cli/cli.js start\",\r\n    \"test\": \"jest\"\r\n  },\r\n  \"dependencies\": {\r\n    \"react\": \"16.2.0\",\r\n    \"react-native\": \"0.52.3\",\r\n    \"react-native-actionsheet\": \"^2.4.2\",\r\n    \"react-native-amap3d\": \"^1.0.0-beta.1\",\r\n    \"react-native-calendars\": \"^1.19.3\",\r\n    \"react-navigation\": \"^2.0.1\"\r\n  },\r\n  \"devDependencies\": {\r\n    \"babel-jest\": \"22.4.3\",\r\n    \"babel-preset-react-native\": \"4.0.0\",\r\n    \"jest\": \"22.4.3\",\r\n    \"react-test-renderer\": \"16.3.1\"\r\n  },\r\n  \"jest\": {\r\n    \"preset\": \"react-native\"\r\n  }\r\n}\r\n```\r\n\r\n\r\n用了官方的`react-navigation`，只有一个界面集成`MapView`时没有问题，各种手势API调用都没有问题。\r\n\r\n我这里是`Main.js`，代码如下：\r\n\r\n```javascript\r\nimport React, { Component } from 'react';\r\nimport { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native';\r\nimport { MapView } from 'react-native-amap3d';\r\nimport ActionSheet from 'react-native-actionsheet'\r\n\r\nexport default class Main extends Component {\r\n  static navigationOptions = {\r\n    title: '小翼',\r\n  };\r\n\r\n  state = {\r\n    showsCompass: false,        // 是否显示罗盘\r\n    zoomLevel: 18,              // 地图缩放级别，[3, 20]\r\n    mapType: 'standard',        // standard: 标准地图，satellite: 卫星地图\r\n    tiltEnabled: false,\r\n    rotateEnabled: false,\r\n    coordinate: {               // 定位模块当前位置\r\n      latitude: 39.806901,\r\n      longitude: 116.397972,\r\n    },\r\n  };\r\n\r\n  locationType = ['离线模式', '省电模式', '普通模式', '性能模式', '休眠', '取消'];\r\n\r\n  _coordinates = [\r\n    {\r\n      latitude: 39.806901,\r\n      longitude: 116.397972,\r\n    },\r\n    {\r\n      latitude: 39.806901,\r\n      longitude: 116.297972,\r\n    },\r\n    {\r\n      latitude: 39.906901,\r\n      longitude: 116.397972,\r\n    },\r\n    {\r\n      latitude: 39.706901,\r\n      longitude: 116.397972,\r\n    },\r\n  ];\r\n\r\n  // 改变定位模式\r\n  _changeLocationType = () => {\r\n    this._actionSheet.show();\r\n  };\r\n\r\n  _actionSheetSelected = (index) => {\r\n    console.log(index, this.locationType[index]);\r\n    switch (index) {\r\n      case 0:\r\n        break;\r\n      default:\r\n        break;\r\n    }\r\n  };\r\n\r\n  // 地图缩放 [3, 20]\r\n  // 放大\r\n  _zoomIn = () => {\r\n    console.log('zoom out', this.state.zoomLevel);\r\n    if (this.state.zoomLevel === 20) {\r\n      return;\r\n    }\r\n    let zoom = ++this.state.zoomLevel;\r\n    this.setState({\r\n      zoomLevel: zoom\r\n    });\r\n  };\r\n\r\n  // 缩小\r\n  _zoomOut = () => {\r\n    console.log('zoom in', this.state.zoomLevel);\r\n    if (this.state.zoomLevel === 3) {\r\n      return;\r\n    }\r\n    let zoom = --this.state.zoomLevel;\r\n    this.setState({\r\n      zoomLevel: zoom\r\n    });\r\n  };\r\n\r\n  // 标准地图，卫星地图\r\n  _changeLocationStyle = () => {\r\n    if (this.state.mapType === 'standard') {\r\n      this.setState({\r\n        mapType: 'satellite'\r\n      });\r\n    } else {\r\n      this.setState({\r\n        mapType: 'standard'\r\n      });\r\n    }\r\n  };\r\n\r\n  // 以定位模块当前位置为中心点\r\n  _updateCurrentCenter = () => {\r\n    this._mapView.animateTo({\r\n      coordinate: {\r\n        latitude: 39.806901,\r\n        longitude: 116.397972,\r\n      }\r\n    });\r\n  };\r\n\r\n  // track history\r\n  _enterTrackHistory = () => {\r\n    this.props.navigation.push('History');\r\n  };\r\n\r\n  // 导航到设备\r\n  _navigationToDevice = () => {\r\n    console.log('_navigationToDevice');\r\n  };\r\n\r\n  render() {\r\n    return (\r\n      <View style={StyleSheet.absoluteFill}>\r\n        <MapView\r\n          {...this.state}\r\n          ref={o => this._mapView = o}\r\n          style={styles.mapView}\r\n        >\r\n          <MapView.Marker\r\n            title={'小翼，电量95%'}\r\n            centerOffset={{x:0, y:-56}}\r\n            icon={() => (\r\n              <View style={styles.customMarker}>\r\n                <Image\r\n                  style={{width: 80, height: 80}}\r\n                  source={require('../res/small_coordinate_0.png')}\r\n                />\r\n              </View>\r\n            )}\r\n            coordinate={this._coordinates[0]}\r\n          />\r\n        </MapView>\r\n\r\n        <View style={styles.toolView}>\r\n          <TouchableOpacity\r\n            onPress={this._changeLocationType.bind(this)}>\r\n            <Image\r\n              style={{width: 43, height: 43}}\r\n              source={require('../res/quick_track-plus_0.png')}\r\n            />\r\n          </TouchableOpacity>\r\n          <TouchableOpacity\r\n            onPress={this._zoomIn.bind(this)}>\r\n            <Image\r\n              style={{width: 36, height: 34, marginTop: 20}}\r\n              source={require('../res/zoom_in.png')}\r\n            />\r\n          </TouchableOpacity>\r\n          <TouchableOpacity\r\n            onPress={this._zoomOut.bind(this)}>\r\n            <Image\r\n              style={{width: 36, height: 34, marginTop: 1}}\r\n              source={require('../res/zoom_out.png')}\r\n            />\r\n          </TouchableOpacity>\r\n          <TouchableOpacity\r\n            onPress={this._changeLocationStyle.bind(this)}>\r\n            <Image\r\n              style={{width: 44, height: 44, marginTop: 60}}\r\n              source={require('../res/map_2d.png')}\r\n            />\r\n          </TouchableOpacity>\r\n          <TouchableOpacity\r\n            onPress={this._updateCurrentCenter.bind(this)}>\r\n            <Image\r\n              style={{width: 52, height: 52, marginTop: 10}}\r\n              source={require('../res/location_0.png')}\r\n            />\r\n          </TouchableOpacity>\r\n          <TouchableOpacity\r\n            onPress={this._enterTrackHistory.bind(this)}>\r\n            <Image\r\n              style={{width: 33, height: 33, marginTop: 10}}\r\n              source={require('../res/track_0.png')}\r\n            />\r\n          </TouchableOpacity>\r\n        </View>\r\n        <View style={styles.bottomView}>\r\n          <View style={{width: 50, justifyContent: 'center', alignItems: 'center'}}>\r\n            <Image\r\n              source={require('../res/track_0.png')}\r\n            />\r\n          </View>\r\n          <View style={{flex: 1}}>\r\n            <Text style={{fontSize: 14, backgroundColor: 'red'}}>\r\n              江苏省苏州市吴中区道浜村苏州创意产业园\r\n            </Text>\r\n            <Text style={{color: 'gray', fontSize: 12, top: 2}}>\r\n              更新于13:59 GPS定位\r\n            </Text>\r\n          </View>\r\n          <View style={{width: 50, justifyContent: 'center', alignItems: 'center'}}>\r\n            <TouchableOpacity\r\n              onPress={this._navigationToDevice.bind(this)}>\r\n              <Image\r\n                source={require('../res/going_0.png')}\r\n              />\r\n            </TouchableOpacity>\r\n          </View>\r\n        </View>\r\n        <ActionSheet\r\n          ref={o => this._actionSheet = o}\r\n          title={'设定定位模式\\n模式不一样，汇报间隔会有差别'}\r\n          options={this.locationType}\r\n          cancelButtonIndex={this.locationType.length - 1}\r\n          destructiveButtonIndex={1}\r\n          onPress={this._actionSheetSelected.bind(this)}\r\n        />\r\n      </View>\r\n    )\r\n  }\r\n}\r\n\r\nconst styles = StyleSheet.create({\r\n  mapView: {\r\n    flex: 1,\r\n    margin: 0,\r\n    marginBottom: 68,\r\n  },\r\n  toolView: {\r\n    position: 'absolute',\r\n    top: 0,\r\n    right:8,\r\n    bottom: 68,\r\n    width: 60,\r\n    justifyContent: 'center',\r\n    alignItems: 'center',\r\n  },\r\n  bottomView: {\r\n    position: 'absolute',\r\n    flexDirection: 'row',\r\n    alignItems: 'center',\r\n    left:0,\r\n    right:0,\r\n    bottom: 0,\r\n    height: 68,\r\n    width: '100%',\r\n    backgroundColor: 'white',\r\n  },\r\n  customMarker: {\r\n    alignItems: 'center',\r\n    borderRadius: 5,\r\n    padding: 5,\r\n  },\r\n  markerText: {\r\n    color: '#fff',\r\n  },\r\n});\r\n\r\n```\r\n\r\n后面又写了`History.js`，通过`react-navigation` push了一个新实例，这里只绘制了一条路径。此时返回到`Main.js`时移动地图程序就崩溃了。\r\n\r\n```javascript\r\nimport React, { Component } from 'react';\r\nimport { StyleSheet, View, Text } from 'react-native';\r\nimport { MapView } from 'react-native-amap3d';\r\n\r\nexport default class History extends Component {\r\n  static navigationOptions = {\r\n    title: '历史轨迹',\r\n  };\r\n\r\n  state = {\r\n    showsCompass: false,        // 是否显示罗盘\r\n    zoomLevel: 18,              // 地图缩放级别，[3, 20]\r\n    mapType: 'standard',        // standard: 标准地图，satellite: 卫星地图\r\n    tiltEnabled: false,\r\n    rotateEnabled: false,\r\n    coordinate: {               // 定位模块当前位置\r\n      latitude: 39.51000,\r\n      longitude: 116.123,\r\n    },\r\n    linePoints: [\r\n      {\r\n        latitude: 39.51000,\r\n        longitude: 116.123,\r\n      },\r\n      {\r\n        latitude: 39.51110,\r\n        longitude: 116.123,\r\n      },\r\n      {\r\n        latitude: 39.51220,\r\n        longitude: 116.123,\r\n      },\r\n      {\r\n        latitude: 39.51350,\r\n        longitude: 116.123,\r\n      },\r\n      {\r\n        latitude: 39.51450,\r\n        longitude: 116.1234,\r\n      },\r\n      {\r\n        latitude: 39.51550,\r\n        longitude: 116.1334,\r\n      },\r\n      {\r\n        latitude: 39.50550,\r\n        longitude: 116.1364,\r\n      },\r\n    ]\r\n  };\r\n\r\n  _onItemPress = point => {\r\n    console.log((this._points.indexOf(point).toString()));\r\n  };\r\n\r\n  render() {\r\n    return (\r\n      <View style={StyleSheet.absoluteFill}>\r\n        <MapView\r\n          {...this.state}\r\n          style={styles.mapView}\r\n        >\r\n          <MapView.Polyline\r\n            gradient\r\n            width={5}\r\n            colors={['#f44336', '#2196f3', '#4caf50']}\r\n            coordinates={this.state.linePoints}\r\n          />\r\n          <MapView.MultiPoint\r\n            points={this.state.linePoints}\r\n            onItemPress={this._onItemPress}\r\n          />\r\n        </MapView>\r\n      </View>\r\n    )\r\n  }\r\n}\r\n\r\nconst styles = StyleSheet.create({\r\n  mapView: {\r\n    flex: 1,\r\n    margin: 0,\r\n    marginBottom: 68,\r\n  },\r\n});\r\n```\r\n\r\n截图如下，真机iPhone 6 Plus，模拟器iPhone X测试结果一致。崩溃前没有任何log。Xcode断点只定位到main函数，没有参考意义。看起来是内存问题。希望能帮忙看看，谢谢！\r\n\r\n![image](https://user-images.githubusercontent.com/5308436/40228966-5a5b7660-5ac5-11e8-88f3-a1af5c7b7389.png)\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/qiuxiang/react-native-amap3d/issues/comments/390219095","html_url":"https://github.com/qiuxiang/react-native-amap3d/issues/320#issuecomment-390219095","issue_url":"https://api.github.com/repos/qiuxiang/react-native-amap3d/issues/320","id":390219095,"user":{"login":"qiuxiang","id":1709072,"avatar_url":"https://avatars1.githubusercontent.com/u/1709072?v=4","gravatar_id":"","url":"https://api.github.com/users/qiuxiang","html_url":"https://github.com/qiuxiang","followers_url":"https://api.github.com/users/qiuxiang/followers","following_url":"https://api.github.com/users/qiuxiang/following{/other_user}","gists_url":"https://api.github.com/users/qiuxiang/gists{/gist_id}","starred_url":"https://api.github.com/users/qiuxiang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qiuxiang/subscriptions","organizations_url":"https://api.github.com/users/qiuxiang/orgs","repos_url":"https://api.github.com/users/qiuxiang/repos","events_url":"https://api.github.com/users/qiuxiang/events{/privacy}","received_events_url":"https://api.github.com/users/qiuxiang/received_events","type":"User","site_admin":false},"created_at":"2018-05-18T14:08:51Z","updated_at":"2018-05-18T14:08:51Z","author_association":"OWNER","body":"应该不是 `MultiPoint` 的问题，不然 example 也会有问题的，看起来是在某种情况下才会导致的。单从你提供的代码看不出来。"}}
{"actor":{"display_login":"qiuxiang"}}