如何解决如何在 React Native MapView 中选择默认的 Google Maps 标记?或者,您如何不显示默认的 Google 地图标记?
我有一个地图视图,其中渲染了三种类型的标记:访问、书签和喜欢。
<MapView
style={styles.map}
provider={PROVIDER_GOOGLE}
initialRegion={region}
showsUserLocation={true}
ref={mapRef}
>
{/* <View style={{ paddingLeft: '5%',paddingBottom: '1%',height: '18%',width: '100%',flexDirection: 'row',justifyContent: 'flex-start',alignItems: 'flex-end' }}> */}
<View style={{ paddingLeft: '5%',flexDirection: 'column'}}>
<View style={{ flexDirection: 'row',paddingTop: '24%' }}>
{profileUser && followers.length > 0 && <FollowerPicture user={profileUser} /> }
{followers.map(follower => {
return (
<FollowerPicture key={follower.profileUri} user={follower} />
)
})}
</View>
{data && <TouchableOpacity onPress={filter} style={{
shadowColor: '#000000',shadowOffset: {
width: 0,height: 3
},shadowRadius: 5,shadowOpacity: 0.3,alignSelf: 'flex-end',marginTop: '3%',marginRight: '5%',backgroundColor: colors.white1,height: 40,width: 40,borderRadius: 40,justifyContent: 'center',alignItems: 'center'
}}>
<FontAwesome name="filter" size={24} color={colors.black2} />
</TouchableOpacity>}
</View>
{visits.map(visit => {
const restaurant = visit.restaurant;
return(
<MapView.Marker
key={restaurant.id.toString().concat(restaurant.__typename)}
coordinate={{ latitude: restaurant.latitude,longitude: restaurant.longitude }}
title={restaurant.name}
pinColor={colors.green1}
onPress={(e) => {
pressMarker(e,restaurant.id)
}}
/>
)
})}
{bookmarks.map(bookmark => {
const restaurant = bookmark.restaurant;
return(
<MapView.Marker
key={restaurant.id.toString().concat(restaurant.__typename)}
coordinate={{ latitude: restaurant.latitude,longitude: restaurant.longitude }}
title={restaurant.name}
pinColor={colors.blue2}
onPress={(e) => {
pressMarker(e,restaurant.id)
}}
/>
)
})}
{likes.map(like => {
const restaurant = like.restaurant;
return(
<MapView.Marker
key={restaurant.id.toString().concat(restaurant.__typename)}
coordinate={{ latitude: restaurant.latitude,longitude: restaurant.longitude }}
title={restaurant.name}
pinColor={colors.red1}
onPress={(e) => {
pressMarker(e,restaurant.id)
}}
/>
)
})}
</MapView>
但是,在地图中,其他标记也是可见的。这些标记是 Google 地图默认显示的默认标记。地图放大得越多,出现的这些标记就越多。
这就是地图的样子。红色和蓝色标记是我的标记。代表 IHOP、Veselka、Veniero's Pasticceria & Caffe 等的标记是 Google 地图的默认标记。
我的问题有两个:
- 如何选择这些默认的 Google 地图标记?我尝试使用像 onPress 或 onMarkerSelect 这样的 MapView 方法,但是当我点击默认标记时没有事件触发器。
- 如何删除这些默认的 Google 地图标记?
非常感谢!!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。