通过State重新渲染地图点位后,老的点位不会清除掉,并且点位会随着地图拖动而移动
Created by: blackkey520
"react": "16.0.0", "react-native": "0.50.4", "react-native-amap3d": "^0.8.0", 更新到最新版本后,通过state重新渲染地图上的点位,老的点位不会被清除掉。新加的点位会随着地图的移动而移动。 之前我提过类似的bug,之前解决了。但是现在又出现了。 这是链接 代码如下
` import React, {Component} from 'react' import {StyleSheet, Image, View} from 'react-native' import {MapView, Marker} from 'react-native-amap3d'
export default class MarkerExample extends Component { static navigationOptions = { title: '添加标记', }
state = { list: [1, 2, 3, 4, 5, 6], }
_renderImageMarker = () => <Image style={styles.customIcon} source={require('../../images/flag.png')}/>
_update = () => this.setState({list: [11, 12, 13, 14, 15, 16]})
render() { return {this.state.list.map(item => <Marker key={item} icon={this._renderImageMarker} title={'Marker' + item} coordinate={{ latitude: 39.906901 + (item * 0.01), longitude: 116.397972 + (item * 0.01), }} /> )} } }
const styles = StyleSheet.create({ customIcon: { width: 40, height: 40, }, })`