javascript - 在 Mapview Marker 标题上反应原生 onPress 事件?
问题描述
使用下面的代码,如果我单击标记,它会导航到我提到的页面,但我希望在标记标题而不是标记上实现这一点,有什么方法可以使标题可点击。请提供任何帮助。
return (
<MapView
style={styles.map}
placeholder="Search location"
minLength={2}
region={focusRegion}
// onPress={componentDidMount()}
onMapReady={getLocationHandler}
showsUserLocation={true}
//followsUserLocation={true}
loadingEnabled={true}
loadingIndicatorColor={"#606060"}
>
{places.map((marker) => (
<Marker
key={marker.id}
coordinate={{ latitude: marker.lat, longitude: marker.lng }}
title={(marker.title)}
onPress={() => {
props.navigation.navigate("PlaceDetail", {
placeTitle: marker.title,
placeId: marker.id,
});
}}
>
</MapView>
);
解决方案
它适用于标注
<MapView.Callout
title={true}
width={210}
onPress={() => {
props.navigation.navigate("PlaceDetail", {
placeTitle: marker.title,
placeId: marker.id,
});
}}
></MapView.Callout>
推荐阅读
- phpmyadmin - 为什么当 Jupyter 笔记本处于活动状态时我无法访问我的 localhost:8888 地址?
- jquery - Jquery UI Sortable 在 Wordpress 中不起作用
- java - 用于在 android 版本 7 上解析网络安全配置的 xml 配置的凌空异常文件
- javascript - 指定单个 Google Analytics(分析)媒体资源
- octobercms - OctoberCMS 按组注册用户
- recaptcha - 尽管存在正确的随机数,但 Google ReCaptcha CSP 评估违规?
- python - ModuleNotFoundError:没有名为“MySQLdb”的模块
- ruby - 重复字符串
- c++ - 模板参数推导失败和函数参数/参数不匹配
- python - 如何从 .csv 文件中提取值并将它们放入数组中?