【发布时间】:2020-04-22 22:28:15
【问题描述】:
当我按下应用上卡片的 X 按钮时,我目前正试图关闭我的标注。
我的代码是这样的。 **关卡功能**
unsetCard = id => {
this.setState({
...this.state,
showCard: false,
});
this.markers.hideCallout();
if (this.state.keyboard) {
Keyboard.dismiss();
}
};
这是我的** Map View 代码,我使用 RN Clustering **
<MapView
//
mapRef={ref => (this.myMapRef = ref)}
//
onPress={this.unsetCard}>
{this.props.data.map(marker => (
<Marker
key={marker.id}
ref={ref => (this.markers = ref)}
//
}>
<Callout
//
}}>
<CustomCallout title={marker.t} />
</Callout>
</Marker>
))}
</MapView>
最后在同一个文件的这个组件中调用了unset card函数:
<CustomCardWithImage
close={() => this.unsetCard(this.state.cardInfo.id)}
/>
如果有人告诉我如何使用标记的引用,我将不胜感激,因为尽管我尝试了很多,但它不起作用。
提前致谢,
【问题讨论】:
标签: reactjs react-native react-native-maps