react-native - 标注内的按钮单击在本机地图-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
.
推荐阅读
- php - Codeigniter 邮件发送没有 SMTP 服务器?
- xamarin.forms - Xamarin.iOS UIDocumentPickerViewController
- polymer - 如何从聚合物3中的按钮监听另一个组件的事件
- azure - 通过邮递员调用 microsoft graph api
- node.js - 发布请求在nodejs中不起作用
- mysql - MySQL中按聚合函数最大值分组
- php - 如何从 laravel 5.6 中的数据透视表更新特定行?
- asp.net-core - HTTP 错误 502.3 - 播种数据库时网关错误
- android - 我正在尝试查看导致空异常的片段中的地图
- java - Java 中关于 String.intern 的怪事