如何解决在标注中单击按钮在 react native map-android 中不起作用
caaout 内的可触摸不透明度不起作用。实际上,一旦单击同一标注中的关闭按钮,我需要隐藏自定义标注视图。不幸的是,单击关闭按钮时我的功能没有触发
`
const closeinforwindow=(e)=>{
console.log("close button is clicked");
}
<SafeAreaView style={{flex: 1}}>
<View style={Interfacestyle.container}>
<MapView mapType="satellite" style={Interfacestyle.map} region={getInitialState()}>
{markers.map((marker,key) => {
return(
<Marker
key={key}
coordinate={marker.latlng}
title={marker.title}
description={marker.description}
calloutOffset={{ x: -8,y: 10 }}
calloutAnchor={{ x: 0.5,y: 0.2 }}
>
<Image source={{uri: marker.image}} style={{width: 42,height: 42,transform: [{ rotate : `${marker.heading} deg`}]}}/>
<Callout tooltip >
<View style={[Interfacestyle.info_windowwrapper]}>
<View style={[Interfacestyle.info_windowcontainer]}>
<View style={[Interfacestyle.inforwwindowheader]} >
<View style={{width:"92%",alignItems:'center'}}><Text style={[Interfacestyle.inforwwindowheadertext]}>{marker.name}</Text></View>
<View style={[Interfacestyle.menuicon]}>
<TouchableHighlight onPress={(e)=>{closeinforwindow(e)}}>
<Icon name="close" color="#fff" size={16} />
</TouchableHighlight>
</View>
</View>
</View>
</Callout>
</Marker>
)
})}
</MapView>
<View>
</SafeAreaView
`
请帮助我。
解决方法
这是一个旧线程,但它似乎仍然相关:https://github.com/react-native-maps/react-native-maps/issues/226#issuecomment-220356079
Android 地图标注不支持其中的按钮,仅支持整个标注的 onPress 事件。这是 Android 上的 Google 地图库的限制,react-native-maps 对此无能为力。
听起来您要么需要放弃该功能,要么重构您的方法以将 onPress
事件用于 Callout
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。