如何解决react native 如何更新标记数据中的模态
我正在谷歌地图中映射标记。
例如,我按下了任何标记模式将仅显示第三个数组标记数据。
如何显示任何其他数组标记数据?
我认为它会使用 componentDidUpdate
,但我不会写代码,请帮忙。
我使用 react-native-maps
和 react-native-modalize
标记数据
export const locations = {
markers: [
{
index: '1',coordinate: {
latitude: 37.449642,longitude: 127.127142
},title: "bread",company: "paba",price: "3000",description: "pa",img: "https://t1.daumcdn.net/cfile/blog/251112342853B589A8D8F2B",},{
index: '2',coordinate: {
latitude: 37.451299,longitude: 127.129404
},title: "youget",company: "711",price: "1000",description: "711",img: "https://www.mpps.co.kr/kfcs_api_img/KFWECS/goods/DL_2174223_20200903093553622.PNG"
},{
index: '3',coordinate: {
latitude: 37.448789,longitude: 127.127100
},title: "coke",company: "famil",description: "famil",img: "https://image.auction.co.kr/itemimage/12/36/f2/1236f20cb63212.jpg"
},]
}
打开模态
mapMarkers = (_marker) => {
return locations.markers.map((_marker,i) => (
<View>
<Marker
key={_marker['index']}
coordinate={_marker['coordinate']}
//title={_marker.title}
//description={_marker['description']}
onPress={this.openModal}
>
</Marker>
</View>
))
}
modalScreen = () => {
return locations.markers.map((_marker) => (
<Modalize
ref={this.modal}
snapPoint={200}
modalTopOffset={100}
overlayStyle={{
backgroundColor: 'transparent'
}}
>
<View>
<View style={styles.bubble}>
<Text style={styles.name}> {_marker.title}</Text>
{<Text style={styles.company}> {_marker.company} </Text>}
<Text style={styles.price}>{_marker.price}</Text>
<Image style={styles.image}
source={{ uri: _marker['img'] }}
/>
</View>
</View>
</Modalize>
))
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。